/*! \~russian * \brief Метод инициализирует элементы настройки цвета в соответствии с переданной палитрой. * \param palette - палитра для инициализации */ void Settings::initColorPickers(QPalette palette) { ui->Frame_Style_Window->setColor( palette.window().color() ); ui->Frame_Style_WindowText->setColor( palette.windowText().color() ); ui->Frame_Style_Base->setColor( palette.base().color() ); ui->Frame_Style_AlternateBase->setColor( palette.alternateBase().color() ); ui->Frame_Style_ToolTipBase->setColor( palette.toolTipBase().color() ); ui->Frame_Style_ToolTipText->setColor( palette.toolTipText().color() ); ui->Frame_Style_Text->setColor( palette.text().color() ); ui->Frame_Style_Button->setColor( palette.button().color() ); ui->Frame_Style_ButtonText->setColor( palette.buttonText().color() ); ui->Frame_Style_BrightText->setColor( palette.brightText().color() ); ui->Frame_Style_Link->setColor( palette.link().color() ); ui->Frame_Style_Highlight->setColor( palette.highlight().color() ); ui->Frame_Style_HighlightedText->setColor( palette.highlightedText().color() ); }
void KisCategorizedItemDelegate::paintTriangle(QPainter* painter, qint32 x, qint32 y, qint32 size, bool rotate) const { QPolygonF triangle; triangle.push_back(QPointF(-0.2,-0.2)); triangle.push_back(QPointF( 0.2,-0.2)); triangle.push_back(QPointF( 0.0, 0.2)); QTransform transform; transform.translate(x + size/2, y + size/2); transform.scale(size, size); if(rotate) transform.rotate(-90); QPalette palette = QApplication::palette(); painter->setBrush(palette.buttonText()); painter->drawPolygon(transform.map(triangle)); }
void KisCategorizedItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->resetTransform(); if(!index.data(__CategorizedListModelBase::IsHeaderRole).toBool()) { QStyleOptionViewItem sovi(option); if (index.data(__CategorizedListModelBase::isLockableRole).toBool()) { bool locked = index.data(__CategorizedListModelBase::isLockedRole).toBool(); const QIcon icon = locked ? KisIconUtils::loadIcon(koIconName("locked")) : KisIconUtils::loadIcon(koIconName("unlocked")); const int iconSize = qMax(16, m_minimumItemHeight - 2); sovi.decorationPosition = QStyleOptionViewItem::Right; sovi.decorationAlignment = Qt::AlignRight; sovi.decorationSize = QSize(iconSize, iconSize); sovi.features |= QStyleOptionViewItem::HasDecoration; sovi.icon = icon; } QStyledItemDelegate::paint(painter, sovi, index); painter->setOpacity(1); } else { QPalette palette = QApplication::palette(); if(option.state & QStyle::State_MouseOver) painter->fillRect(option.rect, palette.midlight()); else painter->fillRect(option.rect, palette.button()); painter->setBrush(palette.buttonText()); painter->drawText(option.rect, index.data().toString(), QTextOption(Qt::AlignVCenter|Qt::AlignHCenter)); paintTriangle( painter, option.rect.x(), option.rect.y(), option.rect.height(), !index.data(__CategorizedListModelBase::ExpandCategoryRole).toBool() ); } painter->resetTransform(); }
QVariantMap Bridge::get_palette() { QVariantMap colors; QPalette palette = qApp->palette(); colors.insert("window", palette.window().color().name()); colors.insert("window_text", palette.windowText().color().name()); colors.insert("base", palette.base().color().name()); colors.insert("alternate_base", palette.alternateBase().color().name()); colors.insert("text", palette.text().color().name()); colors.insert("button", palette.buttonText().color().name()); colors.insert("bright_text", palette.brightText().color().name()); colors.insert("light", palette.light().color().name()); colors.insert("midlight", palette.midlight().color().name()); colors.insert("dark", palette.dark().color().name()); colors.insert("mid", palette.mid().color().name()); colors.insert("shadow", palette.shadow().color().name()); colors.insert("highlight", palette.highlight().color().name()); colors.insert("highlight_text", palette.highlightedText().color().name()); colors.insert("link", palette.link().color().name()); colors.insert("link_visited", palette.linkVisited().color().name()); return colors; }
void KTThemeSelector::setupChooseColor() { DVHBox *hbox = new DVHBox(this, Qt::Horizontal); DVHBox *box1 = new DVHBox(hbox, Qt::Vertical); box1->boxLayout()->setMargin(10); m_general = new QGroupBox(tr("General"), box1); QGridLayout *layout1 = new QGridLayout(m_general); QStringList labels1 = QStringList() << tr("Text") << tr("Base") << tr("Foreground") << tr("Background") << tr("Button") << tr("Button Text"); QStringList names = QStringList() << "Text" << "Base" << "Foreground" << "Background" << "Button" << "ButtonText"; QPalette colorGroup = QApplication::palette(); QList<QColor> colors = QList<QColor>() << colorGroup.text ().color() << colorGroup.base().color() << colorGroup.foreground().color() << colorGroup.background().color() << colorGroup.button().color() << colorGroup.buttonText().color(); for(int i = 0; i < labels1.count(); i++) { layout1->addWidget(new QLabel(labels1[i], m_general), i, 0 ); DColorButton *button = new DColorButton(m_general); button->setObjectName(names[i]); QPalette pal = button->palette(); pal.setColor(QPalette::Button, colors[i]); button->setPalette(pal); m_generalButtonGroup.addButton(button); layout1->addWidget(button, i, 1); m_generalSection.insert(names[i], colors[i].name()); } m_effects = new QGroupBox(tr("Effects"), box1); QGridLayout *layout2 = new QGridLayout(m_effects); QStringList labels2 = QStringList() << tr("Light") << tr("Midlight") << tr("Dark") << tr("Mid"); QStringList names2 = QStringList() << "Light" << "Midlight" << "Dark" << "Mid"; colors.clear(); colors << colorGroup.light().color() << colorGroup.midlight().color() << colorGroup.dark().color() << colorGroup.mid().color(); for(int i = 0; i < labels2.count(); i++) { layout2->addWidget(new QLabel(labels2[i], m_effects), i, 0 ); DColorButton *button = new DColorButton(m_effects); button->setObjectName(names2[i]); QPalette pal = button->palette(); pal.setColor(QPalette::Button, colors[i]); button->setPalette(pal); m_effectsButtonGroup.addButton(button); layout2->addWidget(button, i, 1); m_effectsSection.insert(names2[i], colors[i].name()); } //////////// DVHBox *box2 = new DVHBox(hbox, Qt::Vertical); box2->boxLayout()->setMargin(10); m_selections = new QGroupBox(tr("Selections"), box2); QGridLayout *layout3 = new QGridLayout(m_selections); QStringList labels3 = QStringList() << tr("Highlight") << tr("Highlighted Text"); QStringList names3 = QStringList() << "Highlight" << "HighlightedText"; colors.clear(); colors << colorGroup.highlight().color() << colorGroup.highlightedText().color(); for(int i = 0; i < labels3.count(); i++) { layout3->addWidget(new QLabel(labels3[i], m_selections), i, 0 ); DColorButton *button = new DColorButton(m_selections); button->setObjectName(names3[i]); QPalette pal = button->palette(); pal.setColor(QPalette::Button, colors[i]); button->setPalette(pal); m_selectionsButtonGroup.addButton(button); layout3->addWidget(button, i, 1); m_selectionsSection.insert(names3[i], colors[i].name()); } m_textEffects = new QGroupBox(tr("Text effects"), box2); QGridLayout *layout4 = new QGridLayout(m_textEffects); QStringList labels4 = QStringList() << tr("Bright Text") << tr("Link") << tr("Link Visited"); QStringList names4 = QStringList() << "BrightText" << "Link" << "LinkVisited"; colors.clear(); colors << colorGroup.brightText().color() << colorGroup.link().color() << colorGroup.linkVisited().color(); for(int i = 0; i < labels4.count(); i++) { layout4->addWidget(new QLabel(labels4[i], m_textEffects), i, 0 ); DColorButton *button = new DColorButton(m_textEffects); button->setObjectName(names4[i]); QPalette pal = button->palette(); pal.setColor(QPalette::Button, colors[i]); button->setPalette(pal); m_textEffectsButtonGroup.addButton(button); layout4->addWidget(button, i, 1); m_textEffectsSection.insert(names4[i], colors[i].name()); } QGroupBox *schemeWidget = new QGroupBox(tr("Schema"), box2); // FIXME: add vertical layout QVBoxLayout *schemaLayout = new QVBoxLayout; m_allSchemes = new QTreeWidget; m_allSchemes->setHeaderLabels ( QStringList() << tr("Schema") << tr( "Owner" ) << tr( "Date" ) ); m_allSchemes->header()->setResizeMode(QHeaderView::Stretch); schemaLayout->addWidget(m_allSchemes); connect(m_allSchemes, SIGNAL(itemDoubleClicked (QTreeWidgetItem *, int )), this, SLOT(loadSchemaFromListView( QTreeWidgetItem *, int ))); QPushButton *saveSchemeButton = new QPushButton(tr("Save schema")); connect(saveSchemeButton, SIGNAL(clicked()), SLOT(saveSchema())); schemaLayout->addWidget(saveSchemeButton); schemeWidget->setLayout(schemaLayout); new DSeparator(this); new QLabel(tr("Style"), this); DStyleComboBox *styleComboBox = new DStyleComboBox(this); Q_UNUSED(styleComboBox); new DSeparator(this); m_useColors = new QCheckBox(tr("Use this colors"), this); connect(&m_generalButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseGeneralColor(QAbstractButton * ))); connect(&m_effectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseEffectsColor(QAbstractButton * ))); connect(&m_selectionsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseSelectionsColor(QAbstractButton * ))); connect(&m_textEffectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseTextEffectsColor(QAbstractButton * ))); }