7#include "ui_paletteeditor.h"
8#include <QtWidgets/qitemdelegate.h>
17class QDesignerFormEditorInterface;
27 static QPalette getPalette(QDesignerFormEditorInterface *core,
28 QWidget* parent,
const QPalette &init = QPalette(),
29 const QPalette &parentPal = QPalette(),
int *result =
nullptr);
33 void setPalette(
const QPalette &palette,
const QPalette &parentPalette);
38 void activeRadioClicked();
39 void inactiveRadioClicked();
40 void disabledRadioClicked();
41 void computeRadioClicked();
42 void detailsRadioClicked();
44 void paletteChanged(
const QPalette &palette);
45 void viewContextMenuRequested(QPoint pos);
52 PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent);
55 void updatePreviewPalette();
56 void updateStyledButton();
58 QPalette::ColorGroup currentColorGroup()
const
59 {
return m_currentColorGroup; }
62 QPalette m_editPalette;
63 QPalette m_parentPalette;
65 QDesignerFormEditorInterface *m_core;
66 QAction *m_lighterAction =
nullptr;
67 QAction *m_darkerAction =
nullptr;
68 QAction *m_copyColorAction =
nullptr;
69 QMenu *m_contextMenu =
nullptr;
71 bool m_modelUpdated =
false;
72 bool m_paletteUpdated =
false;
73 bool m_compute =
true;
80 Q_PROPERTY(QPalette::ColorRole colorRole READ colorRole)
84 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
85 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
86 QVariant data(
const QModelIndex &index,
int role)
const override;
87 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
93 void setPalette(
const QPalette &palette,
const QPalette &parentPalette);
108 QPalette::ColorRole role;
111 QPalette::ColorGroup columnToGroup(
int index)
const;
112 int groupToColumn(QPalette::ColorGroup group)
const;
113 QPalette::ColorRole roleAt(
int row)
const {
return m_roleEntries.at(row).role; }
114 int rowOf(QPalette::ColorRole role)
const;
117 QPalette m_parentPalette;
118 QList<RoleEntry> m_roleEntries;
119 bool m_compute =
true;
137 bool m_changed =
false;
138 QDesignerFormEditorInterface *m_core;
147 void setLabel(
const QString &label);
156 bool m_edited =
false;
166 QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
167 const QModelIndex &index)
const override;
169 void setEditorData(QWidget *ed,
const QModelIndex &index)
const override;
170 void setModelData(QWidget *ed, QAbstractItemModel *model,
171 const QModelIndex &index)
const override;
173 void updateEditorGeometry(QWidget *ed,
const QStyleOptionViewItem &option,
174 const QModelIndex &index)
const override;
176 void paint(QPainter *painter,
const QStyleOptionViewItem &opt,
177 const QModelIndex &index)
const override;
178 QSize sizeHint(
const QStyleOptionViewItem &opt,
const QModelIndex &index)
const override;
180 QDesignerFormEditorInterface *m_core;
void setBrush(const QBrush &brush)
QSize sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
void paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
void setPalette(const QPalette &palette)
void setPalette(const QPalette &palette, const QPalette &parentPalette)
QBrush brushAt(const QModelIndex &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the data for the given role and section in the header with the specified orientation.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns for the children of the given parent.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
QPalette getPalette() const
QPalette::ColorRole colorRole() const
quint64 rowMask(const QModelIndex &index) const
QVariant data(const QModelIndex &index, int role) const override
Returns the data stored under the given role for the item referred to by the index.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets the role data for the item at index to value.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
void setPalette(const QPalette &palette, const QPalette &parentPalette)
void setLabel(const QString &label)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QString paletteFilter()
static bool savePalette(const QString &fileName, const QPalette &pal, QString *errorMessage)
static QString msgCannotReadPalette(const QString &fileName, const QXmlStreamReader &reader)
static QString msgCannotReadPalette(const QString &fileName, const QXmlStreamReader &reader, const QString &why)
static bool loadPalette(const QString &fileName, QPalette *pal, QString *errorMessage)