void SyntaxHighlighter::settingsChanged() { QRegExp re(QString(" +$|^ +|.?")+QChar(0x0000AD)+".?"); //soft hyphen if (Settings::highlightSpaces() && highlightingRules.last().pattern!=re) { KColorScheme colorScheme(QPalette::Normal); HighlightingRule rule; rule.format.clearForeground(); //nbsp rule.format.setBackground(colorScheme.background(KColorScheme::AlternateBackground)); rule.pattern = QRegExp(QChar(0x00a0U)); highlightingRules.append(rule); //usual spaces at the end rule.format.setBackground(colorScheme.background(KColorScheme::ActiveBackground)); rule.pattern = re; highlightingRules.append(rule); rehighlight(); } else if (!Settings::highlightSpaces() && highlightingRules.last().pattern==re) { highlightingRules.resize(highlightingRules.size()-2); rehighlight(); } }
void ActiveVocabulary::buildBrushes() { KColorScheme colorScheme(QPalette::Active); QColor negative = colorScheme.background(KColorScheme::NegativeBackground).color(); recogNone = KColorScheme::shade(negative, KColorScheme::MidShade); }
CompressionOptionsWidget::CompressionOptionsWidget(QWidget *parent, const CompressionOptions &opts) : QWidget(parent) , m_opts(opts) { setupUi(this); KColorScheme colorScheme(QPalette::Active, KColorScheme::View); pwdWidget->setBackgroundWarningColor(colorScheme.background(KColorScheme::NegativeBackground).color()); pwdWidget->setPasswordStrengthMeterVisible(false); connect(multiVolumeCheckbox, &QCheckBox::stateChanged, this, &CompressionOptionsWidget::slotMultiVolumeChecked); if (m_opts.contains(QStringLiteral("VolumeSize"))) { multiVolumeCheckbox->setChecked(true); // Convert from kilobytes. volumeSizeSpinbox->setValue(m_opts.value(QStringLiteral("VolumeSize")).toDouble() / 1024); } }
const QPalette *HawaiiTheme::palette(Palette type) const { #if 0 switch (type) { case SystemPalette: { QString colorSchemeName = m_settings->value("interface/color-scheme").toString(); if (colorSchemeName.isEmpty()) return QPlatformTheme::palette(type); VColorScheme colorScheme(QString("%1/%2.colors").arg(path).arg(colorSchemeName)); return colorScheme.palette(); } default: break; } #endif return new QPalette(); }
void FindBar::notifyMatch(bool match) { QPalette p = m_lineEdit->palette(); KColorScheme colorScheme(p.currentColorGroup()); if (m_lineEdit->text().isEmpty()) { p.setColor(QPalette::Base, colorScheme.background(KColorScheme::NormalBackground).color()); } else { if (match) { p.setColor(QPalette::Base, colorScheme.background(KColorScheme::PositiveBackground).color()); } else { p.setColor(QPalette::Base, colorScheme.background(KColorScheme::NegativeBackground).color()); // previous were 247, 230, 230 } } m_lineEdit->setPalette(p); }
void MoonPhaseCalendar::paintEvent( QPaintEvent *e ) { QPainter p( this ); if( !imagesLoaded ) loadImages(); KColorScheme colorScheme(palette().currentColorGroup(), KColorScheme::View); const QRect &rectToUpdate = e->rect(); int leftCol = ( int )std::floor( rectToUpdate.left() / cellWidth ); int topRow = ( int )std::floor( rectToUpdate.top() / cellHeight ); int rightCol = ( int )std::ceil( rectToUpdate.right() / cellWidth ); int bottomRow = ( int )std::ceil( rectToUpdate.bottom() / cellHeight ); bottomRow = qMin( bottomRow, numWeekRows - 1 ); rightCol = qMin( rightCol, numDayColumns - 1 ); p.translate( leftCol * cellWidth, topRow * cellHeight ); for ( int i = leftCol; i <= rightCol; ++i ) { for ( int j = topRow; j <= bottomRow; ++j ) { this->paintCell( &p, j, i, colorScheme ); p.translate( 0, cellHeight ); } p.translate( cellWidth, 0 ); p.translate( 0, -cellHeight * ( bottomRow - topRow + 1 ) ); } p.end(); }
void TodoDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { KColorScheme colorScheme( option.palette.currentColorGroup() ); QPen pen; // if( option.state & QStyle::State_Selected ){ // painter->fillRect(option.rect, option.palette.highlight() ); // } QPoint originPoint = option.rect.topLeft(); originPoint.rx()++; originPoint.ry()++; QMap<QString,QVariant> map( index.data().toMap() ); QStyleOptionViewItem newOption = option; if( map["type"] == 1 ){ switch( map["priority"].toInt() ){ case 1: if( Settings::self()->getUseOwnColor() ){ newOption.palette.setColor(QPalette::Background, Settings::self()->getPriority1() ); } else { newOption.palette.setColor(QPalette::Background, colorScheme.background(KColorScheme::NegativeBackground).color()); } if( Settings::self()->getUseOwnFontColor() ){ pen.setColor( Settings::self()->getPriority1Font() ); } painter->fillRect(newOption.rect, newOption.palette.background()); break; case 2: if( Settings::self()->getUseOwnColor() ){ newOption.palette.setColor(QPalette::Background, Settings::self()->getPriority2() ); } else { newOption.palette.setColor(QPalette::Background, colorScheme.background(KColorScheme::NeutralBackground).color()); } if( Settings::self()->getUseOwnFontColor() ){ pen.setColor( Settings::self()->getPriority2Font() ); } painter->fillRect(newOption.rect, newOption.palette.background()); break; case 3: if( Settings::self()->getUseOwnColor() ){ newOption.palette.setColor(QPalette::Background, Settings::self()->getPriority3() ); } else { newOption.palette.setColor(QPalette::Background, colorScheme.background(KColorScheme::PositiveBackground).color()); } if( Settings::self()->getUseOwnFontColor() ){ pen.setColor( Settings::self()->getPriority3Font() ); } painter->fillRect(newOption.rect, newOption.palette.background()); break; default: newOption.palette.setColor(QPalette::Background, colorScheme.background(KColorScheme::NormalBackground).color()); break; } painter->fillRect(newOption.rect, newOption.palette.background()); //qDebug() << newOption.palette.background().color().toRgb(); } painter->save(); QStyledItemDelegate::paint(painter,newOption,index); painter->restore(); if( map["type"] == 0 ){ if( index.column() != 0 ){ return; } QString iconName; if( view->isExpanded(index) ){ iconName = "arrow-down"; } else { iconName = "arrow-right"; } QRect iconRect(originPoint, QSize(15,15)); painter->drawPixmap(iconRect, KIcon(iconName).pixmap(QSize(15,15)) ); painter->save(); painter->setFont(boldFont); QPoint writePoint( originPoint + QPoint(iconRect.size().width()+5,0) ); QString text = cutString( map["name"].toString(), QRect( writePoint, newOption.rect.bottomRight() ), boldFont ); painter->drawText( QRect( writePoint, newOption.rect.bottomRight() ), text ); painter->restore(); } if( map["type"] == 1 ){ painter->save(); painter->setPen(pen); originPoint.ry()++; if( index.column() == 0 ){ originPoint.rx() += 25; // for the checkbox QString text = map["name"].toString(); // if( map["priority"].toInt() == 4 ){ // text.prepend("- "); // } else { // text.prepend( QString::number(map["priority"].toInt()) + " " ); // } text = cutString( text, QRect(originPoint,newOption.rect.bottomRight()), standardFont ); painter->drawText( QRect(originPoint,newOption.rect.bottomRight()), text ); } else { QString text = cutString( map["date"].toDate().toString(), QRect(originPoint,newOption.rect.bottomRight()), standardFont ); painter->drawText( QRect(originPoint,newOption.rect.bottomRight()), text); if(map["date"].toDate().isNull()){ painter->drawText( QRect(originPoint,newOption.rect.bottomRight()), "-"); } } painter->restore(); } }
/** Get the colors for the wire property. */ const WireColorScheme & WirePropertyInteger::getColorScheme() const { return colorScheme(); }