Skip to content

Commit 149b23e

Browse files
committedMar 12, 2018
Allow updating gpl based color schemes which are set to the
default random color scheme Allows users to edit the color scheme inside QGIS and see the effects immediately on next layer load
1 parent bc449c4 commit 149b23e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎src/core/qgscolorscheme.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
***************************************************************************/
1717

1818
#include "qgscolorscheme.h"
19+
#include "qgscolorschemeregistry.h"
1920

2021
#include "qgsproject.h"
2122
#include "qgssymbollayerutils.h"
@@ -278,7 +279,19 @@ bool QgsGplColorScheme::setColors( const QgsNamedColorList &colors, const QStrin
278279
}
279280

280281
QFile destFile( destFilePath );
281-
return QgsSymbolLayerUtils::saveColorsToGpl( destFile, schemeName(), colors );
282+
if ( QgsSymbolLayerUtils::saveColorsToGpl( destFile, schemeName(), colors ) )
283+
{
284+
if ( QgsApplication::colorSchemeRegistry()->randomStyleColorScheme() == this )
285+
{
286+
// force a re-generation of the random style color list, since the color list has changed
287+
QgsApplication::colorSchemeRegistry()->setRandomStyleColorScheme( this );
288+
}
289+
return true;
290+
}
291+
else
292+
{
293+
return false;
294+
}
282295
}
283296

284297

@@ -315,6 +328,12 @@ QgsUserColorScheme::QgsUserColorScheme( const QString &filename )
315328
{
316329
mName = mFilename;
317330
}
331+
332+
// we consider this scheme writable if the user has permission, OR
333+
// if it DOESN'T already exist (since new schemes are only created when
334+
// first written to)
335+
QFileInfo sourceFileInfo( gplFilePath() );
336+
mEditable = !sourceFileInfo.exists() || sourceFileInfo.isWritable();
318337
}
319338

320339
QString QgsUserColorScheme::schemeName() const

0 commit comments

Comments
 (0)