Skip to content

Commit a6030d6

Browse files
committedDec 7, 2016
[snapping] fix enable state of snapping widget's elements
1 parent 6b0bf49 commit a6030d6

File tree

3 files changed

+2256
-82
lines changed

3 files changed

+2256
-82
lines changed
 

‎images/themes/default/mIconSnapping.svg

Lines changed: 2228 additions & 70 deletions
Loading

‎src/app/qgssnappingwidget.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,18 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
225225
modeChanged();
226226
updateToleranceDecimals();
227227

228-
restoreGeometry( QSettings().value( "/Windows/SnappingWidget/geometry" ).toByteArray() );
228+
mSettings = new QSettings();
229+
bool defaultSnapEnabled = mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool();
230+
enableSnapping( defaultSnapEnabled );
231+
232+
restoreGeometry( mSettings->value( "/Windows/SnappingWidget/geometry" ).toByteArray() );
229233
}
230234

231235
QgsSnappingWidget::~QgsSnappingWidget()
232236
{
233237
if ( mDisplayMode == Widget )
234238
{
235-
QSettings().setValue( QStringLiteral( "/Windows/SnappingWidget/geometry" ), saveGeometry() );
239+
mSettings->setValue( QStringLiteral( "/Windows/SnappingWidget/geometry" ), saveGeometry() );
236240
}
237241
}
238242

@@ -291,6 +295,8 @@ void QgsSnappingWidget::projectSnapSettingsChanged()
291295
{
292296
mIntersectionSnappingAction->setChecked( config.intersectionSnapping() );
293297
}
298+
299+
toggleSnappingWidgets( config.enabled() );
294300
}
295301

296302
void QgsSnappingWidget::projectTopologicalEditingChanged()
@@ -303,19 +309,23 @@ void QgsSnappingWidget::projectTopologicalEditingChanged()
303309

304310
void QgsSnappingWidget::enableSnapping( bool checked )
305311
{
306-
mModeButton->setEnabled( checked );
307-
mTypeButton->setEnabled( checked );
308-
mToleranceSpinBox->setEnabled( checked );
309-
mUnitsComboBox->setEnabled( checked );
312+
toggleSnappingWidgets( checked );
313+
mConfig.setEnabled( checked );
314+
mProject->setSnappingConfig( mConfig );
315+
}
316+
317+
void QgsSnappingWidget::toggleSnappingWidgets( bool enabled )
318+
{
319+
mModeButton->setEnabled( enabled );
320+
mTypeButton->setEnabled( enabled );
321+
mToleranceSpinBox->setEnabled( enabled );
322+
mUnitsComboBox->setEnabled( enabled );
310323
if ( mLayerTreeView )
311324
{
312-
mLayerTreeView->setEnabled( checked );
325+
mLayerTreeView->setEnabled( enabled );
313326
}
314-
mTopologicalEditingAction->setEnabled( checked );
315-
mIntersectionSnappingAction->setEnabled( checked );
316-
317-
mConfig.setEnabled( checked );
318-
mProject->setSnappingConfig( mConfig );
327+
mTopologicalEditingAction->setEnabled( enabled );
328+
mIntersectionSnappingAction->setEnabled( enabled );
319329
}
320330

321331
void QgsSnappingWidget::changeTolerance( double tolerance )

‎src/app/qgssnappingwidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class QgsProject;
3333
#include "qgssnappingconfig.h"
3434

3535
#include <QWidget>
36+
#include <QSettings>
3637

3738
/**
3839
* A widget which lets the user defines settings for snapping on a project
@@ -77,6 +78,9 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
7778

7879
void enableSnapping( bool checked );
7980

81+
//! toggle widgets enabled states
82+
void toggleSnappingWidgets( bool enabled );
83+
8084
void changeTolerance( double tolerance );
8185

8286
void changeUnit( int idx );
@@ -104,6 +108,8 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
104108
//! modeChanged determines if widget are visible or not based on mode
105109
void modeChanged();
106110

111+
QSettings *mSettings;
112+
107113
QgsProject* mProject;
108114
QgsSnappingConfig mConfig;
109115
QgsMapCanvas* mCanvas;

0 commit comments

Comments
 (0)
Please sign in to comment.