Skip to content

Commit

Permalink
change zoom factor value to percent
Browse files Browse the repository at this point in the history
  • Loading branch information
myarjunar authored and m-kuhn committed Mar 10, 2017
1 parent a024bc1 commit 18a97a7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
28 changes: 26 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
}
}
2 changes: 2 additions & 0 deletions src/app/qgsoptions.h
Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -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>
Expand Down

0 comments on commit 18a97a7

Please sign in to comment.