void RatingWidget::slotThemeChanged() { d->regPixmap = QPixmap(15, 15); d->regPixmap.fill(Qt::transparent); d->selPixmap = QPixmap(15, 15); d->selPixmap.fill(Qt::transparent); d->disPixmap = QPixmap(15, 15); d->disPixmap.fill(Qt::transparent); QPainter p1(&d->regPixmap); p1.setRenderHint(QPainter::Antialiasing, true); p1.setBrush(palette().color(QPalette::Active, backgroundRole())); p1.setPen(palette().color(QPalette::Active, foregroundRole())); p1.drawPolygon(d->starPolygon, Qt::WindingFill); p1.end(); QPainter p2(&d->selPixmap); p2.setRenderHint(QPainter::Antialiasing, true); p2.setBrush(ThemeEngine::instance()->textSpecialRegColor()); p2.setPen(palette().color(QPalette::Active, foregroundRole())); p2.drawPolygon(d->starPolygon, Qt::WindingFill); p2.end(); QPainter p3(&d->disPixmap); p3.setRenderHint(QPainter::Antialiasing, true); p3.setBrush(palette().color(QPalette::Disabled, backgroundRole())); p3.setPen(palette().color(QPalette::Disabled, foregroundRole())); p3.drawPolygon(d->starPolygon, Qt::WindingFill); p3.end(); setMinimumSize(QSize((d->regPixmap.width()+1)*RatingMax, d->regPixmap.height())); update(); }
void PsiTipLabel::paintEvent(QPaintEvent *) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); // stolen from QLabel::paintEvent QPainter painter(this); drawFrame(&painter); QRect cr = contentsRect(); cr.adjust(margin, margin, -margin, -margin); PsiRichText::ensureTextLayouted(doc, width() - 2*margin); QAbstractTextDocumentLayout *layout = doc->documentLayout(); // QRect lr = rect(); QRect lr = cr; QAbstractTextDocumentLayout::PaintContext context; // Adjust the palette context.palette = palette(); if (foregroundRole() != QPalette::Text && isEnabled()) context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole())); painter.save(); painter.translate(lr.x() + 1, lr.y() + 1); painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1)); layout->draw(&painter, context); painter.restore(); }
void KexiDBImageBox::setPalette(const QPalette &pal) { KexiFrame::setPalette(pal); if (m_insideSetPalette) return; m_insideSetPalette = true; setPaletteBackgroundColor(pal.active().base()); //setPaletteForegroundColor(pal.active().foreground()); QPalette p(palette()); p.setColor(foregroundRole(), pal.color(foregroundRole())); setPalette(p); m_insideSetPalette = false; }
void ScriptEditorWidget::updateOptions() { QPalette p = palette(); p.setColor(QPalette::Base,g_clrBackground); p.setColor(QPalette::Text,g_clrNormalText); setPalette(p); setFont(g_fntNormal); setTextColor(g_clrNormalText); disableSyntaxHighlighter(); enableSyntaxHighlighter(); p = ((ScriptEditorImplementation*)m_pParent)->findLineEdit()->palette(); p.setColor(foregroundRole(),g_clrFind); ((ScriptEditorImplementation*)m_pParent)->findLineEdit()->setPalette(p); //set cursor custom width if (KVI_OPTION_BOOL(KviOption_boolEnableCustomCursorWidth)) { setCursorWidth(KVI_OPTION_UINT(KviOption_uintCustomCursorWidth)); } else { #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) int iCursorWidth = 1; SystemParametersInfo(SPI_GETCARETWIDTH, 0, &iCursorWidth, 0); setCursorWidth(iCursorWidth); #endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW } }
void KexiDBLabel::init() { KexiDataItemInterface::setHasFocusableWidget(false); d->frameColor = palette().color(foregroundRole()); setIndent(2); setAutoFillBackground(true); }
void VCClock::paintEvent(QPaintEvent* e) { QPainter painter(this); if (clockType() == Clock) { QDateTime currTime = QDateTime::currentDateTime(); style()->drawItemText(&painter, rect(), Qt::AlignCenter | Qt::TextWordWrap, palette(), true, currTime.time().toString(), foregroundRole()); } else { quint32 secTime = m_currentTime; uint h, m; h = secTime / 3600; secTime -= (h * 3600); m = secTime / 60; secTime -= (m * 60); style()->drawItemText(&painter, rect(), Qt::AlignCenter | Qt::TextWordWrap, palette(), true, QString("%1:%2:%3").arg(h, 2, 10, QChar('0')) .arg(m, 2, 10, QChar('0')).arg(secTime, 2, 10, QChar('0')), foregroundRole()); } painter.end(); VCWidget::paintEvent(e); }
PreviewWidget::PreviewWidget(QWidget *parent) : QFrame(parent), m_textLabel(new QLabel(this)), m_pixmapLabel(new QLabel(this)), m_moveAnimation(nullptr) { QVBoxLayout *layout(new QVBoxLayout(this)); layout->addWidget(m_pixmapLabel); layout->addWidget(m_textLabel); QPalette palette; palette.setColor(backgroundRole(), palette.color(QPalette::ToolTipBase)); palette.setColor(QPalette::Base, palette.color(QPalette::ToolTipBase)); palette.setColor(foregroundRole(), palette.color(QPalette::ToolTipText)); palette.setColor(QPalette::Text, palette.color(QPalette::ToolTipText)); setPalette(palette); setLayout(layout); setWindowFlags(windowFlags() | Qt::ToolTip); setObjectName(QLatin1String("previewWidget")); setStyleSheet(QLatin1String("#previewWidget {border:1px solid #B3B3B3;border-radius:4px;}")); m_textLabel->setFixedWidth(260); m_textLabel->setAlignment(Qt::AlignCenter); m_textLabel->setTextFormat(Qt::PlainText); m_textLabel->setPalette(palette); m_pixmapLabel->setFixedWidth(260); m_pixmapLabel->setAlignment(Qt::AlignCenter); m_pixmapLabel->setPalette(palette); m_pixmapLabel->setStyleSheet(QLatin1String("border:1px solid gray;")); }
ErrorOverlay::ErrorOverlay(QWidget *baseWidget, const QString &details, QWidget *parent) : QWidget(parent ? parent : baseWidget->window()), m_BaseWidget(baseWidget) { // Build the UI QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(10); QLabel *pixmap = new QLabel(); pixmap->setPixmap(KIcon("dialog-error").pixmap(64)); QLabel *message = new QLabel(i18n("Power Management configuration module could not be loaded.\n%1", details)); pixmap->setAlignment(Qt::AlignHCenter); message->setAlignment(Qt::AlignHCenter); layout->addStretch(); layout->addWidget(pixmap); layout->addWidget(message); layout->addStretch(); setLayout(layout); // Draw the transparent overlay background QPalette p = palette(); p.setColor(backgroundRole(), QColor(0, 0, 0, 128)); p.setColor(foregroundRole(), Qt::white); setPalette(p); setAutoFillBackground(true); m_BaseWidget->installEventFilter(this); reposition(); }
ConsoleWindow::ConsoleWindow(QWidget *parent) : QDialog(parent), ui(new Ui::ConsoleWindow) { ui->setupUi(this); this->resize(500, 300); setWindowIcon(QIcon(QString::fromUtf8(":/resources/conceptclienticon.png"))); this->ui->userframe->hide(); QApplication::setWindowIcon(QIcon(QString::fromUtf8(":/resources/conceptclienticon.png"))); QStyle *l_style = QApplication::style(); ui->OkButton->setIcon(l_style->standardIcon(QStyle::SP_DialogOkButton)); ui->CancelButton->setIcon(l_style->standardIcon(QStyle::SP_DialogCancelButton)); this->CC = NULL; ui->splash->setPixmap(QPixmap(":/resources/splash.jpg")); setAutoFillBackground(true); QPalette p = palette(); p.setColor(backgroundRole(), QColor(14, 14, 14)); p.setColor(foregroundRole(), QColor(0xD0, 0xD0, 0xD8)); setPalette(p); this->ui->label_5->setPalette(p); this->ui->label_6->setPalette(p); this->ui->radio1->setPalette(p); this->ui->radio2->setPalette(p); this->ui->radio3->setPalette(p); this->ui->console->hide(); this->ui->progressBar->setMaximumHeight(3); this->ui->progressBar->setStyleSheet(QString("QProgressBar { border: 0px; background-color: #0E0E0E;} QProgressBar::chunk:horizontal { background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #0E0E0E, stop: 0.8 #D0D0FF, stop: 1 #0E0E0E);}")); this->ui->console->setStyleSheet(QString("QWidget { border: 0px; background-color: #0E0E0E; color: #D0D0D8;}")); this->ui->console->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->ui->console->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setWindowFlags(Qt::FramelessWindowHint); started = false; }
void XLabel::setTextColor(const QString &pColorName) { QColor c = namedColor(pColorName); QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
void CaptureFilterEdit::paintEvent(QPaintEvent *evt) { SyntaxLineEdit::paintEvent(evt); // http://wiki.forum.nokia.com/index.php/Custom_QLineEdit if (text().isEmpty() && ! this->hasFocus()) { QPainter p(this); QFont f = font(); f.setItalic(true); p.setFont(f); QColor color(palette().color(foregroundRole())); color.setAlphaF(0.5); p.setPen(color); QStyleOptionFrame opt; initStyleOption(&opt); QRect cr = style()->subElementRect(QStyle::SE_LineEditContents, &opt, this); cr.setLeft(cr.left() + 2); cr.setRight(cr.right() - 2); p.drawText(cr, Qt::AlignLeft|Qt::AlignVCenter, placeholder_text_); } // else check filter syntax and set the background accordingly // XXX - Should we add little warning/error icons as well? }
PreviewWidget::PreviewWidget(QWidget *parent) : QWidget(parent), m_textLabel(new QLabel(this)), m_pixmapLabel(new QLabel(this)), m_moveAnimation(NULL) { QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_pixmapLabel); layout->addWidget(m_textLabel); QPalette palette; palette.setColor(backgroundRole(), palette.color(QPalette::ToolTipBase)); palette.setColor(QPalette::Base, palette.color(QPalette::ToolTipBase)); palette.setColor(foregroundRole(), palette.color(QPalette::ToolTipText)); palette.setColor(QPalette::Text, palette.color(QPalette::ToolTipText)); setPalette(palette); setLayout(layout); setWindowFlags(windowFlags() | Qt::ToolTip); m_textLabel->setFixedWidth(260); m_textLabel->setAlignment(Qt::AlignCenter); m_textLabel->setPalette(palette); m_pixmapLabel->setFixedWidth(260); m_pixmapLabel->setAlignment(Qt::AlignCenter); m_pixmapLabel->setPalette(palette); }
// slot void WSearchLineEdit::restoreSearch(const QString& text) { if(text.isNull()) { // disable setEnabled(false); blockSignals(true); setText("- - -"); blockSignals(false); return; } setEnabled(true); qDebug() << "WSearchLineEdit::restoreSearch(" << text << ")"; blockSignals(true); setText(text); blockSignals(false); if (text == "") { m_place = true; showPlaceholder(); } else { QPalette pal = palette(); pal.setColor(foregroundRole(), m_fgc); setPalette(pal); m_place = false; } updateCloseButton(text); }
QStyleOptionTabV2 YaTabBarBase::getStyleOption(int tab) const { QStyleOptionTabV2 opt; opt.init(this); opt.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); opt.rect = tabRect(tab); bool isCurrent = tab == currentIndex(); opt.row = 0; // if (tab == pressedIndex) // opt.state |= QStyle::State_Sunken; if (isCurrent) opt.state |= QStyle::State_Selected; if (isCurrent && hasFocus()) opt.state |= QStyle::State_HasFocus; if (isTabEnabled(tab)) opt.state &= ~QStyle::State_Enabled; if (isActiveWindow()) opt.state |= QStyle::State_Active; // if (opt.rect == hoverRect) // opt.state |= QStyle::State_MouseOver; opt.shape = shape(); opt.text = tabText(tab); if (tabTextColor(tab).isValid()) opt.palette.setColor(foregroundRole(), tabTextColor(tab)); opt.icon = tabIcon(tab); opt.iconSize = opt.icon.actualSize(QSize(32, 32)); // Will get the default value then. int totalTabs = count(); if (tab > 0 && tab - 1 == currentIndex()) opt.selectedPosition = QStyleOptionTab::PreviousIsSelected; else if (tab < totalTabs - 1 && tab + 1 == currentIndex()) opt.selectedPosition = QStyleOptionTab::NextIsSelected; else opt.selectedPosition = QStyleOptionTab::NotAdjacent; if (tab == 0) { if (totalTabs > 1) opt.position = QStyleOptionTab::Beginning; else opt.position = QStyleOptionTab::OnlyOneTab; } else if (tab == totalTabs - 1) { opt.position = QStyleOptionTab::End; } else { opt.position = QStyleOptionTab::Middle; } if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(parentWidget())) { if (tw->cornerWidget(Qt::TopLeftCorner) || tw->cornerWidget(Qt::BottomLeftCorner)) opt.cornerWidgets |= QStyleOptionTab::LeftCornerWidget; if (tw->cornerWidget(Qt::TopRightCorner) || tw->cornerWidget(Qt::BottomRightCorner)) opt.cornerWidgets |= QStyleOptionTab::RightCornerWidget; } return opt; }
void KexiLinkButton::updateIcon(const KIcon &icon) { if (!d->usesForegroundColor) return; QColor c(palette().color(foregroundRole())); QPixmap pixmap(icon.pixmap(iconSize())); KexiUtils::replaceColors(&pixmap, c); KPushButton::setIcon(KIcon(pixmap)); }
void TextLineNumbers::setTextColor( const QColor& c ) { if ( c == mTextColor ) return; mTextColor = c; QPalette p( palette() ); p.setColor( foregroundRole(), mTextColor ); setPalette( p ); emit textColorChanged( mTextColor ); }
QColor AnimatedBarWidget::foregroundColor() const { const bool isHighlighted = isHoverHintEnabled(); QColor foregroundColor = palette().color( foregroundRole() ); if( !isHighlighted ) foregroundColor.setAlpha( 60 ); return foregroundColor; }
void Location::setNext(const QString& newUrl) { if (newUrl.isEmpty()) { setPalette(QPalette()); setText(m_url); } else { QPalette p = palette(); p.setColor(foregroundRole(), Qt::blue); setPalette(p); setText(newUrl); } }
//******************************************************************* // showEvent PRIVATE inherited //******************************************************************* void QBtPackDialog::showEvent( QShowEvent* const in_event ) { QBtShared::resize_width( this, 30 ); QDialog::showEvent( in_event ); { QPalette p = QPalette(); p.setColor( source_->backgroundRole(), palette().color( backgroundRole() ) ); p.setColor( source_->foregroundRole(), palette().color( foregroundRole() ) ); source_->setPalette( p ); } { QPalette p = QPalette(); p.setColor( destination_->backgroundRole(), palette().color( backgroundRole() ) ); p.setColor( destination_->foregroundRole(), palette().color( foregroundRole() ) ); destination_->setPalette( p ); } remove_ext(); display_src( *data_.begin() ); display_dst(); }
bool BE::Contacts::setPhoto(const QString &path) { QRect r(0,0,160,160); QImage img = QImage( path ); if (img.isNull()) return false; const float f = qMin( float(img.width())/float(r.width()), float(img.height())/float(r.height()) ); r.setSize( r.size()*f ); r.moveTopRight( img.rect().topRight() ); img = img.copy(r).scaled( QSize(160,160), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); img = img.convertToFormat(QImage::Format_ARGB32); // if ( !MPC::setting("rgbCover").toBool() ) { int r,g,b; palette().color(foregroundRole()).getRgb(&r,&g,&b); int n = img.width() * img.height(); const uchar *bits = img.bits(); QRgb *pixel = (QRgb*)(const_cast<uchar*>(bits)); // this creates a (slightly) translucent monochromactic version of the // image using the foreground color // the gray value is turned into the opacity #define ALPHA qAlpha(pixel[i]) #define GRAY qGray(pixel[i]) #define OPACITY 224 if ( qMax( qMax(r,g), b ) > 128 ) // value > 50%, bright foreground for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (OPACITY*GRAY) / 255 ) ) / 255 ); else // inverse for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (OPACITY*(255-GRAY)) / 255 ) ) / 255 ); } #if 1 QPainterPath glasPath; glasPath.moveTo( img.rect().topLeft() ); glasPath.lineTo( img.rect().topRight() ); glasPath.quadTo( img.rect().center()/2, img.rect().bottomLeft() ); QPainter p( &img ); p.setRenderHint( QPainter::Antialiasing ); p.setPen( Qt::NoPen ); p.setBrush( QColor(255,255,255,64) ); p.drawPath(glasPath); p.end(); #endif m_ui2->photo->setPixmap( QPixmap::fromImage( img ) ); return true; }
void VCLabel::paintEvent(QPaintEvent* e) { bool enabled = false; if (mode() == Doc::Operate && isDisabled() == false) enabled = true; QPainter painter(this); style()->drawItemText(&painter, rect(), Qt::AlignCenter | Qt::TextWordWrap, palette(), enabled, caption(), foregroundRole()); painter.end(); VCWidget::paintEvent(e); }
void KexiDBAutoField::setForegroundLabelColor(const QColor & color) { if (d->widgetType == Boolean) setPaletteForegroundColor(color); else { QPalette pal(d->label->palette()); pal.setColor(d->label->foregroundRole(), color); d->label->setPalette(pal); pal = palette(); pal.setColor(foregroundRole(), color); setPalette(pal); } }
Clock::Clock(QWidget* parent) : QLabel(parent), m_clock(0, 0, 0), m_paused(true), m_stopped(true) { QFont f = font(); f.setPixelSize(20); setFont(f); setCursor(Qt::PointingHandCursor); QPalette p = palette(); p.setColor(foregroundRole(), Qt::white); setPalette(p); m_clock_timer = new QTimeLine(1000, this); connect(m_clock_timer, SIGNAL(finished()), this, SLOT(tick())); }
QPixmap AlbumLabelsTreeView::colorRectPixmap(const QColor& color) const { QRect rect(8, 8, 48, 48); QPixmap pixmap = QPixmap(60, 60); pixmap.fill(Qt::transparent); QPainter p1(&pixmap); p1.setRenderHint(QPainter::Antialiasing, true); p1.setBrush(color); p1.setPen(palette().color(QPalette::Active, foregroundRole())); p1.drawRect(rect); p1.end(); return pixmap; }
QColor KUrlNavigatorButtonBase::foregroundColor() const { const bool isHighlighted = isDisplayHintEnabled(EnteredHint) || isDisplayHintEnabled(DraggedHint) || isDisplayHintEnabled(PopupActiveHint); QColor foregroundColor = palette().color(foregroundRole()); int alpha = m_active ? 255 : 128; if (!m_active && !isHighlighted) { alpha -= alpha / 4; } foregroundColor.setAlpha(alpha); return foregroundColor; }
void WSearchLineEdit::showPlaceholder() { //Must block signals here so that we don't emit a search() signal via //textChanged(). blockSignals(true); setText(tr("Search..." , "noun")); setToolTip(tr("Search" , "noun") + "\n" + tr("Enter a string to search for") + "\n\n" + tr("Shortcut")+ ": \n" + tr("Ctrl+F") + " " + tr("Focus" , "Give search bar input focus") + "\n" + tr("Ctrl+Backspace") + " "+ tr("Clear input" , "Clear the search bar input field") + "\n" + tr("Esc") + " " + tr("Exit search" , "Exit search bar and leave focus") ); blockSignals(false); QPalette pal = palette(); pal.setColor(foregroundRole(), Qt::lightGray); setPalette(pal); }
void K3b::ThemedLabel::slotThemeChanged() { setAutoFillBackground( true ); if( K3b::Theme* theme = k3bappcore->themeManager()->currentTheme() ) { QPalette p = palette(); p.setColor( backgroundRole(), theme->backgroundColor() ); p.setColor( foregroundRole(), theme->foregroundColor() ); setPalette( p ); if( m_themePixmapCode > -1 ) { setPixmap( theme->pixmap( (K3b::Theme::PixmapType)m_themePixmapCode ) ); setScaledContents( false ); if ( pixmap() ) { setFixedSize( pixmap()->size() ); } } } }
void TrackActionButton::reloadContent( const QSize &sz ) { if ( sz.isNull() ) return; int r,g,b; palette().color(foregroundRole()).getRgb(&r,&g,&b); m_icon.image[2] = m_icon.icon.pixmap( sz ).toImage(); QImage img = m_icon.image[2].convertToFormat(QImage::Format_ARGB32); int n = img.width() * img.height(); const uchar *bits = img.bits(); QRgb *pixel = (QRgb*)(const_cast<uchar*>(bits)); // this creates a (slightly) translucent monochromactic version of the // image using the foreground color // the gray value is turned into the opacity #define ALPHA qAlpha(pixel[i]) #define GRAY qGray(pixel[i]) if ( qMax( qMax(r,g), b ) > 128 ) // value > 50%, bright foreground for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*GRAY) / 255 ) ) / 255 ); else // inverse for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*(255-GRAY)) / 255 ) ) / 255 ); // premultiplied is much faster on painting / alphablending m_icon.image[1] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied); // and a very translucent variant for (int i = 0; i < n; ++i) pixel[i] = qRgba(r,g,b, ALPHA/6); #undef ALPHA #undef GRAY m_icon.image[0] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied); int i = 0; if ( underMouse() ) i = 2; else if ( !parentWidget() || parentWidget()->underMouse() ) i = 1; setIcon( m_icon.image[i] ); }
void WSearchLineEdit::focusInEvent(QFocusEvent* event) { QLineEdit::focusInEvent(event); if (m_place) { // This gets rid of the blue mac highlight. setAttribute(Qt::WA_MacShowFocusRect, false); //Must block signals here so that we don't emit a search() signal via //textChanged(). blockSignals(true); setText(""); blockSignals(false); QPalette pal = palette(); pal.setColor(foregroundRole(), m_fgc); setPalette(pal); m_place = false; emit(searchStarting()); } }
YTTabBar::YTTabBar(QWidget *parent) : QTabBar(parent), hoveredIndex(-1), pressedIndex(-1) { QPalette p = palette(); p.setColor(backgroundRole(), Qt::black); p.setColor(foregroundRole(), Qt::white); setPalette(p); setAutoFillBackground(true); setMouseTracking(true); QPixmap masterPix = QPixmap(":/Control/bg-tabs.png"); selectedPix = masterPix.copy(0, 0, masterPix.width(), masterPix.height()/4); nonSelectedPix= masterPix.copy(0, masterPix.height()/4, masterPix.width(), masterPix.height()/4); hoverPix = masterPix.copy(0, masterPix.height()*2/4, masterPix.width(), masterPix.height()/4); clickedPix = masterPix.copy(0, masterPix.height()*3/4, masterPix.width(), masterPix.height()/4); sepPix = QPixmap(":/Control/bg-tabs-sep.png"); setExpanding(true); setFixedHeight(masterPix.height() / 4); }