File tree 5 files changed +31
-2
lines changed
5 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ Adds all default color schemes to this color scheme.
50
50
.. seealso:: :py:func:`addColorScheme`
51
51
52
52
.. seealso:: :py:func:`addUserSchemes`
53
+ %End
54
+
55
+ void initStyleScheme();
56
+ %Docstring
57
+ Initializes the default random style color scheme for the user.
58
+
59
+ .. versionadded:: 3.2
53
60
%End
54
61
55
62
void addUserSchemes();
Original file line number Diff line number Diff line change @@ -271,6 +271,9 @@ void QgsApplication::init( QString profileFolder )
271
271
// so we read actual value in main.cpp
272
272
ABISYM ( mMaxThreads ) = -1 ;
273
273
274
+ colorSchemeRegistry ()->addDefaultSchemes ();
275
+ colorSchemeRegistry ()->initStyleScheme ();
276
+
274
277
ABISYM ( mInitialized ) = true ;
275
278
}
276
279
@@ -1718,7 +1721,6 @@ QgsApplication::ApplicationMembers::ApplicationMembers()
1718
1721
mFieldFormatterRegistry = new QgsFieldFormatterRegistry ();
1719
1722
mSvgCache = new QgsSvgCache ();
1720
1723
mColorSchemeRegistry = new QgsColorSchemeRegistry ();
1721
- mColorSchemeRegistry ->addDefaultSchemes ();
1722
1724
mPaintEffectRegistry = new QgsPaintEffectRegistry ();
1723
1725
mSymbolLayerRegistry = new QgsSymbolLayerRegistry ();
1724
1726
mRendererRegistry = new QgsRendererRegistry ();
Original file line number Diff line number Diff line change @@ -51,6 +51,17 @@ void QgsColorSchemeRegistry::addDefaultSchemes()
51
51
addUserSchemes ();
52
52
}
53
53
54
+ void QgsColorSchemeRegistry::initStyleScheme ()
55
+ {
56
+ QString stylePalette = QgsApplication::pkgDataPath () + QStringLiteral ( " /resources/new_layer_colors.gpl" );
57
+ if ( QFileInfo::exists ( stylePalette ) )
58
+ {
59
+ QgsUserColorScheme *scheme = new QgsUserColorScheme ( stylePalette );
60
+ addColorScheme ( scheme );
61
+ setRandomStyleColorScheme ( scheme );
62
+ }
63
+ }
64
+
54
65
void QgsColorSchemeRegistry::addUserSchemes ()
55
66
{
56
67
QString palettesDir = QgsApplication::qgisSettingsDirPath () + " /palettes" ;
Original file line number Diff line number Diff line change @@ -58,6 +58,12 @@ class CORE_EXPORT QgsColorSchemeRegistry
58
58
*/
59
59
void addDefaultSchemes ();
60
60
61
+ /* *
62
+ * Initializes the default random style color scheme for the user.
63
+ * \since QGIS 3.2
64
+ */
65
+ void initStyleScheme ();
66
+
61
67
/* *
62
68
* Creates schemes for all gpl palettes in the user's palettes folder.
63
69
* \see populateFromInstance
Original file line number Diff line number Diff line change @@ -104,7 +104,8 @@ class TestQgsColorSchemeRegistry : public QObject
104
104
105
105
void TestQgsColorSchemeRegistry::initTestCase ()
106
106
{
107
-
107
+ QgsApplication::init ();
108
+ QgsApplication::initQgis ();
108
109
}
109
110
110
111
void TestQgsColorSchemeRegistry::cleanupTestCase ()
@@ -249,6 +250,8 @@ void TestQgsColorSchemeRegistry::fetchRandomStyleColor()
249
250
QVERIFY ( registry->fetchRandomStyleColor ().isValid () );
250
251
}
251
252
253
+ // we expect the default application color scheme registry to have a randomStyleColorScheme set
254
+ QVERIFY ( QgsApplication::colorSchemeRegistry ()->randomStyleColorScheme () );
252
255
}
253
256
254
257
QGSTEST_MAIN ( TestQgsColorSchemeRegistry )
You can’t perform that action at this time.
0 commit comments