Qt Utilities: paletteeditor/paletteeditor.cpp Source File

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