@@ -40,6 +40,16 @@ class CORE_EXPORT QgsColorScheme
4040{
4141 public:
4242
43+ /* * Flags for controlling behaviour of color scheme
44+ */
45+ enum SchemeFlag
46+ {
47+ ShowInColorDialog = 0x01 , /* < show scheme in color picker dialog */
48+ ShowInColorButtonMenu = 0x02 , /* < show scheme in color button drop down menu */
49+ ShowInAllContexts = ShowInColorDialog | ShowInColorButtonMenu /* < show scheme in all contexts */
50+ };
51+ Q_DECLARE_FLAGS ( SchemeFlags, SchemeFlag )
52+
4353 QgsColorScheme ();
4454
4555 virtual ~QgsColorScheme ();
@@ -49,6 +59,11 @@ class CORE_EXPORT QgsColorScheme
4959 */
5060 virtual QString schemeName () const = 0;
5161
62+ /* *Returns the current flags for the color scheme.
63+ * @returns current flags
64+ */
65+ virtual SchemeFlags flags () const { return ShowInColorDialog; }
66+
5267 /* *Gets a list of colors from the scheme. The colors can optionally
5368 * be generated using the supplied context and base color.
5469 * @param context string specifiying an optional context for the returned
@@ -83,6 +98,8 @@ class CORE_EXPORT QgsColorScheme
8398 virtual QgsColorScheme* clone () const = 0;
8499};
85100
101+ Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsColorScheme::SchemeFlags )
102+
86103/* * \ingroup core
87104 * \class QgsGplColorScheme
88105 * \brief A color scheme which stores its colors in a gpl palette file.
@@ -158,6 +175,8 @@ class CORE_EXPORT QgsRecentColorScheme : public QgsColorScheme
158175
159176 virtual QString schemeName () const { return QT_TR_NOOP ( " Recent colors" ); }
160177
178+ virtual SchemeFlags flags () const { return ShowInAllContexts; }
179+
161180 virtual QgsNamedColorList fetchColors ( const QString context = QString(),
162181 const QColor baseColor = QColor() );
163182
@@ -179,6 +198,8 @@ class CORE_EXPORT QgsCustomColorScheme : public QgsColorScheme
179198
180199 virtual QString schemeName () const { return QT_TR_NOOP ( " Standard colors" ); }
181200
201+ virtual SchemeFlags flags () const { return ShowInAllContexts; }
202+
182203 virtual QgsNamedColorList fetchColors ( const QString context = QString(),
183204 const QColor baseColor = QColor() );
184205
@@ -204,6 +225,8 @@ class CORE_EXPORT QgsProjectColorScheme : public QgsColorScheme
204225
205226 virtual QString schemeName () const { return QT_TR_NOOP ( " Project colors" ); }
206227
228+ virtual SchemeFlags flags () const { return ShowInAllContexts; }
229+
207230 virtual QgsNamedColorList fetchColors ( const QString context = QString(),
208231 const QColor baseColor = QColor() );
209232
0 commit comments