PixmapDialog::PixmapDialog( QWidget *parent ) : Plasma::Dialog( parent ) { setResizeHandleCorners( Plasma::Dialog::NoCorner ); QVBoxLayout *layout = new QVBoxLayout( this ); label = new QLabel; label->setAutoFillBackground ( true ); label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); layout->addWidget( label ); setMinimumSize( 50, 50 ); connect( this, SIGNAL( dialogResized() ), this, SLOT( resized() ) ); connect( this, SIGNAL( showSignal() ), this, SLOT( show() ) ); }
PixmapListDialog::PixmapListDialog( QWidget *parent ) : Plasma::Dialog( parent ) { current_image = -1; movie_buffer = NULL; left_icon_hover = false; right_icon_hover = false; setResizeHandleCorners( Plasma::Dialog::NoCorner ); QVBoxLayout *layout = new QVBoxLayout( this ); const int icon_size = 36; const int label_size = 40; left_icon = new QLabel; left_icon->setAutoFillBackground ( true ); left_icon->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter ); left_icon_pixmap = KIconLoader::global()->loadIcon( "go-previous", KIconLoader::NoGroup, icon_size, KIconLoader::DefaultState, QStringList(), 0L, false ); left_icon->setPixmap( left_icon_pixmap ); left_icon->setFixedHeight( label_size ); left_icon->setFixedWidth( label_size ); left_icon->setAttribute( Qt::WA_Hover ); left_icon->installEventFilter( this ); title = new QLabel; QPalette palette = title->palette(); palette.setColor( QPalette::WindowText, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) ); palette.setColor( QPalette::Text, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) ); palette.setColor( QPalette::BrightText, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) ); title->setPalette( palette ); title->setAutoFillBackground ( true ); title->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter ); title->setFixedHeight( label_size ); right_icon = new QLabel; right_icon->setAutoFillBackground ( true ); right_icon->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter ); right_icon_pixmap = KIconLoader::global()->loadIcon( "go-next", KIconLoader::NoGroup, icon_size, KIconLoader::DefaultState, QStringList(), 0L, false ); right_icon->setPixmap( right_icon_pixmap ); right_icon->setFixedHeight( label_size ); right_icon->setFixedWidth( label_size ); right_icon->setAttribute( Qt::WA_Hover ); right_icon->installEventFilter( this ); QHBoxLayout *icon_layout = new QHBoxLayout; icon_layout->addWidget( left_icon ); icon_layout->addWidget( title ); icon_layout->addWidget( right_icon ); layout->addLayout( icon_layout ); background_label = new QLabel; background_label->setAutoFillBackground ( true ); background_label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); background_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); label = new QLabel( background_label ); label->setAutoFillBackground ( true ); label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); label->resize( background_label->size() ); label->installEventFilter( this ); layout->addWidget( background_label ); setMinimumSize( 50, 50 ); QPainterPath path; path.addRoundRect( QRectF( 0, 0, label_size - 2, label_size - 2 ), 15 ); QLinearGradient gradient( 0.5, 0, 0.5, 1 ); gradient.setCoordinateMode( QGradient::ObjectBoundingMode ); if ( qGray( Plasma::Theme::BackgroundColor ) < 140 ) { gradient.setColorAt( 0, QColor( 240, 240, 240, 255 ) ); gradient.setColorAt( 1, QColor( 140, 140, 140, 255 ) ); } else { gradient.setColorAt( 0, QColor( 140, 140, 140, 255 ) ); gradient.setColorAt( 1, QColor( 40, 40, 40, 255 ) ); } left_icon_pixmap_lighter = QPixmap( label_size, label_size ); left_icon_pixmap_lighter.fill( Qt::transparent ); QPainter painter_left( &left_icon_pixmap_lighter ); painter_left.setBrush( gradient ); painter_left.translate( 1, 1 ); painter_left.drawPath( path ); painter_left.translate( -1, -1 ); painter_left.drawPixmap( QRect( (int)(0.5*(label_size-icon_size)), (int)(0.5*(label_size-icon_size)), left_icon_pixmap.width(), left_icon_pixmap.height() ), left_icon_pixmap ); right_icon_pixmap_lighter = QPixmap( label_size, label_size ); right_icon_pixmap_lighter.fill( Qt::transparent ); QPainter painter_right( &right_icon_pixmap_lighter ); painter_right.setBrush( gradient ); painter_left.translate( 0.5, 0.5 ); painter_right.drawPath( path ); painter_left.translate( -0.5, -0.5 ); painter_right.drawPixmap( QRect( (int)(0.5*(label_size-icon_size)), (int)(0.5*(label_size-icon_size)), right_icon_pixmap.width(), right_icon_pixmap.height() ), right_icon_pixmap ); connect( this, SIGNAL( dialogResized() ), this, SLOT( resized() ) ); }
void SpellCheck::toggleDialog(bool pasteText, bool preferSelection) { if (!m_spellingDialog) { m_spellingDialog = new Plasma::Dialog(); KWindowSystem::setState(m_spellingDialog->effectiveWinId(), NET::SkipTaskbar|NET::SkipPager); m_spellingDialog->setFocusPolicy(Qt::NoFocus); m_spellingDialog->setWindowTitle(i18n("Spell checking")); m_spellingDialog->setWindowIcon(KIcon("tools-check-spelling")); m_spellingDialog->setResizeHandleCorners(Plasma::Dialog::All); m_textEdit = new KTextEdit(m_spellingDialog); m_textEdit->enableFindReplace(false); m_textEdit->setCheckSpellingEnabled(true); m_textEdit->createHighlighter(); m_dictionaryComboBox = new Sonnet::DictionaryComboBox(m_spellingDialog); m_dictionaryComboBox->setToolTip(i18n("Language")); KAction *spellingAction = new KAction(KIcon("tools-check-spelling"), i18n("Spell checking"), m_spellingDialog); KAction *copyAction = new KAction(KIcon("edit-copy"), i18n("Copy"), m_spellingDialog); KAction *closeAction = new KAction(KIcon("dialog-close"), i18n("Close"), m_spellingDialog); QToolButton *spellingButton = new QToolButton(m_spellingDialog); spellingButton->setDefaultAction(spellingAction); QToolButton *copyButton = new QToolButton(m_spellingDialog); copyButton->setDefaultAction(copyAction); QToolButton *closeButton = new QToolButton(m_spellingDialog); closeButton->setDefaultAction(closeAction); QHBoxLayout *horizontalLayout = new QHBoxLayout; horizontalLayout->addWidget(m_dictionaryComboBox); horizontalLayout->addWidget(spellingButton); horizontalLayout->addWidget(copyButton); horizontalLayout->addWidget(closeButton); QVBoxLayout *verticalLayout = new QVBoxLayout(m_spellingDialog); verticalLayout->setSpacing(0); verticalLayout->setMargin(0); verticalLayout->addWidget(m_textEdit); verticalLayout->addLayout(horizontalLayout); configChanged(); connect(m_spellingDialog, SIGNAL(dialogResized()), this, SLOT(dialogResized())); connect(spellingAction, SIGNAL(triggered()), m_textEdit, SLOT(checkSpelling())); connect(copyAction, SIGNAL(triggered()), this, SLOT(copyToClipboard())); connect(closeAction, SIGNAL(triggered()), this, SLOT(toggleDialog())); connect(m_textEdit, SIGNAL(languageChanged(QString)), this, SLOT(setLanguage(QString))); connect(m_dictionaryComboBox, SIGNAL(dictionaryChanged(QString)), this, SLOT(setLanguage(QString))); } if (m_spellingDialog->isVisible()) { m_spellingDialog->animatedHide(Plasma::locationToInverseDirection(location())); m_textEdit->clear(); } else { m_spellingDialog->move(popupPosition(m_spellingDialog->sizeHint())); m_spellingDialog->animatedShow(Plasma::locationToDirection(location())); if (pasteText) { m_textEdit->setText((!preferSelection || QApplication::clipboard()->text(QClipboard::Selection).isEmpty()) ? QApplication::clipboard()->text(QClipboard::Clipboard) : QApplication::clipboard()->text(QClipboard::Selection)); } m_textEdit->setFocus(); } }