Skip to content
Permalink
Browse files

change zoom factor value to percent

  • Loading branch information
myarjunar authored and m-kuhn committed Mar 10, 2017
1 parent a024bc1 commit 18a97a7f04b60cdb3271086866d2bdef2a09071b
Showing with 39 additions and 7 deletions.
  1. +26 −2 src/app/qgsoptions.cpp
  2. +2 −0 src/app/qgsoptions.h
  3. +11 −5 src/ui/qgsoptionsbase.ui
@@ -714,7 +714,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
}
leTemplateFolder->setText( templateDirName );

spinZoomFactor->setValue( mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble() );
setZoomFactorValue();

// predefined scales for scale combobox
QString myPaths = mSettings->value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString();
@@ -1347,7 +1347,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "/qgis/default_measure_color_green" ), myColor.green() );
mSettings->setValue( QStringLiteral( "/qgis/default_measure_color_blue" ), myColor.blue() );

mSettings->setValue( QStringLiteral( "/qgis/zoom_factor" ), spinZoomFactor->value() );
mSettings->setValue( QStringLiteral( "/qgis/zoom_factor" ), zoomFactorValue() );

//digitizing
mSettings->setValue( QStringLiteral( "/qgis/digitizing/line_width" ), mLineWidthSpinBox->value() );
@@ -2300,3 +2300,27 @@ void QgsOptions::scaleItemChanged( QListWidgetItem *changedScaleItem )
addScaleToScaleList( changedScaleItem );
mListGlobalScales->setCurrentItem( changedScaleItem );
}

double QgsOptions::zoomFactorValue()
{
// Get the decimal value for zoom factor. This function is needed because the zoom factor spin box is shown as a percent value.
// The minimum zoom factor value is 1.01
if ( spinZoomFactor->value() == spinZoomFactor->minimum() )
return 1.01;
else
return spinZoomFactor->value() / 100.0;
}

void QgsOptions::setZoomFactorValue()
{
// Set the percent value for zoom factor spin box. This function is for converting the decimal zoom factor value in the qgis setting to the percent zoom factor value.
if ( mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ) <= 1.01 )
{
spinZoomFactor->setValue( spinZoomFactor->minimum() );
}
else
{
int percentValue = mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toInt() * 100;
spinZoomFactor->setValue( percentValue );
}
}
@@ -228,6 +228,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void saveContrastEnhancement( QComboBox *cbox, const QString &name );
void initMinMaxLimits( QComboBox *cbox, const QString &name, const QString &defaultVal );
void saveMinMaxLimits( QComboBox *cbox, const QString &name );
void setZoomFactorValue();
double zoomFactorValue();
QgsCoordinateReferenceSystem mDefaultCrs;
QgsCoordinateReferenceSystem mLayerDefaultCrs;
bool mLoadedGdalDriverList;
@@ -3440,15 +3440,21 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="spinZoomFactor">
<property name="decimals">
<number>1</number>
<widget class="QSpinBox" name="spinZoomFactor">
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<double>1.100000000000000</double>
<number>100</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<double>2.000000000000000</double>
<number>200</number>
</property>
</widget>
</item>

0 comments on commit 18a97a7

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