Skip to content

Commit ff28fe9

Browse files
committed
Add set of default colors for custom color palette
1 parent e775775 commit ff28fe9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/core/qgscolorscheme.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,31 @@ QgsNamedColorList QgsCustomColorScheme::fetchColors( const QString context, cons
8686
Q_UNUSED( baseColor );
8787

8888
//fetch predefined custom colors
89+
QgsNamedColorList colorList;
8990
QSettings settings;
9091

92+
//check if settings contains custom palette
93+
if ( !settings.contains( QString( "/colors/ypalettecolors" ) ) )
94+
{
95+
//no custom palette, return default colors
96+
colorList.append( qMakePair( QColor( "#000000" ), QString() ) );
97+
colorList.append( qMakePair( QColor( "#ffffff" ), QString() ) );
98+
colorList.append( qMakePair( QColor( "#a6cee3" ), QString() ) );
99+
colorList.append( qMakePair( QColor( "#1f78b4" ), QString() ) );
100+
colorList.append( qMakePair( QColor( "#b2df8a" ), QString() ) );
101+
colorList.append( qMakePair( QColor( "#33a02c" ), QString() ) );
102+
colorList.append( qMakePair( QColor( "#fb9a99" ), QString() ) );
103+
colorList.append( qMakePair( QColor( "#e31a1c" ), QString() ) );
104+
colorList.append( qMakePair( QColor( "#fdbf6f" ), QString() ) );
105+
colorList.append( qMakePair( QColor( "#ff7f00" ), QString() ) );
106+
107+
return colorList;
108+
}
109+
91110
QList< QVariant > customColorVariants = settings.value( QString( "/colors/palettecolors" ) ).toList();
92111
QList< QVariant > customColorLabels = settings.value( QString( "/colors/palettelabels" ) ).toList();
93112

94113
//generate list from custom colors
95-
QgsNamedColorList colorList;
96114
int colorIndex = 0;
97115
for ( QList< QVariant >::iterator it = customColorVariants.begin();
98116
it != customColorVariants.end(); ++it )

0 commit comments

Comments
 (0)