Qt Utilities 6.12.2
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
paletteeditor.cpp
Go to the documentation of this file.
1#include "./paletteeditor.h"
2#include "./colorbutton.h"
3
4#include "ui_paletteeditor.h"
5
6#include <QFileDialog>
7#include <QHeaderView>
8#include <QLabel>
9#include <QMessageBox>
10#include <QMetaProperty>
11#include <QPainter>
12#include <QPushButton>
13#include <QSettings>
14#include <QStyle>
15#include <QToolButton>
16
17#include <type_traits>
18
19namespace QtUtilities {
20
21enum { BrushRole = 33 };
22
24 : QDialog(parent)
25 , m_ui(new Ui::PaletteEditor)
26 , m_currentColorGroup(QPalette::Active)
27 , m_paletteModel(new PaletteModel(this))
28 , m_modelUpdated(false)
29 , m_paletteUpdated(false)
30 , m_compute(true)
31{
32 m_ui->setupUi(this);
33 m_ui->paletteView->setModel(m_paletteModel);
34 updateStyledButton();
35 m_ui->paletteView->setModel(m_paletteModel);
36 auto *const delegate = new ColorDelegate(this);
37 m_ui->paletteView->setItemDelegate(delegate);
38 m_ui->paletteView->setEditTriggers(QAbstractItemView::AllEditTriggers);
39 m_ui->paletteView->setSelectionBehavior(QAbstractItemView::SelectRows);
40 m_ui->paletteView->setDragEnabled(true);
41 m_ui->paletteView->setDropIndicatorShown(true);
42 m_ui->paletteView->setRootIsDecorated(false);
43 m_ui->paletteView->setColumnHidden(2, true);
44 m_ui->paletteView->setColumnHidden(3, true);
45
46 auto saveButton = m_ui->buttonBox->addButton(tr("Save…"), QDialogButtonBox::ActionRole);
47 connect(saveButton, &QPushButton::clicked, this, &PaletteEditor::save);
48 auto loadButton = m_ui->buttonBox->addButton(tr("Load…"), QDialogButtonBox::ActionRole);
49 connect(loadButton, &QPushButton::clicked, this, &PaletteEditor::load);
50
51 connect(m_paletteModel, &PaletteModel::paletteChanged, this, &PaletteEditor::paletteChanged);
52 connect(m_ui->buildButton, &ColorButton::colorChanged, this, &PaletteEditor::buildPalette);
53 connect(m_ui->computeRadio, &QRadioButton::clicked, this, &PaletteEditor::handleComputeRadioClicked);
54 connect(m_ui->detailsRadio, &QRadioButton::clicked, this, &PaletteEditor::handleDetailsRadioClicked);
55}
56
58{
59}
60
61QPalette PaletteEditor::palette() const
62{
63 return m_editPalette;
64}
65
66void PaletteEditor::setPalette(const QPalette &palette)
67{
68 m_editPalette = palette;
69 const auto mask = palette.
70#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
71 resolveMask()
72#else
73 resolve()
74#endif
75 ;
76 using MaskType = std::remove_cv_t<decltype(mask)>;
77 for (int i = 0; i < static_cast<int>(QPalette::NColorRoles); ++i) {
78 if (mask & (static_cast<MaskType>(1) << static_cast<MaskType>(i))) {
79 continue;
80 }
81 m_editPalette.setBrush(
82 QPalette::Active, static_cast<QPalette::ColorRole>(i), m_parentPalette.brush(QPalette::Active, static_cast<QPalette::ColorRole>(i)));
83 m_editPalette.setBrush(
84 QPalette::Inactive, static_cast<QPalette::ColorRole>(i), m_parentPalette.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(i)));
85 m_editPalette.setBrush(
86 QPalette::Disabled, static_cast<QPalette::ColorRole>(i), m_parentPalette.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(i)));
87 }
88 m_editPalette.
89#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
90 setResolveMask(mask);
91 m_editPalette = m_editPalette.resolve(m_editPalette)
92#else
93 resolve(mask)
94#endif
95 ;
96 updateStyledButton();
97 m_paletteUpdated = true;
98 if (!m_modelUpdated) {
99 m_paletteModel->setPalette(m_editPalette, m_parentPalette);
100 }
101 m_paletteUpdated = false;
102}
103
104void PaletteEditor::setPalette(const QPalette &palette, const QPalette &parentPalette)
105{
106 m_parentPalette = parentPalette;
108}
109
110void PaletteEditor::handleComputeRadioClicked()
111{
112 if (m_compute) {
113 return;
114 }
115 m_ui->paletteView->setColumnHidden(2, true);
116 m_ui->paletteView->setColumnHidden(3, true);
117 m_compute = true;
118 m_paletteModel->setCompute(true);
119}
120
121void PaletteEditor::handleDetailsRadioClicked()
122{
123 if (!m_compute) {
124 return;
125 }
126 const int w = m_ui->paletteView->columnWidth(1);
127 m_ui->paletteView->setColumnHidden(2, false);
128 m_ui->paletteView->setColumnHidden(3, false);
129 auto *const header = m_ui->paletteView->header();
130 header->resizeSection(1, w / 3);
131 header->resizeSection(2, w / 3);
132 header->resizeSection(3, w / 3);
133 m_compute = false;
134 m_paletteModel->setCompute(false);
135}
136
137static inline QString paletteSuffix()
138{
139 return QStringLiteral("ini");
140}
141
142static inline QString paletteFilter()
143{
144 return PaletteEditor::tr("Color palette configuration (*.ini)");
145}
146
147static bool loadPalette(const QString &fileName, QPalette *pal, QString *errorMessage)
148{
149 const auto settings = QSettings(fileName, QSettings::IniFormat);
150 if (settings.status() != QSettings::NoError) {
151 *errorMessage = PaletteEditor::tr("Unable to load \"%1\".").arg(fileName);
152 return false;
153 }
154 const auto value = settings.value(QStringLiteral("palette"));
155 if (!value.isValid() || !value.canConvert<QPalette>()) {
156 *errorMessage = PaletteEditor::tr("\"%1\" does not contain a valid palette.").arg(fileName);
157 return false;
158 }
159 *pal = settings.value(QStringLiteral("palette")).value<QPalette>();
160 return true;
161}
162
163static bool savePalette(const QString &fileName, const QPalette &pal, QString *errorMessage)
164{
165 auto settings = QSettings(fileName, QSettings::IniFormat);
166 settings.setValue(QStringLiteral("palette"), QVariant(pal));
167 settings.sync();
168 if (settings.status() != QSettings::NoError) {
169 *errorMessage = PaletteEditor::tr("Unable to write \"%1\".").arg(fileName);
170 return false;
171 }
172 return true;
173}
174
175void PaletteEditor::load()
176{
177 auto dialog = QFileDialog(this, tr("Load palette"), QString(), paletteFilter());
178 dialog.setAcceptMode(QFileDialog::AcceptOpen);
179 if (dialog.exec() != QDialog::Accepted) {
180 return;
181 }
182 auto pal = QPalette();
183 auto errorMessage = QString();
184 if (loadPalette(dialog.selectedFiles().constFirst(), &pal, &errorMessage)) {
185 setPalette(pal);
186 // apply again as otherwise highlight and possibly other roles are not shown until the next restart
187 setPalette(pal, pal);
188 } else {
189 QMessageBox::warning(this, tr("Error reading palette"), errorMessage);
190 }
191}
192
193void PaletteEditor::save()
194{
195 auto dialog = QFileDialog(this, tr("Save palette"), QString(), paletteFilter());
196 dialog.setAcceptMode(QFileDialog::AcceptSave);
197 dialog.setDefaultSuffix(paletteSuffix());
198 if (dialog.exec() != QDialog::Accepted) {
199 return;
200 }
201 auto errorMessage = QString();
202 if (!savePalette(dialog.selectedFiles().constFirst(), palette(), &errorMessage)) {
203 QMessageBox::warning(this, tr("Error writing palette"), errorMessage);
204 }
205}
206
207void PaletteEditor::paletteChanged(const QPalette &palette)
208{
209 m_modelUpdated = true;
210 if (!m_paletteUpdated) {
212 }
213 m_modelUpdated = false;
214}
215
216void PaletteEditor::buildPalette()
217{
218 const QColor btn(m_ui->buildButton->color());
219 const QPalette temp(btn);
220 setPalette(temp);
221}
222
223void PaletteEditor::updateStyledButton()
224{
225 m_ui->buildButton->setColor(palette().color(QPalette::Active, QPalette::Button));
226}
227
228QPalette PaletteEditor::getPalette(QWidget *parent, const QPalette &init, const QPalette &parentPal, int *ok)
229{
230 PaletteEditor dlg(parent);
231 auto parentPalette(parentPal);
232 const auto mask = init.
233#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
234 resolveMask()
235#else
236 resolve()
237#endif
238 ;
239 using MaskType = std::remove_cv_t<decltype(mask)>;
240 for (int i = 0; i < static_cast<int>(QPalette::NColorRoles); ++i) {
241 if (mask & (static_cast<MaskType>(1) << static_cast<MaskType>(i))) {
242 continue;
243 }
244 parentPalette.setBrush(
245 QPalette::Active, static_cast<QPalette::ColorRole>(i), init.brush(QPalette::Active, static_cast<QPalette::ColorRole>(i)));
246 parentPalette.setBrush(
247 QPalette::Inactive, static_cast<QPalette::ColorRole>(i), init.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(i)));
248 parentPalette.setBrush(
249 QPalette::Disabled, static_cast<QPalette::ColorRole>(i), init.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(i)));
250 }
251 dlg.setPalette(init, parentPalette);
252
253 const int result = dlg.exec();
254 if (ok) {
255 *ok = result;
256 }
257 return result == QDialog::Accepted ? dlg.palette() : init;
258}
259
261 : QAbstractTableModel(parent)
262 , m_compute(true)
263{
264 const QMetaObject *meta = metaObject();
265 const QMetaProperty property = meta->property(meta->indexOfProperty("colorRole"));
266 const QMetaEnum enumerator = property.enumerator();
267 for (int r = QPalette::WindowText; r < QPalette::NColorRoles; ++r) {
268 m_roleNames[static_cast<QPalette::ColorRole>(r)] = QLatin1String(enumerator.key(r));
269 }
270}
271
272int PaletteModel::rowCount(const QModelIndex &) const
273{
274 return static_cast<int>(m_roleNames.count());
275}
276
277int PaletteModel::columnCount(const QModelIndex &) const
278{
279 return 4;
280}
281
282QVariant PaletteModel::data(const QModelIndex &index, int role) const
283{
284 if (!index.isValid() || index.row() < 0 || index.row() >= QPalette::NColorRoles || index.column() < 0 || index.column() >= 4) {
285 return QVariant();
286 }
287
288 if (index.column() == 0) {
289 if (role == Qt::DisplayRole) {
290 return m_roleNames[static_cast<QPalette::ColorRole>(index.row())];
291 }
292 if (role == Qt::EditRole) {
293 const auto mask = m_palette.
294#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
295 resolveMask()
296#else
297 resolve()
298#endif
299 ;
300 using MaskType = std::remove_cv_t<decltype(mask)>;
301 return mask & (static_cast<MaskType>(1) << static_cast<MaskType>(index.row()));
302 }
303 return QVariant();
304 }
305 if (role == BrushRole) {
306 return m_palette.brush(columnToGroup(index.column()), static_cast<QPalette::ColorRole>(index.row()));
307 }
308 return QVariant();
309}
310
311bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int role)
312{
313 if (!index.isValid()) {
314 return false;
315 }
316
317 if (index.column() != 0 && role == BrushRole) {
318 const QBrush br = qvariant_cast<QBrush>(value);
319 const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(index.row());
320 const QPalette::ColorGroup g = columnToGroup(index.column());
321 m_palette.setBrush(g, r, br);
322
323 QModelIndex idxBegin = PaletteModel::index(r, 0);
324 QModelIndex idxEnd = PaletteModel::index(r, 3);
325 if (m_compute) {
326 m_palette.setBrush(QPalette::Inactive, r, br);
327 switch (r) {
328 case QPalette::WindowText:
329 case QPalette::Text:
330 case QPalette::ButtonText:
331 case QPalette::Base:
332 break;
333 case QPalette::Dark:
334 m_palette.setBrush(QPalette::Disabled, QPalette::WindowText, br);
335 m_palette.setBrush(QPalette::Disabled, QPalette::Dark, br);
336 m_palette.setBrush(QPalette::Disabled, QPalette::Text, br);
337 m_palette.setBrush(QPalette::Disabled, QPalette::ButtonText, br);
338 idxBegin = PaletteModel::index(0, 0);
339 idxEnd = PaletteModel::index(static_cast<int>(m_roleNames.count()) - 1, 3);
340 break;
341 case QPalette::Window:
342 m_palette.setBrush(QPalette::Disabled, QPalette::Base, br);
343 m_palette.setBrush(QPalette::Disabled, QPalette::Window, br);
344 idxBegin = PaletteModel::index(QPalette::Base, 0);
345 break;
346 case QPalette::Highlight:
347 break;
348 default:
349 m_palette.setBrush(QPalette::Disabled, r, br);
350 break;
351 }
352 }
353 emit paletteChanged(m_palette);
354 emit dataChanged(idxBegin, idxEnd);
355 return true;
356 }
357 if (index.column() == 0 && role == Qt::EditRole) {
358 auto mask = m_palette.
359#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
360 resolveMask()
361#else
362 resolve()
363#endif
364 ;
365 const bool isMask = qvariant_cast<bool>(value);
366 const int r = index.row();
367 if (isMask) {
368 mask |= (static_cast<decltype(mask)>(1) << static_cast<decltype(mask)>(r));
369 } else {
370 m_palette.setBrush(
371 QPalette::Active, static_cast<QPalette::ColorRole>(r), m_parentPalette.brush(QPalette::Active, static_cast<QPalette::ColorRole>(r)));
372 m_palette.setBrush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r),
373 m_parentPalette.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r)));
374 m_palette.setBrush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r),
375 m_parentPalette.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r)));
376 mask &= ~static_cast<decltype(mask)>((static_cast<decltype(mask)>(1) << static_cast<decltype(mask)>(index.row())));
377 }
378 m_palette.
379#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
380 setResolveMask(mask);
381 m_palette = m_palette.resolve(m_palette)
382#else
383 resolve(mask)
384#endif
385 ;
386 emit paletteChanged(m_palette);
387 const QModelIndex idxEnd = PaletteModel::index(r, 3);
388 emit dataChanged(index, idxEnd);
389 return true;
390 }
391 return false;
392}
393
394Qt::ItemFlags PaletteModel::flags(const QModelIndex &index) const
395{
396 if (!index.isValid())
397 return Qt::ItemIsEnabled;
398 return Qt::ItemIsEditable | Qt::ItemIsEnabled;
399}
400
401QVariant PaletteModel::headerData(int section, Qt::Orientation orientation, int role) const
402{
403 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
404 if (section == 0)
405 return tr("Color Role");
406 if (section == groupToColumn(QPalette::Active))
407 return tr("Active");
408 if (section == groupToColumn(QPalette::Inactive))
409 return tr("Inactive");
410 if (section == groupToColumn(QPalette::Disabled))
411 return tr("Disabled");
412 }
413 return QVariant();
414}
415
417{
418 return m_palette;
419}
420
421void PaletteModel::setPalette(const QPalette &palette, const QPalette &parentPalette)
422{
423 m_parentPalette = parentPalette;
424 m_palette = palette;
425 const QModelIndex idxBegin = index(0, 0);
426 const QModelIndex idxEnd = index(static_cast<int>(m_roleNames.count()) - 1, 3);
427 emit dataChanged(idxBegin, idxEnd);
428}
429
430QPalette::ColorGroup PaletteModel::columnToGroup(int index) const
431{
432 if (index == 1)
433 return QPalette::Active;
434 if (index == 2)
435 return QPalette::Inactive;
436 return QPalette::Disabled;
437}
438
439int PaletteModel::groupToColumn(QPalette::ColorGroup group) const
440{
441 if (group == QPalette::Active)
442 return 1;
443 if (group == QPalette::Inactive)
444 return 2;
445 return 3;
446}
447
449 : QWidget(parent)
450 , m_button(new ColorButton(this))
451 , m_changed(false)
452{
453 auto *const layout = new QHBoxLayout(this);
454 layout->setContentsMargins(0, 0, 0, 0);
455 layout->addWidget(m_button);
456 connect(m_button, &ColorButton::colorChanged, this, &BrushEditor::brushChanged);
457 setFocusProxy(m_button);
458}
459
460void BrushEditor::setBrush(const QBrush &brush)
461{
462 m_button->setColor(brush.color());
463 m_changed = false;
464}
465
466QBrush BrushEditor::brush() const
467{
468 return QBrush(m_button->color());
469}
470
471void BrushEditor::brushChanged()
472{
473 m_changed = true;
474 emit changed(this);
475}
476
478{
479 return m_changed;
480}
481
483 : QWidget(parent)
484 , m_label(new QLabel(this))
485 , m_edited(false)
486{
487 QHBoxLayout *layout = new QHBoxLayout(this);
488 layout->setContentsMargins(0, 0, 0, 0);
489 layout->setSpacing(0);
490
491 layout->addWidget(m_label);
492 m_label->setAutoFillBackground(true);
493 m_label->setIndent(3); // same value as textMargin in QItemDelegate
494 setFocusProxy(m_label);
495
496 auto *const button = new QToolButton(this);
497 button->setToolButtonStyle(Qt::ToolButtonIconOnly);
498 button->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
499 button->setIconSize(QSize(8, 8));
500 button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
501 layout->addWidget(button);
502 connect(button, &QAbstractButton::clicked, this, &RoleEditor::emitResetProperty);
503}
504
505void RoleEditor::setLabel(const QString &label)
506{
507 m_label->setText(label);
508}
509
511{
512 QFont font;
513 if (on == true) {
514 font.setBold(on);
515 }
516 m_label->setFont(font);
517 m_edited = on;
518}
519
521{
522 return m_edited;
523}
524
525void RoleEditor::emitResetProperty()
526{
527 setEdited(false);
528 emit changed(this);
529}
530
532 : QItemDelegate(parent)
533{
534}
535
536QWidget *ColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
537{
538 if (index.column() == 0) {
539 auto *const editor = new RoleEditor(parent);
540 connect(editor, &RoleEditor::changed, this, &ColorDelegate::commitData);
541 return editor;
542 }
543
544 using BrushEditorWidgetSignal = void (BrushEditor::*)(QWidget *);
545
546 auto *const editor = new BrushEditor(parent);
547 connect(editor, static_cast<BrushEditorWidgetSignal>(&BrushEditor::changed), this, &ColorDelegate::commitData);
548 editor->setFocusPolicy(Qt::NoFocus);
549 editor->installEventFilter(const_cast<ColorDelegate *>(this));
550 return editor;
551}
552
553void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const
554{
555 if (index.column() == 0) {
556 const auto mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
557 auto *const editor = static_cast<RoleEditor *>(ed);
558 editor->setEdited(mask);
559 const auto colorName = qvariant_cast<QString>(index.model()->data(index, Qt::DisplayRole));
560 editor->setLabel(colorName);
561 } else {
562 const auto br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
563 auto *const editor = static_cast<BrushEditor *>(ed);
564 editor->setBrush(br);
565 }
566}
567
568void ColorDelegate::setModelData(QWidget *ed, QAbstractItemModel *model, const QModelIndex &index) const
569{
570 if (index.column() == 0) {
571 const auto *const editor = static_cast<RoleEditor *>(ed);
572 const auto mask = editor->edited();
573 model->setData(index, mask, Qt::EditRole);
574 } else {
575 const auto *const editor = static_cast<BrushEditor *>(ed);
576 if (editor->changed()) {
577 QBrush br = editor->brush();
578 model->setData(index, br, BrushRole);
579 }
580 }
581}
582
583void ColorDelegate::updateEditorGeometry(QWidget *ed, const QStyleOptionViewItem &option, const QModelIndex &index) const
584{
585 QItemDelegate::updateEditorGeometry(ed, option, index);
586 ed->setGeometry(ed->geometry().adjusted(0, 0, -1, -1));
587}
588
589void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const
590{
591 QStyleOptionViewItem option = opt;
592 const auto mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole));
593 if (index.column() == 0 && mask) {
594 option.font.setBold(true);
595 }
596 auto br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole));
597 if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern || br.style() == Qt::ConicalGradientPattern) {
598 painter->save();
599 painter->translate(option.rect.x(), option.rect.y());
600 painter->scale(option.rect.width(), option.rect.height());
601 QGradient gr = *(br.gradient());
602 gr.setCoordinateMode(QGradient::LogicalMode);
603 br = QBrush(gr);
604 painter->fillRect(0, 0, 1, 1, br);
605 painter->restore();
606 } else {
607 painter->save();
608 painter->setBrushOrigin(option.rect.x(), option.rect.y());
609 painter->fillRect(option.rect, br);
610 painter->restore();
611 }
612 QItemDelegate::paint(painter, option, index);
613
614 const QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
615 const QPen oldPen = painter->pen();
616 painter->setPen(QPen(color));
617
618 painter->drawLine(option.rect.right(), option.rect.y(), option.rect.right(), option.rect.bottom());
619 painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom());
620 painter->setPen(oldPen);
621}
622
623QSize ColorDelegate::sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const
624{
625 return QItemDelegate::sizeHint(opt, index) + QSize(4, 4);
626}
627
628} // namespace QtUtilities
The BrushEditor class is used by PaletteEditor.
void setBrush(const QBrush &brush)
BrushEditor(QWidget *parent=nullptr)
The ColorButton class is used by PaletteEditor.
Definition colorbutton.h:15
void setColor(const QColor &color)
void colorChanged(const QColor &color)
The ColorDelegate class is used by PaletteEditor.
void setModelData(QWidget *ed, QAbstractItemModel *model, const QModelIndex &index) const override
void updateEditorGeometry(QWidget *ed, const QStyleOptionViewItem &option, const QModelIndex &index) const override
void setEditorData(QWidget *ed, const QModelIndex &index) const override
void paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const override
QSize sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const override
ColorDelegate(QObject *parent=nullptr)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
The PaletteEditor class provides a dialog to customize a QPalette.
static QPalette getPalette(QWidget *parent, const QPalette &init=QPalette(), const QPalette &parentPal=QPalette(), int *result=nullptr)
PaletteEditor(QWidget *parent)
void setPalette(const QPalette &palette)
The PaletteModel class is used by PaletteEditor.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QVariant data(const QModelIndex &index, int role) const override
PaletteModel(QObject *parent=nullptr)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
void setPalette(const QPalette &palette, const QPalette &parentPalette)
void paletteChanged(const QPalette &palette)
The RoleEditor class is used by PaletteEditor.
void changed(QWidget *widget)
RoleEditor(QWidget *parent=nullptr)
void setLabel(const QString &label)