8#include "ui_paletteeditor.h"
9#include <QtWidgets/qstyleditemdelegate.h>
18class QDesignerFormEditorInterface;
28 static QPalette getPalette(QDesignerFormEditorInterface *core,
29 QWidget* parent,
const QPalette &init = QPalette(),
30 const QPalette &parentPal = QPalette(),
int *result =
nullptr);
34 void setPalette(
const QPalette &palette,
const QPalette &parentPalette);
39 void activeRadioClicked();
40 void inactiveRadioClicked();
41 void disabledRadioClicked();
42 void computeRadioClicked();
43 void detailsRadioClicked();
45 void paletteChanged(
const QPalette &palette);
46 void viewContextMenuRequested(QPoint pos);
53 PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent);
56 void updatePreviewPalette();
57 void updateStyledButton();
59 QPalette::ColorGroup currentColorGroup()
const
60 {
return m_currentColorGroup; }
63 QPalette m_editPalette;
64 QPalette m_parentPalette;
66 QDesignerFormEditorInterface *m_core;
67 QAction *m_lighterAction =
nullptr;
68 QAction *m_darkerAction =
nullptr;
69 QAction *m_copyColorAction =
nullptr;
70 QMenu *m_contextMenu =
nullptr;
72 bool m_modelUpdated =
false;
73 bool m_paletteUpdated =
false;
74 bool m_compute =
true;
81 Q_PROPERTY(QPalette::ColorRole colorRole READ colorRole)
85 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
86 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
87 QVariant data(
const QModelIndex &index,
int role)
const override;
88 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
94 void setPalette(
const QPalette &palette,
const QPalette &parentPalette);
109 QPalette::ColorRole role;
112 QPalette::ColorGroup columnToGroup(
int index)
const;
113 int groupToColumn(QPalette::ColorGroup group)
const;
114 QPalette::ColorRole roleAt(
int row)
const {
return m_roleEntries.at(row).role; }
115 int rowOf(QPalette::ColorRole role)
const;
118 QPalette m_parentPalette;
119 QList<RoleEntry> m_roleEntries;
120 bool m_compute =
true;
138 bool m_changed =
false;
139 QDesignerFormEditorInterface *m_core;
148 void setLabel(
const QString &label);
157 bool m_edited =
false;
167 QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
168 const QModelIndex &index)
const override;
170 void setEditorData(QWidget *ed,
const QModelIndex &index)
const override;
171 void setModelData(QWidget *ed, QAbstractItemModel *model,
172 const QModelIndex &index)
const override;
174 void updateEditorGeometry(QWidget *ed,
const QStyleOptionViewItem &option,
175 const QModelIndex &index)
const override;
177 void paint(QPainter *painter,
const QStyleOptionViewItem &opt,
178 const QModelIndex &index)
const override;
179 QSize sizeHint(
const QStyleOptionViewItem &opt,
const QModelIndex &index)
const override;
181 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)
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)