Skip to content
Permalink
Browse files

[snapping] fix default snapping enabled state

  • Loading branch information
nirvn committed Dec 7, 2016
1 parent 75f51bc commit 60ad5c672ea54ced8a72831418c16330564b3bf2
Showing with 19 additions and 10 deletions.
  1. +5 −4 src/app/qgsoptions.cpp
  2. +2 −2 src/core/qgssnappingconfig.cpp
  3. +3 −2 src/gui/qgsmapcanvassnapper.cpp
  4. +9 −2 src/ui/qgsoptionsbase.ui
@@ -851,11 +851,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mLineGhostCheckBox->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/line_ghost" ), false ).toBool() );

//default snap mode
mSnappingEnabledDefault->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool() );
mDefaultSnapModeComboBox->insertItem( 0, tr( "To vertex" ), "to vertex" );
mDefaultSnapModeComboBox->insertItem( 1, tr( "To segment" ), "to segment" );
mDefaultSnapModeComboBox->insertItem( 2, tr( "To vertex and segment" ), "to vertex and segment" );
mDefaultSnapModeComboBox->insertItem( 3, tr( "Off" ), "off" );
QString defaultSnapString = mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), "off" ).toString();
QString defaultSnapString = mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), "to vertex" ).toString();
mDefaultSnapModeComboBox->setCurrentIndex( mDefaultSnapModeComboBox->findData( defaultSnapString ) );
mDefaultSnappingToleranceSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), 0 ).toDouble() );
mSearchRadiusVertexEditSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble() );
@@ -912,8 +912,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mValidateGeometries->setCurrentIndex( mSettings->value( QStringLiteral( "/qgis/digitizing/validate_geometries" ), 1 ).toInt() );

mSnappingMainDialogComboBox->clear();
mSnappingMainDialogComboBox->addItem( tr( "dialog" ), "dialog" );
mSnappingMainDialogComboBox->addItem( tr( "dock" ), "dock" );
mSnappingMainDialogComboBox->addItem( tr( "Dialog" ), "dialog" );
mSnappingMainDialogComboBox->addItem( tr( "Dock" ), "dock" );
mSnappingMainDialogComboBox->setCurrentIndex( mSnappingMainDialogComboBox->findData( mSettings->value( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), "dialog" ).toString() ) );

mOffsetJoinStyleComboBox->addItem( tr( "Round" ), 0 );
@@ -1359,6 +1359,7 @@ void QgsOptions::saveOptions()
settings.setValue( QStringLiteral( "/qgis/digitizing/line_ghost" ), mLineGhostCheckBox->isChecked() );

//default snap mode
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), mSnappingEnabledDefault->isChecked() );
QString defaultSnapModeString = mDefaultSnapModeComboBox->currentData().toString();
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), defaultSnapModeString );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), mDefaultSnappingToleranceSpinBox->value() );
@@ -128,7 +128,7 @@ bool QgsSnappingConfig::operator==( const QgsSnappingConfig& other ) const
void QgsSnappingConfig::reset()
{
// get defaults values. They are both used for standard and advanced configuration (per layer)
bool enabled = QSettings().value( QStringLiteral( "/qgis/digitizing/default_advanced_snap_enabled" ), true ).toBool();
bool enabled = QSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool();
SnappingMode mode = static_cast<SnappingMode>( QSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), AllLayers ).toInt() );
if ( mode == 0 )
{
@@ -377,7 +377,7 @@ void QgsSnappingConfig::writeProject( QDomDocument& doc )
bool QgsSnappingConfig::addLayers( const QList<QgsMapLayer*>& layers )
{
bool changed = false;
bool enabled = QSettings().value( QStringLiteral( "/qgis/digitizing/default_advanced_snap_enabled" ), true ).toBool();
bool enabled = QSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), true ).toBool();
SnappingType type = ( SnappingType )QSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_type" ), Vertex ).toInt();
double tolerance = QSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), 0 ).toDouble();
QgsTolerance::UnitType units = ( QgsTolerance::UnitType )QSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), QgsTolerance::ProjectUnits ).toInt();
@@ -169,10 +169,11 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<Qg
QSettings settings;
QString snappingMode = QgsProject::instance()->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/SnappingMode" ), QStringLiteral( "current_layer" ), &snappingDefinedInProject );
QString defaultSnapToleranceUnit = snappingDefinedInProject ? QgsProject::instance()->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapToleranceUnit" ) ) : settings.value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), "0" ).toString();
QString defaultSnapType = snappingDefinedInProject ? QgsProject::instance()->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapType" ) ) : settings.value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), "off" ).toString();
QString defaultSnapType = snappingDefinedInProject ? QgsProject::instance()->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapType" ) ) : settings.value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), "to vertex" ).toString();
QString defaultSnapTolerance = snappingDefinedInProject ? QString::number( QgsProject::instance()->readDoubleEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapTolerance" ) ) ) : settings.value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), "0" ).toString();
bool defaultSnapEnabled = settings.value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool();

if ( !snappingDefinedInProject && defaultSnapType == QLatin1String( "off" ) )
if ( !snappingDefinedInProject && defaultSnapEnabled == false )
{
return 0;
}
@@ -4003,7 +4003,14 @@
<string>Snapping</string>
</property>
<layout class="QGridLayout" name="_10">
<item row="1" column="1">
<item row="1" column="1" colspan="6">
<widget class="QCheckBox" name="mSnappingEnabledDefault">
<property name="text">
<string>Enable snapping by default</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_49">
<property name="text">
<string>Display main dialog as (restart required)</string>
@@ -4127,7 +4134,7 @@
</property>
</widget>
</item>
<item row="1" column="5" colspan="2">
<item row="5" column="5" colspan="2">
<widget class="QComboBox" name="mSnappingMainDialogComboBox"/>
</item>
<item row="3" column="1" colspan="2">

0 comments on commit 60ad5c6

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