diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/colortable.cpp | 31 | ||||
| -rw-r--r-- | src/colortable.h | 11 |
2 files changed, 35 insertions, 7 deletions
diff --git a/src/colortable.cpp b/src/colortable.cpp index 7546abe5..61c5ee5f 100644 --- a/src/colortable.cpp +++ b/src/colortable.cpp @@ -10,6 +10,8 @@ void paintBackground( const QModelIndex& index); +// delegate for the sample text column; paints the background color +// class ColoredBackgroundDelegate : public QStyledItemDelegate { public: @@ -26,6 +28,9 @@ public: QStyleOptionViewItem itemOption(option); initStyleOption(&itemOption, index); + + // paint the default stuff like text, but override the state to avoid + // destroying the background for selected items, etc. itemOption.state = QStyle::State_Enabled; QStyledItemDelegate::paint(p, itemOption, index); @@ -36,6 +41,8 @@ private: }; +// delegate for the icons column; paints the background and icons +// class FakeModFlagIconDelegate : public ModFlagIconDelegate { public: @@ -79,6 +86,8 @@ private: }; +// item used in the first column of the table +// class ColorItem : public QTableWidgetItem { public: @@ -93,16 +102,22 @@ public: set(get()); } + // color caption + // const QString& caption() const { return m_caption; } + // the current color + // QColor get() const { return m_temp; } + // sets the current color, commit() must be called to save it + // bool set(const QColor& c) { if (m_temp != c) { @@ -113,14 +128,18 @@ public: return false; } - void commit() + // resets the current color, commit() must be called to save it + // + bool reset() { - m_commit(m_temp); + return set(m_default); } - bool reset() + // saves the current color + // + void commit() { - return set(m_default); + m_commit(m_temp); } private: @@ -246,9 +265,7 @@ void ColorTable::addColor( const auto r = rowCount(); setRowCount(r + 1); - auto* item = new ColorItem(text, defaultColor, get, commit); - - setItem(r, 0, item); + setItem(r, 0, new ColorItem(text, defaultColor, get, commit)); setItem(r, 1, new QTableWidgetItem("Text")); setItem(r, 2, new QTableWidgetItem); diff --git a/src/colortable.h b/src/colortable.h index c2b64a4d..039b6024 100644 --- a/src/colortable.h +++ b/src/colortable.h @@ -5,13 +5,24 @@ class Settings; +// a QTableWidget to view and modify color settings +// class ColorTable : public QTableWidget { public: ColorTable(QWidget* parent=nullptr); + // adds colors to the table from the settings + // void load(Settings& s); + + // resets the colors to their default values; commitColors() must be called + // to save them + // void resetColors(); + + // commits any changes + // void commitColors(); private: |
