122
122
#include " qgscomposer.h"
123
123
#include " qgscomposermanager.h"
124
124
#include " qgscomposerview.h"
125
- #include " qgsstatusbarcoordinateswidget.h"
126
- #include " qgsstatusbarmagnifierwidget.h"
127
125
#include " qgsconfigureshortcutsdialog.h"
128
126
#include " qgscoordinatetransform.h"
129
127
#include " qgscoordinateutils.h"
207
205
#include " qgsrasterrenderer.h"
208
206
#include " qgsrasterlayersaveasdialog.h"
209
207
#include " qgsrectangle.h"
210
- #include " qgsscalecombobox.h"
211
208
#include " qgsscalevisibilitydialog.h"
212
209
#include " qgsgroupwmsdatadialog.h"
213
210
#include " qgsshortcutsmanager.h"
214
211
#include " qgssinglebandgrayrenderer.h"
215
212
#include " qgssnappingdialog.h"
216
213
#include " qgssponsors.h"
217
214
#include " qgsstatisticalsummarydockwidget.h"
218
- #include " qgssymbolv2selectordialog.h"
215
+ #include " qgsstatusbarcoordinateswidget.h"
216
+ #include " qgsstatusbarmagnifierwidget.h"
217
+ #include " qgsstatusbarscalewidget.h"
219
218
#include " qgsstylev2.h"
220
219
#include " qgssvgannotationitem.h"
220
+ #include " qgssymbolv2selectordialog.h"
221
221
#include " qgstextannotationitem.h"
222
222
#include " qgstipgui.h"
223
223
#include " qgsundowidget.h"
@@ -543,9 +543,7 @@ QgisApp *QgisApp::smInstance = nullptr;
543
543
QgisApp::QgisApp ( QSplashScreen *splash, bool restorePlugins, bool skipVersionCheck, QWidget * parent, Qt::WindowFlags fl )
544
544
: QMainWindow( parent, fl )
545
545
, mNonEditMapTool( nullptr )
546
- , mScaleLabel( nullptr )
547
- , mScaleEdit( nullptr )
548
- , mScaleEditValidator( nullptr )
546
+ , mScaleWidget( nullptr )
549
547
, mMagnifierWidget( nullptr )
550
548
, mCoordsEdit( nullptr )
551
549
, mRotationLabel( nullptr )
@@ -1001,9 +999,7 @@ QgisApp::QgisApp()
1001
999
, mpGpsDock( nullptr )
1002
1000
, mLogDock ( nullptr )
1003
1001
, mNonEditMapTool ( nullptr )
1004
- , mScaleLabel ( nullptr )
1005
- , mScaleEdit ( nullptr )
1006
- , mScaleEditValidator ( nullptr )
1002
+ , mScaleWidget ( nullptr )
1007
1003
, mMagnifierWidget ( nullptr )
1008
1004
, mCoordsEdit ( nullptr )
1009
1005
, mRotationLabel ( nullptr )
@@ -2138,38 +2134,17 @@ void QgisApp::createStatusBar()
2138
2134
mCoordsEdit ->setFont ( myFont );
2139
2135
statusBar ()->addPermanentWidget ( mCoordsEdit , 0 );
2140
2136
2141
- // add a label to show current scale
2142
- mScaleLabel = new QLabel ( QString (), statusBar () );
2143
- mScaleLabel ->setObjectName ( " mScaleLable" );
2144
- mScaleLabel ->setFont ( myFont );
2145
- mScaleLabel ->setMinimumWidth ( 10 );
2146
- // mScaleLabel->setMaximumHeight( 20 );
2147
- mScaleLabel ->setMargin ( 3 );
2148
- mScaleLabel ->setAlignment ( Qt::AlignCenter );
2149
- mScaleLabel ->setFrameStyle ( QFrame::NoFrame );
2150
- mScaleLabel ->setText ( tr ( " Scale" ) );
2151
- mScaleLabel ->setToolTip ( tr ( " Current map scale" ) );
2152
- statusBar ()->addPermanentWidget ( mScaleLabel , 0 );
2153
-
2154
- mScaleEdit = new QgsScaleComboBox ( statusBar () );
2155
- mScaleEdit ->setObjectName ( " mScaleEdit" );
2156
- mScaleEdit ->setFont ( myFont );
2157
- // seems setFont() change font only for popup not for line edit,
2158
- // so we need to set font for it separately
2159
- mScaleEdit ->lineEdit ()->setFont ( myFont );
2160
- mScaleEdit ->setMinimumWidth ( 10 );
2161
- mScaleEdit ->setContentsMargins ( 0 , 0 , 0 , 0 );
2162
- mScaleEdit ->setWhatsThis ( tr ( " Displays the current map scale" ) );
2163
- mScaleEdit ->setToolTip ( tr ( " Current map scale (formatted as x:y)" ) );
2164
-
2165
- statusBar ()->addPermanentWidget ( mScaleEdit , 0 );
2166
- connect ( mScaleEdit , SIGNAL ( scaleChanged ( double ) ), this , SLOT ( userScale () ) );
2137
+ mScaleWidget = new QgsStatusBarScaleWidget ( mMapCanvas , statusBar () );
2138
+ mScaleWidget ->setFont ( myFont );
2139
+ connect ( mScaleWidget , SIGNAL ( scaleLockChanged ( bool ) ), mMapCanvas , SLOT ( setScaleLocked ( bool ) ) );
2140
+ statusBar ()->addPermanentWidget ( mScaleWidget , 0 );
2167
2141
2168
2142
// zoom widget
2169
- QSettings mySettings;
2170
- mMagnifierWidget = new QgsStatusBarMagnifierWidget ( statusBar (), mMapCanvas );
2143
+ mMagnifierWidget = new QgsStatusBarMagnifierWidget ( statusBar () );
2171
2144
mMagnifierWidget ->setFont ( myFont );
2172
- mMagnifierWidget ->setMagnificationLevel ( mySettings.value ( " /qgis/magnifier_level" , 100 ).toInt () );
2145
+ connect ( mMapCanvas , SIGNAL ( magnificationChanged ( double ) ), mMagnifierWidget , SLOT ( updateMagnification ( double ) ) );
2146
+ connect ( mMagnifierWidget , SIGNAL ( magnificationChanged ( double ) ), mMapCanvas , SLOT ( setMagnificationFactor ( double ) ) );
2147
+ mMagnifierWidget ->updateMagnification ( QSettings ().value ( " /qgis/magnifier_factor_default" , 1.0 ).toDouble () );
2173
2148
statusBar ()->addPermanentWidget ( mMagnifierWidget , 0 );
2174
2149
2175
2150
if ( QgsMapCanvas::rotationEnabled () )
@@ -2227,7 +2202,7 @@ void QgisApp::createStatusBar()
2227
2202
mOnTheFlyProjectionStatusButton ->setObjectName ( " mOntheFlyProjectionStatusButton" );
2228
2203
// Maintain uniform widget height in status bar by setting button height same as labels
2229
2204
// For Qt/Mac 3.3, the default toolbutton height is 30 and labels were expanding to match
2230
- mOnTheFlyProjectionStatusButton ->setMaximumHeight ( mScaleLabel ->height () );
2205
+ mOnTheFlyProjectionStatusButton ->setMaximumHeight ( mScaleWidget ->height () );
2231
2206
mOnTheFlyProjectionStatusButton ->setIcon ( QgsApplication::getThemeIcon ( " mIconProjectionEnabled.png" ) );
2232
2207
mOnTheFlyProjectionStatusButton ->setWhatsThis ( tr ( " This icon shows whether "
2233
2208
" on the fly coordinate reference system transformation is enabled or not. "
@@ -2247,7 +2222,7 @@ void QgisApp::createStatusBar()
2247
2222
mMessageButton ->setWhatsThis ( tr ( " Messages" ) );
2248
2223
mMessageButton ->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
2249
2224
mMessageButton ->setObjectName ( " mMessageLogViewerButton" );
2250
- mMessageButton ->setMaximumHeight ( mScaleLabel ->height () );
2225
+ mMessageButton ->setMaximumHeight ( mScaleWidget ->height () );
2251
2226
mMessageButton ->setCheckable ( true );
2252
2227
statusBar ()->addPermanentWidget ( mMessageButton , 0 );
2253
2228
}
@@ -2716,9 +2691,8 @@ void QgisApp::createOverview()
2716
2691
// Anti Aliasing enabled by default as of QGIS 1.7
2717
2692
mMapCanvas ->enableAntiAliasing ( mySettings.value ( " /qgis/enable_anti_aliasing" , true ).toBool () );
2718
2693
2719
- int action = mySettings.value ( " /qgis/wheel_action" , 2 ).toInt ();
2720
2694
double zoomFactor = mySettings.value ( " /qgis/zoom_factor" , 2 ).toDouble ();
2721
- mMapCanvas ->setWheelAction ( static_cast < QgsMapCanvas::WheelAction >( action ), zoomFactor );
2695
+ mMapCanvas ->setWheelFactor ( zoomFactor );
2722
2696
2723
2697
mMapCanvas ->setCachingEnabled ( mySettings.value ( " /qgis/enable_render_caching" , true ).toBool () );
2724
2698
@@ -4198,7 +4172,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
4198
4172
mMapCanvas ->refresh ();
4199
4173
mMapCanvas ->clearExtentHistory ();
4200
4174
mMapCanvas ->setRotation ( 0.0 );
4201
- mScaleEdit ->updateScales ();
4175
+ mScaleWidget ->updateScales ();
4202
4176
4203
4177
// set project CRS
4204
4178
QString defCrs = settings.value ( " /Projections/projectDefaultCrs" , GEO_EPSG_CRS_AUTHID ).toString ();
@@ -4648,7 +4622,7 @@ bool QgisApp::addProject( const QString& projectFile )
4648
4622
bool projectScales = QgsProject::instance ()->readBoolEntry ( " Scales" , " /useProjectScales" );
4649
4623
if ( projectScales )
4650
4624
{
4651
- mScaleEdit ->updateScales ( QgsProject::instance ()->readListEntry ( " Scales" , " /ScalesList" ) );
4625
+ mScaleWidget ->updateScales ( QgsProject::instance ()->readListEntry ( " Scales" , " /ScalesList" ) );
4652
4626
}
4653
4627
4654
4628
mMapCanvas ->updateScale ();
@@ -7906,21 +7880,15 @@ void QgisApp::saveLastMousePosition( const QgsPoint & p )
7906
7880
void QgisApp::showScale ( double theScale )
7907
7881
{
7908
7882
// Why has MapCanvas the scale inverted?
7909
- mScaleEdit ->setScale ( 1.0 / theScale );
7883
+ mScaleWidget ->setScale ( 1.0 / theScale );
7910
7884
7911
7885
// Not sure if the lines below do anything meaningful /Homann
7912
- if ( mScaleEdit ->width () > mScaleEdit ->minimumWidth () )
7886
+ if ( mScaleWidget ->width () > mScaleWidget ->minimumWidth () )
7913
7887
{
7914
- mScaleEdit ->setMinimumWidth ( mScaleEdit ->width () );
7888
+ mScaleWidget ->setMinimumWidth ( mScaleWidget ->width () );
7915
7889
}
7916
7890
}
7917
7891
7918
- void QgisApp::userScale ()
7919
- {
7920
- // Why has MapCanvas the scale inverted?
7921
- mMapCanvas ->zoomScale ( 1.0 / mScaleEdit ->scale () );
7922
- }
7923
-
7924
7892
7925
7893
void QgisApp::userRotation ()
7926
7894
{
@@ -8596,9 +8564,8 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage )
8596
8564
8597
8565
mMapCanvas ->enableAntiAliasing ( mySettings.value ( " /qgis/enable_anti_aliasing" ).toBool () );
8598
8566
8599
- int action = mySettings.value ( " /qgis/wheel_action" , 2 ).toInt ();
8600
8567
double zoomFactor = mySettings.value ( " /qgis/zoom_factor" , 2 ).toDouble ();
8601
- mMapCanvas ->setWheelAction ( static_cast < QgsMapCanvas::WheelAction >( action ), zoomFactor );
8568
+ mMapCanvas ->setWheelFactor ( zoomFactor );
8602
8569
8603
8570
mMapCanvas ->setCachingEnabled ( mySettings.value ( " /qgis/enable_render_caching" , true ).toBool () );
8604
8571
@@ -8613,8 +8580,6 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage )
8613
8580
layer->setLayerName ( layer->originalName () );
8614
8581
}
8615
8582
8616
- mMagnifierWidget ->setMagnificationLevel ( mySettings.value ( " /qgis/magnifier_level" ).toInt () );
8617
-
8618
8583
// update any open compositions so they reflect new composer settings
8619
8584
// we have to push the changes to the compositions here, because compositions
8620
8585
// have no access to qgisapp and accordingly can't listen in to changes
@@ -8633,7 +8598,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage )
8633
8598
8634
8599
if ( oldScales != mySettings.value ( " Map/scales" , PROJECT_SCALES ).toString () )
8635
8600
{
8636
- mScaleEdit ->updateScales ();
8601
+ mScaleWidget ->updateScales ();
8637
8602
}
8638
8603
8639
8604
qobject_cast<QgsMeasureTool*>( mMapTools .mMeasureDist )->updateSettings ();
@@ -8645,6 +8610,10 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString& currentPage )
8645
8610
8646
8611
mMapCanvas ->setSegmentationTolerance ( mySettings.value ( " /qgis/segmentationTolerance" , " 0.01745" ).toDouble () );
8647
8612
mMapCanvas ->setSegmentationToleranceType ( QgsAbstractGeometryV2::SegmentationToleranceType ( mySettings.value ( " /qgis/segmentationToleranceType" , " 0" ).toInt () ) );
8613
+
8614
+ double factor = mySettings.value ( " /qgis/magnifier_factor_default" , 1.0 ).toDouble ();
8615
+ mMagnifierWidget ->setDefaultFactor ( factor );
8616
+ mMagnifierWidget ->updateMagnification ( factor );
8648
8617
}
8649
8618
8650
8619
delete optionsDialog;
@@ -9964,7 +9933,7 @@ void QgisApp::projectProperties()
9964
9933
connect ( pp, SIGNAL ( displayPrecisionChanged () ), this ,
9965
9934
SLOT ( updateMouseCoordinatePrecision () ) );
9966
9935
9967
- connect ( pp, SIGNAL ( scalesChanged ( const QStringList & ) ), mScaleEdit ,
9936
+ connect ( pp, SIGNAL ( scalesChanged ( const QStringList & ) ), mScaleWidget ,
9968
9937
SLOT ( updateScales ( const QStringList & ) ) );
9969
9938
QApplication::restoreOverrideCursor ();
9970
9939
0 commit comments