22 #include <QFileInfoList>    28   qDeleteAll( mColorSchemeList );
    29   mColorSchemeList.clear();
    38   QList< QgsColorScheme * >::iterator it = schemeList.begin();
    39   for ( ; it != schemeList.end(); ++it )
    57   if ( QFileInfo::exists( stylePalette ) )
    70   if ( !localDir.mkpath( palettesDir ) )
    75   QFileInfoList fileInfoList = QDir( palettesDir ).entryInfoList( QStringList( QStringLiteral( 
"*.gpl" ) ), QDir::Files );
    76   QFileInfoList::const_iterator infoIt = fileInfoList.constBegin();
    77   for ( ; infoIt != fileInfoList.constEnd(); ++infoIt )
    85   mColorSchemeList.append( scheme );
    90   QList< QgsColorScheme * > allSchemes;
    91   QList<QgsColorScheme *>::const_iterator schemeIt;
    92   for ( schemeIt = mColorSchemeList.constBegin(); schemeIt != mColorSchemeList.constEnd(); ++schemeIt )
    94     allSchemes.append( ( *schemeIt ) );
   101   QList< QgsColorScheme * > matchingSchemes;
   102   QList<QgsColorScheme *>::const_iterator schemeIt;
   103   for ( schemeIt = mColorSchemeList.constBegin(); schemeIt != mColorSchemeList.constEnd(); ++schemeIt )
   105     if ( ( *schemeIt )->flags().testFlag( flag ) )
   107       matchingSchemes.append( ( *schemeIt ) );
   110   return matchingSchemes;
   115   mRandomStyleColorScheme = scheme;
   120     if ( mRandomStyleColors.count() > 0 )
   122       std::random_device rd;
   123       std::mt19937 mt( rd() );
   124       std::uniform_int_distribution<int> colorDist( 0, mRandomStyleColors.count() - 1 );
   125       mNextRandomStyleColorIndex = colorDist( mt );
   126       std::uniform_int_distribution<int> colorDir( 0, 1 );
   127       mNextRandomStyleColorDirection = colorDir( mt ) == 0 ? -1 : 1;
   132     mRandomStyleColors.clear();
   138   return mRandomStyleColorScheme;
   143   if ( mRandomStyleColors.empty() )
   148     std::random_device rd;
   149     std::mt19937 mt( rd() );
   150     std::uniform_int_distribution<int> hueDist( 0, 359 );
   151     std::uniform_int_distribution<int> satDist( 64, 255 );
   152     std::uniform_int_distribution<int> valueDist( 128, 255 );
   153     return QColor::fromHsv( hueDist( mt ), satDist( mt ), valueDist( mt ) );
   157     static QMutex sMutex;
   158     QMutexLocker locker( &sMutex );
   159     QColor res = mRandomStyleColors.at( mNextRandomStyleColorIndex ).first;
   160     mNextRandomStyleColorIndex += mNextRandomStyleColorDirection;
   161     if ( mNextRandomStyleColorIndex < 0 )
   162       mNextRandomStyleColorIndex = mRandomStyleColors.count() - 1;
   163     if ( mNextRandomStyleColorIndex >= mRandomStyleColors.count() )
   164       mNextRandomStyleColorIndex = 0;
   171   if ( mRandomStyleColorScheme == scheme )
   173     mRandomStyleColorScheme = 
nullptr;
   174     mRandomStyleColors.clear();
   177   if ( mColorSchemeList.indexOf( scheme ) != -1 )
   179     mColorSchemeList.removeAll( scheme );
 void populateFromInstance()
Adds all color schemes from the global instance to this color scheme. 
 
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 ...
 
void addDefaultSchemes()
Adds all default color schemes to this color scheme. 
 
A color scheme which contains project specific colors set through project properties dialog...
 
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir. 
 
virtual ~QgsColorSchemeRegistry()
 
Abstract base class for color schemes. 
 
void initStyleScheme()
Initializes the default random style color scheme for the user. 
 
bool removeColorScheme(QgsColorScheme *scheme)
Removes all matching color schemes from the registry. 
 
QgsColorScheme * randomStyleColorScheme()
Returns the color scheme used when fetching random colors to use for symbol styles. 
 
QList< QgsColorScheme * > schemes() const
Returns all color schemes in the registry. 
 
void addUserSchemes()
Creates schemes for all gpl palettes in the user's palettes folder. 
 
void addColorScheme(QgsColorScheme *scheme)
Adds a color scheme to the registry. 
 
static QString pkgDataPath()
Returns the common root path of all application data directories. 
 
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g. 
 
A color scheme which contains the most recently used colors. 
 
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes. ...
 
void setRandomStyleColorScheme(QgsColorScheme *scheme)
Sets the color scheme to use when fetching random colors to use for symbol styles. 
 
virtual QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor())=0
Gets a list of colors from the scheme. 
 
SchemeFlag
Flags for controlling behavior of color scheme.