42 Q_UNUSED( baseColor );
64 Q_UNUSED( baseColor );
72 Q_FOREACH (
const QVariant& color, recentColorVariants )
92 QColor opaqueColor = color;
99 for (
int colorIdx = recentColorVariants.
length() - 1; colorIdx >= 0; --colorIdx )
101 if (( recentColorVariants.
at( colorIdx ).value<
QColor>() ).name() == opaqueColor.
name() )
103 recentColorVariants.
removeAt( colorIdx );
109 recentColorVariants.
prepend( colorVariant );
112 while ( recentColorVariants.
count() > 20 )
134 Q_UNUSED( baseColor );
164 it != customColorVariants.
end(); ++it )
168 if ( customColorLabels.
length() > colorIndex )
170 label = customColorLabels.
at( colorIndex ).toString();
173 colorList.
append( qMakePair( color, label ) );
183 Q_UNUSED( baseColor );
191 for ( ; colorIt != colors.
constEnd(); ++colorIt )
193 QVariant color = ( *colorIt ).first;
194 QVariant label = ( *colorIt ).second;
195 customColors.
append( color );
196 customColorLabels.
append( label );
199 settings.
setValue(
QString(
"/colors/palettelabels" ), customColorLabels );
222 Q_UNUSED( baseColor );
232 it != colorStrings.
end(); ++it )
236 if ( colorLabels.
length() > colorIndex )
238 label = colorLabels.
at( colorIndex );
241 colorList.
append( qMakePair( color, label ) );
251 Q_UNUSED( baseColor );
258 for ( ; colorIt != colors.
constEnd(); ++colorIt )
261 QString label = ( *colorIt ).second;
262 customColors.
append( color );
263 customColorLabels.
append( label );
294 Q_UNUSED( baseColor );
297 if ( sourceFilePath.
isEmpty() )
305 QFile sourceFile( sourceFilePath );
312 Q_UNUSED( baseColor );
320 QFile destFile( destFilePath );
331 , mFilename( filename )
336 if ( sourceFile.
open( QIODevice::ReadOnly ) )
348 QRegExp rx(
"Name:\\s*(\\S.*)$" );
349 if ( rx.
indexIn( line ) != -1 )
410 showInMenuSchemes <<
mName;
417 s.
setValue(
"/colors/showInMenuList", showInMenuSchemes );
425 if ( !localDir.
mkpath( palettesDir ) )
A color scheme which contains custom colors set through QGIS app options dialog.
A color scheme which stores its colors in a gpl palette file within the "palettes" subfolder off the ...
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
QString cap(int nth) const
virtual ~QgsColorScheme()
A color scheme which contains project specific colors set through project properties dialog...
bool erase()
Erases the associated gpl palette file from the users "palettes" folder.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
QgsCustomColorScheme * clone() const override
Clones a color scheme.
QString readLine(qint64 maxlen)
virtual ~QgsRecentColorScheme()
virtual SchemeFlags flags() const
Returns the current flags for the color scheme.
QList< QVariant > toList() const
Abstract base class for color schemes.
virtual bool setColors(const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor()) override
Sets the colors for the scheme.
static QString encodeColor(const QColor &color)
const T & at(int i) const
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QString filePath(const QString &fileName) const
QgsRecentColorScheme * clone() const override
Clones a color scheme.
virtual QgsColorScheme::SchemeFlags flags() const override
Returns the current flags for the color scheme.
static QString colorToName(const QColor &color)
Returns a friendly display name for a color.
QgsProjectColorScheme * clone() const override
Clones a color scheme.
void setValue(const QString &key, const QVariant &value)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
virtual ~QgsCustomColorScheme()
bool writeEntry(const QString &scope, const QString &key, bool value)
int count(const T &value) const
void append(const T &value)
void setShowSchemeInMenu(bool show)
Sets whether a this scheme should be shown in color button menus.
static QgsNamedColorList importColorsFromGpl(QFile &file, bool &ok, QString &name)
Imports colors from a gpl GIMP palette file.
bool contains(const QString &key) const
int removeAll(const T &value)
QgsUserColorScheme(const QString &filename)
Constructs a new user color scheme, using a specified gpl palette file.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual bool setColors(const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor()) override
Sets the colors for the scheme.
QStringList readListEntry(const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=nullptr) const
Key value accessors.
virtual ~QgsProjectColorScheme()
virtual QString gplFilePath()=0
Returns the file path for the associated gpl palette file.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static void addRecentColor(const QColor &color)
Adds a color to the list of recent colors.
virtual QString gplFilePath() override
Returns the file path for the associated gpl palette file.
A color scheme which contains the most recently used colors.
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
QStringList toStringList() const
virtual QString schemeName() const override
Gets the name for the color scheme.
virtual QgsUserColorScheme * clone() const override
Clones a color scheme.
virtual QString schemeName() const =0
Gets the name for the color scheme.
virtual bool setColors(const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor()) override
Sets the colors for the scheme.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void prepend(const T &value)
static QColor decodeColor(const QString &str)
const_iterator constEnd() const
virtual ~QgsGplColorScheme()
const_iterator constBegin() const
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
static bool saveColorsToGpl(QFile &file, const QString &paletteName, const QgsNamedColorList &colors)
Exports colors to a gpl GIMP palette file.
virtual ~QgsUserColorScheme()
virtual bool setColors(const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor())
Sets the colors for the scheme.
A color scheme which stores its colors in a gpl palette file.
bool mkpath(const QString &dirPath) const