Skip to content

Commit

Permalink
migrate r/g/b/a setting to color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 16, 2023
1 parent 5be8887 commit 4fe0cbd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 31 deletions.
10 changes: 2 additions & 8 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -1022,10 +1022,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mLineColorToolButton->setContext( QStringLiteral( "gui" ) );
mLineColorToolButton->setDefaultColor( QColor( 255, 0, 0, 200 ) );

mFillColorToolButton->setColor( QColor( QgsSettingsRegistryCore::settingsDigitizingFillColorRed->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorGreen->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorBlue->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorAlpha->value() ) );
mFillColorToolButton->setColor( QgsSettingsRegistryCore::settingsDigitizingFillColor->value() );
mFillColorToolButton->setAllowOpacity( true );
mFillColorToolButton->setContext( QStringLiteral( "gui" ) );
mFillColorToolButton->setDefaultColor( QColor( 255, 0, 0, 30 ) );
Expand Down Expand Up @@ -1693,10 +1690,7 @@ void QgsOptions::saveOptions()
QgsSettingsRegistryCore::settingsDigitizingLineColor->setValue( digitizingColor );

digitizingColor = mFillColorToolButton->color();
QgsSettingsRegistryCore::settingsDigitizingFillColorRed->setValue( digitizingColor.red() );
QgsSettingsRegistryCore::settingsDigitizingFillColorGreen->setValue( digitizingColor.green() );
QgsSettingsRegistryCore::settingsDigitizingFillColorBlue->setValue( digitizingColor.blue() );
QgsSettingsRegistryCore::settingsDigitizingFillColorAlpha->setValue( digitizingColor.alpha() );
QgsSettingsRegistryCore::settingsDigitizingFillColor->setValue( digitizingColor );

QgsSettingsRegistryCore::settingsDigitizingLineGhost->setValue( mLineGhostCheckBox->isChecked() );

Expand Down
12 changes: 4 additions & 8 deletions src/core/settings/qgssettingsregistrycore.cpp
Expand Up @@ -43,17 +43,11 @@ const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingStream

const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingLineWidth = new QgsSettingsEntryInteger( QStringLiteral( "line_width" ), QgsSettings::sTreeDigitizing, 1 );

const QgsSettingsEntryColor *QgsSettingsRegistryCore::settingsDigitizingLineColor = new QgsSettingsEntryColor( QStringLiteral( "line_color" ), QgsSettings::sTreeDigitizing, QColor( 255, 0, 0, 200 ) );
const QgsSettingsEntryColor *QgsSettingsRegistryCore::settingsDigitizingLineColor = new QgsSettingsEntryColor( QStringLiteral( "line-color" ), QgsSettings::sTreeDigitizing, QColor( 255, 0, 0, 200 ) );

const QgsSettingsEntryDouble *QgsSettingsRegistryCore::settingsDigitizingLineColorAlphaScale = new QgsSettingsEntryDouble( QStringLiteral( "line_color_alpha_scale" ), QgsSettings::sTreeDigitizing, 0.75 );

const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingFillColorRed = new QgsSettingsEntryInteger( QStringLiteral( "fill_color_red" ), QgsSettings::sTreeDigitizing, 255 );

const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingFillColorGreen = new QgsSettingsEntryInteger( QStringLiteral( "fill_color_green" ), QgsSettings::sTreeDigitizing, 0 );

const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingFillColorBlue = new QgsSettingsEntryInteger( QStringLiteral( "fill_color_blue" ), QgsSettings::sTreeDigitizing, 0 );

const QgsSettingsEntryInteger *QgsSettingsRegistryCore::settingsDigitizingFillColorAlpha = new QgsSettingsEntryInteger( QStringLiteral( "fill_color_alpha" ), QgsSettings::sTreeDigitizing, 30 );
const QgsSettingsEntryColor *QgsSettingsRegistryCore::settingsDigitizingFillColor = new QgsSettingsEntryColor( QStringLiteral( "fill-color" ), QgsSettings::sTreeDigitizing, QColor( 255, 0, 0, 30 ) );

