Skip to content
Permalink
Browse files

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
  • Loading branch information
nyalldawson committed Feb 5, 2018
1 parent bc449c4 commit 149b23e08bd4aa28cbaefe4d50feaedf0c2bedc2
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/core/qgscolorscheme.cpp
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscolorscheme.h"
#include "qgscolorschemeregistry.h"

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

QFile destFile( destFilePath );
return QgsSymbolLayerUtils::saveColorsToGpl( destFile, schemeName(), colors );
if ( QgsSymbolLayerUtils::saveColorsToGpl( destFile, schemeName(), colors ) )
{
if ( QgsApplication::colorSchemeRegistry()->randomStyleColorScheme() == this )
{
// force a re-generation of the random style color list, since the color list has changed
QgsApplication::colorSchemeRegistry()->setRandomStyleColorScheme( this );
}
return true;
}
else
{
return false;
}
}


@@ -315,6 +328,12 @@ QgsUserColorScheme::QgsUserColorScheme( const QString &filename )
{
mName = mFilename;
}

// we consider this scheme writable if the user has permission, OR
// if it DOESN'T already exist (since new schemes are only created when
// first written to)
QFileInfo sourceFileInfo( gplFilePath() );
mEditable = !sourceFileInfo.exists() || sourceFileInfo.isWritable();
}

QString QgsUserColorScheme::schemeName() const

0 comments on commit 149b23e

Please sign in to comment.
You can’t perform that action at this time.