42 Q_UNUSED( baseColor );
64 Q_UNUSED( baseColor );
68 QList< QVariant > recentColorVariants = settings.value( QString(
"/colors/recent" ) ).toList();
72 foreach ( QVariant color, recentColorVariants )
98 Q_UNUSED( baseColor );
105 if ( !settings.contains( QString(
"/colors/palettecolors" ) ) )
108 colorList.append( qMakePair( QColor(
"#000000" ), QString() ) );
109 colorList.append( qMakePair( QColor(
"#ffffff" ), QString() ) );
110 colorList.append( qMakePair( QColor(
"#a6cee3" ), QString() ) );
111 colorList.append( qMakePair( QColor(
"#1f78b4" ), QString() ) );
112 colorList.append( qMakePair( QColor(
"#b2df8a" ), QString() ) );
113 colorList.append( qMakePair( QColor(
"#33a02c" ), QString() ) );
114 colorList.append( qMakePair( QColor(
"#fb9a99" ), QString() ) );
115 colorList.append( qMakePair( QColor(
"#e31a1c" ), QString() ) );
116 colorList.append( qMakePair( QColor(
"#fdbf6f" ), QString() ) );
117 colorList.append( qMakePair( QColor(
"#ff7f00" ), QString() ) );
122 QList< QVariant > customColorVariants = settings.value( QString(
"/colors/palettecolors" ) ).toList();
123 QList< QVariant > customColorLabels = settings.value( QString(
"/colors/palettelabels" ) ).toList();
127 for ( QList< QVariant >::iterator it = customColorVariants.begin();
128 it != customColorVariants.end(); ++it )
130 QColor color = ( *it ).value<QColor>();
132 if ( customColorLabels.length() > colorIndex )
134 label = customColorLabels.at( colorIndex ).toString();
137 colorList.append( qMakePair( color, label ) );
147 Q_UNUSED( baseColor );
151 QList< QVariant > customColors;
152 QList< QVariant > customColorLabels;
154 QgsNamedColorList::const_iterator colorIt = colors.constBegin();
155 for ( ; colorIt != colors.constEnd(); ++colorIt )
157 QVariant color = ( *colorIt ).first;
158 QVariant label = ( *colorIt ).second;
159 customColors.append( color );
160 customColorLabels.append( label );
162 settings.setValue( QString(
"/colors/palettecolors" ), customColors );
163 settings.setValue( QString(
"/colors/palettelabels" ), customColorLabels );
186 Q_UNUSED( baseColor );
195 for ( QStringList::iterator it = colorStrings.begin();
196 it != colorStrings.end(); ++it )
200 if ( colorLabels.length() > colorIndex )
202 label = colorLabels.at( colorIndex );
205 colorList.append( qMakePair( color, label ) );
215 Q_UNUSED( baseColor );
218 QStringList customColors;
219 QStringList customColorLabels;
221 QgsNamedColorList::const_iterator colorIt = colors.constBegin();
222 for ( ; colorIt != colors.constEnd(); ++colorIt )
225 QString label = ( *colorIt ).second;
226 customColors.append( color );
227 customColorLabels.append( label );
258 Q_UNUSED( baseColor );
261 if ( sourceFilePath.isEmpty() )
269 QFile sourceFile( sourceFilePath );
276 Q_UNUSED( baseColor );
279 if ( destFilePath.isEmpty() )
284 QFile destFile( destFilePath );
295 , mFilename( filename )
300 if ( sourceFile.open( QIODevice::ReadOnly ) )
302 QTextStream in( &sourceFile );
306 while ( !in.atEnd() && !line.startsWith(
"Name:" ) )
308 line = in.readLine();
312 QRegExp rx(
"Name:\\s*(\\S.*)$" );
313 if ( rx.indexIn( line ) != -1 )
319 if (
mName.isEmpty() )
343 if ( filePath.isEmpty() )
349 return QFile::remove( filePath );
357 if ( !localDir.mkpath( palettesDir ) )
362 return QDir( palettesDir ).filePath(
mFilename );
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
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.
virtual ~QgsRecentColorScheme()
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.
virtual QgsColorScheme * clone() const override
Clones a color scheme.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
static QColor decodeColor(QString str)
static QString colorToName(const QColor &color)
Returns a friendly display name for a color.
static const QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
QgsColorScheme * clone() const override
Clones a color scheme.
QgsColorScheme * clone() const override
Clones a color scheme.
static QString encodeColor(QColor color)
virtual ~QgsCustomColorScheme()
bool writeEntry(const QString &scope, const QString &key, bool value)
QStringList readListEntry(const QString &scope, const QString &key, QStringList def=QStringList(), bool *ok=0) const
key value accessors
static bool saveColorsToGpl(QFile &file, const QString paletteName, QgsNamedColorList colors)
Exports colors to a gpl GIMP palette file.
static QgsNamedColorList importColorsFromGpl(QFile &file, bool &ok, QString &name)
Imports colors from a gpl GIMP palette file.
QgsUserColorScheme(const QString &filename)
Constructs a new user color scheme, using a specified gpl palette file.
virtual bool setColors(const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor()) override
Sets the colors for the scheme.
virtual ~QgsProjectColorScheme()
virtual QString gplFilePath()=0
Returns the file path for the associated gpl palette file.
virtual QString gplFilePath() override
Returns the file path for the associated gpl palette file.
QgsColorScheme * clone() const override
Clones a color scheme.
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
virtual QString schemeName() const override
Gets the name for the 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()
access to canonical QgsProject instance
virtual ~QgsGplColorScheme()
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.
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.