const QgsSettingsEntryBool *QgsSettingsRegistryCore::settingsDigitizingLineGhost = new QgsSettingsEntryBool( QStringLiteral( "line_ghost" ), QgsSettings::sTreeDigitizing, false );

Expand Down Expand Up @@ -123,6 +117,7 @@ void QgsSettingsRegistryCore::migrateOldSettings()

// single settings - added in 3.30
settingsDigitizingLineColor->copyValueFromKeys( QStringLiteral( "qgis/digitizing/line_color_red" ), QStringLiteral( "qgis/digitizing/line_color_green" ), QStringLiteral( "qgis/digitizing/line_color_blue" ), QStringLiteral( "qgis/digitizing/line_color_alpha" ) );
settingsDigitizingFillColor->copyValueFromKeys( QStringLiteral( "qgis/digitizing/fill_color_red" ), QStringLiteral( "qgis/digitizing/fill_color_green" ), QStringLiteral( "qgis/digitizing/fill_color_blue" ), QStringLiteral( "qgis/digitizing/fill_color_alpha" ) );
QgsLayout::settingsSearchPathForTemplates->copyValueFromKey( QStringLiteral( "core/Layout/searchPathsForTemplates" ) );

QgsProcessing::settingsPreferFilenameAsLayerName->copyValueFromKey( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ) );
Expand Down Expand Up @@ -258,6 +253,7 @@ void QgsSettingsRegistryCore::backwardCompatibility()
{
// single settings - added in 3.30
settingsDigitizingLineColor->copyValueToKeys( QStringLiteral( "qgis/digitizing/line_color_red" ), QStringLiteral( "qgis/digitizing/line_color_green" ), QStringLiteral( "qgis/digitizing/line_color_blue" ), QStringLiteral( "qgis/digitizing/line_color_alpha" ) );
settingsDigitizingFillColor->copyValueToKeys( QStringLiteral( "qgis/digitizing/fill_color_red" ), QStringLiteral( "qgis/digitizing/fill_color_green" ), QStringLiteral( "qgis/digitizing/fill_color_blue" ), QStringLiteral( "qgis/digitizing/fill_color_alpha" ) );
QgsLayout::settingsSearchPathForTemplates->copyValueToKey( QStringLiteral( "core/Layout/searchPathsForTemplates" ) );

QgsProcessing::settingsPreferFilenameAsLayerName->copyValueToKey( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ) );
Expand Down
13 changes: 2 additions & 11 deletions src/core/settings/qgssettingsregistrycore.h
Expand Up @@ -62,17 +62,8 @@ class CORE_EXPORT QgsSettingsRegistryCore : public QgsSettingsRegistry
//! Settings entry digitizing line color alpha scale
static const QgsSettingsEntryDouble *settingsDigitizingLineColorAlphaScale;

//! Settings entry digitizing fill color red
static const QgsSettingsEntryInteger *settingsDigitizingFillColorRed;

//! Settings entry digitizing fill color green
static const QgsSettingsEntryInteger *settingsDigitizingFillColorGreen;

//! Settings entry digitizing fill color blue
static const QgsSettingsEntryInteger *settingsDigitizingFillColorBlue;

//! Settings entry digitizing fill color alpha
static const QgsSettingsEntryInteger *settingsDigitizingFillColorAlpha;
//! Settings entry digitizing fill color
static const QgsSettingsEntryColor *settingsDigitizingFillColor;

//! Settings entry digitizing line ghost
static const QgsSettingsEntryBool *settingsDigitizingLineGhost;
Expand Down
5 changes: 1 addition & 4 deletions src/gui/qgsmaptooledit.cpp
Expand Up @@ -57,10 +57,7 @@ int QgsMapToolEdit::digitizingStrokeWidth()

QColor QgsMapToolEdit::digitizingFillColor()
{
return QColor( QgsSettingsRegistryCore::settingsDigitizingFillColorRed->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorGreen->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorBlue->value(),
QgsSettingsRegistryCore::settingsDigitizingFillColorAlpha->value() );
return QgsSettingsRegistryCore::settingsDigitizingFillColor->value();
}


Expand Down

0 comments on commit 4fe0cbd

Please sign in to comment.