Skip to content

Commit

Permalink
Make max canvas scale 1600% (fix #15861)
Browse files Browse the repository at this point in the history
Max canvas sacle should be a multiple of 2 so that zooming in
to the max and then back out again results in 100% zoom option.

Additionally, make the min/max zoom level not come from QSettings
as these aren't exposed anywhere

(cherry-picked from 6d0e8e6)
  • Loading branch information
nyalldawson committed Nov 23, 2016
1 parent a78efc0 commit 9c64ad2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mSimplifyMaximumScaleComboBox->setScale( 1.0 / mSettings->value( "/qgis/simplifyMaxScale", 1 ).toFloat() );

// Magnifier
double magnifierMin = 100 * mSettings->value( "/qgis/magnifier_factor_min", 0.1 ).toDouble();
double magnifierMax = 100 * mSettings->value( "/qgis/magnifier_factor_max", 10 ).toDouble();
double magnifierMin = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
double magnifierMax = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
double magnifierVal = 100 * mSettings->value( "/qgis/magnifier_factor_default", 1.0 ).toDouble();
doubleSpinBoxMagnifierDefault->setRange( magnifierMin, magnifierMax );
doubleSpinBoxMagnifierDefault->setSingleStep( 50 );
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsstatusbarmagnifierwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
#include <qgsapplication.h>
#include "qgsstatusbarmagnifierwidget.h"
#include "qgsdoublespinbox.h"
#include "qgisgui.h"

QgsStatusBarMagnifierWidget::QgsStatusBarMagnifierWidget( QWidget* parent )
: QWidget( parent )
{
QSettings settings;
int minimumFactor = ( int ) 100 * settings.value( "/qgis/magnifier_factor_min", 0.1 ).toDouble();
int maximumFactor = ( int ) 100 * settings.value( "/qgis/magnifier_factor_max", 10 ).toDouble();
int minimumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
int maximumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
int defaultFactor = ( int ) 100 * settings.value( "/qgis/magnifier_factor_default", 1.0 ).toDouble();

// label
Expand Down
16 changes: 16 additions & 0 deletions src/gui/qgisgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class QFont;
/** \ingroup gui
* /namespace QgisGui
* The QgisGui namespace contains constants and helper functions used throughout the QGIS GUI.
* \note not available in Python bindings
*/
namespace QgisGui
{
Expand All @@ -48,6 +49,21 @@ namespace QgisGui
*/
static const Qt::WindowFlags ModalDialogFlags = nullptr;

/**
* Minimum magnification level allowed in map canvases.
* @see CANVAS_MAGNIFICATION_MAX
* @note added in QGIS 3.0
*/
constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;

/**
* Maximum magnification level allowed in map canvases.
* @see CANVAS_MAGNIFICATION_MAX
* @note added in QGIS 3.0
*/
// Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;

/**
Open files, preferring to have the default file selector be the
last one used, if any; also, prefer to start in the last directory
Expand Down
5 changes: 2 additions & 3 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,8 @@ QgsMapCanvas::~QgsMapCanvas()
void QgsMapCanvas::setMagnificationFactor( double factor )
{
// do not go higher or lower than min max magnification ratio
QSettings settings;
double magnifierMin = settings.value( "/qgis/magnifier_factor_min", 0.1 ).toDouble();
double magnifierMax = settings.value( "/qgis/magnifier_factor_max", 10 ).toDouble();
double magnifierMin = QgisGui::CANVAS_MAGNIFICATION_MIN;
double magnifierMax = QgisGui::CANVAS_MAGNIFICATION_MAX;
factor = qBound( magnifierMin, factor, magnifierMax );

// the magnifier widget is in integer percent
Expand Down

0 comments on commit 9c64ad2

Please sign in to comment.