Skip to content

Commit

Permalink
fix settings for shape map tool categories
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 1, 2023
1 parent 38005d9 commit dbf2f88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.cpp
Expand Up @@ -32,9 +32,8 @@
#include <QActionGroup>

const QgsSettingsEntryEnumFlag<Qgis::CaptureTechnique> *QgsMapToolsDigitizingTechniqueManager::settingsDigitizingTechnique = new QgsSettingsEntryEnumFlag<Qgis::CaptureTechnique>( QStringLiteral( "technique" ), QgsSettings::sTreeDigitizing, Qgis::CaptureTechnique::StraightSegments, QObject::tr( "Current digitizing technique" ), Qgis::SettingsOption::SaveFormerValue ) SIP_SKIP;

const QgsSettingsEntryString *QgsMapToolsDigitizingTechniqueManager::settingMapToolShapeDefaultForShape = new QgsSettingsEntryString( QStringLiteral( "%1/default" ), sTreeShapeMapTools, QString(), QObject::tr( "Default map tool for given shape category" ) ) SIP_SKIP;
const QgsSettingsEntryString *QgsMapToolsDigitizingTechniqueManager::settingMapToolShapeCurrent = new QgsSettingsEntryString( QStringLiteral( "current" ), sTreeShapeMapTools, QgsMapToolShapeCircle2PointsMetadata::TOOL_ID, QObject::tr( "Current shape map tool" ) ) SIP_SKIP;
const QgsSettingsEntryString *QgsMapToolsDigitizingTechniqueManager::settingMapToolShapeDefaultForCategory = new QgsSettingsEntryString( QStringLiteral( "default" ), sTreeShapeMapToolsCategories, QString(), QObject::tr( "Default map tool for given shape category" ) ) SIP_SKIP;

QgsMapToolsDigitizingTechniqueManager::QgsMapToolsDigitizingTechniqueManager( QObject *parent )
: QObject( parent )
Expand Down Expand Up @@ -137,12 +136,12 @@ void QgsMapToolsDigitizingTechniqueManager::setupToolBars()
action->setCheckable( true );
action->setData( metadata->id() );
shapeMenu->addAction( action );
QString defaultToolId = settingMapToolShapeDefaultForShape->value( qgsEnumValueToKey( metadata->category() ) );
QString defaultToolId = settingMapToolShapeDefaultForCategory->value( qgsEnumValueToKey( metadata->category() ) );
if ( defaultToolId.isEmpty() )
{
// if no default tool for category, take the first one
defaultToolId = metadata->id();
settingMapToolShapeDefaultForShape->setValue( metadata->id(), qgsEnumValueToKey( metadata->category() ) );
settingMapToolShapeDefaultForCategory->setValue( metadata->id(), qgsEnumValueToKey( metadata->category() ) );
}
if ( defaultToolId == metadata->id() )
shapeButton->setDefaultAction( action );
Expand Down Expand Up @@ -208,7 +207,7 @@ void QgsMapToolsDigitizingTechniqueManager::setShapeTool( const QString &shapeTo
const QgsMapToolShapeMetadata *md = QgsGui::mapToolShapeRegistry()->mapToolMetadata( shapeToolId );
if ( md )
{
settingMapToolShapeDefaultForShape->setValue( md->id(), qgsEnumValueToKey( md->category() ) );
settingMapToolShapeDefaultForCategory->setValue( md->id(), qgsEnumValueToKey( md->category() ) );
settingMapToolShapeCurrent->setValue( md->id() );
QToolButton *bt = mShapeCategoryButtons.value( md->category() );
action = mShapeActions.value( md->id() );
Expand Down
4 changes: 3 additions & 1 deletion src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h
Expand Up @@ -54,9 +54,11 @@ class APP_EXPORT QgsMapToolsDigitizingTechniqueManager : public QObject
public:
static const QgsSettingsEntryEnumFlag<Qgis::CaptureTechnique> *settingsDigitizingTechnique;


static inline QgsSettingsTreeNode *sTreeShapeMapTools = QgsSettings::sTreeDigitizing->createChildNode( QStringLiteral( "shape-map-tools" ) );
static const QgsSettingsEntryString *settingMapToolShapeDefaultForShape;
static const QgsSettingsEntryString *settingMapToolShapeCurrent;
static inline QgsSettingsTreeNamedListNode *sTreeShapeMapToolsCategories = sTreeShapeMapTools->createNamedListNode( QStringLiteral( "categories" ) );
static const QgsSettingsEntryString *settingMapToolShapeDefaultForCategory;

QgsMapToolsDigitizingTechniqueManager( QObject *parent );
~QgsMapToolsDigitizingTechniqueManager();
Expand Down

0 comments on commit dbf2f88

Please sign in to comment.