Skip to content

Commit

Permalink
Allow updating gpl based color schemes which are set to the
Browse files Browse the repository at this point in the history
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 Mar 12, 2018
1 parent bc449c4 commit 149b23e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/core/qgscolorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

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

#include "qgsproject.h"
#include "qgssymbollayerutils.h"
Expand Down Expand Up @@ -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;
}
}


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 149b23e

Please sign in to comment.