Skip to content

Commit 18a97a7

Browse files
myarjunarm-kuhn
authored andcommitted
change zoom factor value to percent
1 parent a024bc1 commit 18a97a7

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

src/app/qgsoptions.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
714714
}
715715
leTemplateFolder->setText( templateDirName );
716716

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

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

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

13521352
//digitizing
13531353
mSettings->setValue( QStringLiteral( "/qgis/digitizing/line_width" ), mLineWidthSpinBox->value() );
@@ -2300,3 +2300,27 @@ void QgsOptions::scaleItemChanged( QListWidgetItem *changedScaleItem )
23002300
addScaleToScaleList( changedScaleItem );
23012301
mListGlobalScales->setCurrentItem( changedScaleItem );
23022302
}
2303+
2304+
double QgsOptions::zoomFactorValue()
2305+
{
2306+
// Get the decimal value for zoom factor. This function is needed because the zoom factor spin box is shown as a percent value.
2307+
// The minimum zoom factor value is 1.01
2308+
if ( spinZoomFactor->value() == spinZoomFactor->minimum() )
2309+
return 1.01;
2310+
else
2311+
return spinZoomFactor->value() / 100.0;
2312+
}
2313+
2314+
void QgsOptions::setZoomFactorValue()
2315+
{
2316+
// 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.
2317+
if ( mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ) <= 1.01 )
2318+
{
2319+
spinZoomFactor->setValue( spinZoomFactor->minimum() );
2320+
}
2321+
else
2322+
{
2323+
int percentValue = mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toInt() * 100;
2324+
spinZoomFactor->setValue( percentValue );
2325+
}
2326+
}

src/app/qgsoptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
228228
void saveContrastEnhancement( QComboBox *cbox, const QString &name );
229229
void initMinMaxLimits( QComboBox *cbox, const QString &name, const QString &defaultVal );
230230
void saveMinMaxLimits( QComboBox *cbox, const QString &name );
231+
void setZoomFactorValue();
232+
double zoomFactorValue();
231233
QgsCoordinateReferenceSystem mDefaultCrs;
232234
QgsCoordinateReferenceSystem mLayerDefaultCrs;
233235
bool mLoadedGdalDriverList;

src/ui/qgsoptionsbase.ui

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,15 +3440,21 @@
34403440
</widget>
34413441
</item>
34423442
<item row="0" column="1">
3443-
<widget class="QDoubleSpinBox" name="spinZoomFactor">
3444-
<property name="decimals">
3445-
<number>1</number>
3443+
<widget class="QSpinBox" name="spinZoomFactor">
3444+
<property name="suffix">
3445+
<string>%</string>
34463446
</property>
34473447
<property name="minimum">
3448-
<double>1.100000000000000</double>
3448+
<number>100</number>
3449+
</property>
3450+
<property name="maximum">
3451+
<number>999999999</number>
3452+
</property>
3453+
<property name="singleStep">
3454+
<number>100</number>
34493455
</property>
34503456
<property name="value">
3451-
<double>2.000000000000000</double>
3457+
<number>200</number>
34523458
</property>
34533459
</widget>
34543460
</item>

0 commit comments

Comments
 (0)