diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index acd0f57ceb1..6e8504be32d 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -161,7 +161,7 @@ class QgsMapCanvas : QGraphicsView void clearExtentHistory(); /** Zoom to the extent of the selected features of current (vector) layer. - Added in version 1.2: optionally specify different than current layer */ + @param layer optionally specify different than current layer */ void zoomToSelected( QgsVectorLayer* layer = NULL ); /** Pan to the selected features of current (vector) layer keeping same extent. */ @@ -203,7 +203,7 @@ class QgsMapCanvas : QGraphicsView //! return number of layers on the map int layerCount() const; - //! return list of layers within map canvas. Added in v1.5 + //! return list of layers within map canvas. QList layers() const; /*! Freeze/thaw the map canvas. This is used to prevent the canvas from @@ -350,6 +350,14 @@ class QgsMapCanvas : QGraphicsView //! ask user about datum transformation void getDatumTransformInfo( const QgsMapLayer* ml, const QString& srcAuthId, const QString& destAuthId ); + //! return if canvas rotation is enabled + //! @note added in 2.8 + static bool rotationEnabled(); + + //! change canvas rotation support + //! @note added in 2.8 + static void enableRotation( bool enabled ); + signals: /** Let the owner know how far we are with render operations */ //! @deprecated since 2.4 - already unused in 2.0 anyway @@ -365,6 +373,10 @@ class QgsMapCanvas : QGraphicsView //! Emitted when the extents of the map change void extentsChanged(); + //! Emitted when the rotation of the map changes + //! @note added in 2.8 + void rotationChanged( double ); + /** Emitted when the canvas has rendered. Passes a pointer to the painter on which the map was drawn. This is @@ -383,8 +395,7 @@ class QgsMapCanvas : QGraphicsView void mapCanvasRefreshed(); // ### QGIS 3: rename to mapRefreshStarted() - /** Emitted when the canvas is about to be rendered. - \note Added in 1.5 */ + /** Emitted when the canvas is about to be rendered. */ void renderStarting(); //! Emitted when a new set of layers has been received diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index f6c9ee33bd0..fc5c2341632 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1684,7 +1684,6 @@ void QgisApp::createStatusBar() mCoordsEdit->setMaximumHeight( 20 ); mCoordsEdit->setContentsMargins( 0, 0, 0, 0 ); mCoordsEdit->setAlignment( Qt::AlignCenter ); - mCoordsEdit->setAlignment( Qt::AlignCenter ); QRegExp coordValidator( "[+-]?\\d+\\.?\\d*\\s*,\\s*[+-]?\\d+\\.?\\d*" ); mCoordsEditValidator = new QRegExpValidator( coordValidator, mCoordsEdit ); mCoordsEdit->setWhatsThis( tr( "Shows the map coordinates at the " @@ -1726,7 +1725,7 @@ void QgisApp::createStatusBar() statusBar()->addPermanentWidget( mScaleEdit, 0 ); connect( mScaleEdit, SIGNAL( scaleChanged() ), this, SLOT( userScale() ) ); - if ( QSettings().value( "/qgis/canvasRotation", true ).toBool() ) + if ( QgsMapCanvas::rotationEnabled() ) { // add a widget to show/set current rotation mRotationLabel = new QLabel( QString(), statusBar() ); @@ -1747,7 +1746,6 @@ void QgisApp::createStatusBar() mRotationEdit->setKeyboardTracking( false ); mRotationEdit->setMaximumWidth( 120 ); mRotationEdit->setDecimals( 1 ); - mRotationEdit->setMaximumHeight( 20 ); mRotationEdit->setRange( -180.0, 180.0 ); mRotationEdit->setWrapping( true ); mRotationEdit->setSingleStep( 5.0 ); @@ -2098,10 +2096,6 @@ void QgisApp::setupConnections() connect( this, SIGNAL( projectRead() ), this, SLOT( checkForDeprecatedLabelsInProject() ) ); - // reset rotation on new project - connect( this, SIGNAL( newProject() ), - this, SLOT( resetMapSettings() ) ); - // setup undo/redo actions connect( mUndoWidget, SIGNAL( undoStackChanged() ), this, SLOT( updateUndoActions() ) ); } @@ -3530,7 +3524,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank ) //QgsDebugMsg("emiting new project signal"); - //emit signal so QgsComposer knows we have a new project + // emit signal so listeners know we have a new project emit newProject(); mMapCanvas->freeze( false ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index a1d2cc603ee..afc9bee4eac 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -151,7 +151,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QgsRasterLayer *addRasterLayer( const QString &rasterFile, const QString &baseName, bool guiWarning = true ); /** Returns and adjusted uri for the layer based on current and available CRS as well as the last selected image format - * @note added in 2.4 + * @note added in 2.8 */ QString crsAndFormatAdjustedLayerUri( const QString& uri, const QStringList& supportedCrs, const QStringList& supportedFormats ) const; diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 58409f00a32..cb578a0928e 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -583,7 +583,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) : cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() ); leNullValue->setText( settings.value( "qgis/nullValue", "NULL" ).toString() ); cbxIgnoreShapeEncoding->setChecked( settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() ); - cbxCanvasRotation->setChecked( settings.value( "/qgis/canvasRotation", true ).toBool() ); + cbxCanvasRotation->setChecked( QgsMapCanvas::rotationEnabled() ); cmbLegendDoubleClickAction->setCurrentIndex( settings.value( "/qgis/legendDoubleClickAction", 0 ).toInt() ); @@ -1111,7 +1111,7 @@ void QgsOptions::saveOptions() settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() ); bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool(); settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() ); - settings.setValue( "/qgis/canvasRotation", cbxCanvasRotation->isChecked() ); + QgsMapCanvas::enableRotation( cbxCanvasRotation->isChecked() ); // Default simplify drawing configuration QgsVectorSimplifyMethod::SimplifyHints simplifyHints = QgsVectorSimplifyMethod::NoSimplification; diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index efa59965ae8..c6236322f39 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -904,7 +904,7 @@ double QgsMapCanvas::rotation() const void QgsMapCanvas::setRotation( double degrees ) { - if ( !QSettings().value( "/qgis/canvasRotation", true ).toBool() ) + if ( !rotationEnabled() ) return; double current = rotation(); @@ -1905,3 +1905,13 @@ bool QgsMapCanvas::event( QEvent * e ) return done; } #endif + +bool QgsMapCanvas::rotationEnabled() +{ + return QSettings().value( "/qgis/canvasRotation", true ).toBool(); +} + +void QgsMapCanvas::enableRotation( bool enable ) +{ + QSettings().setValue( "/qgis/canvasRotation", enable ); +} diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index 451ee435e5d..50430a4d742 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -419,6 +419,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! ask user about datum transformation void getDatumTransformInfo( const QgsMapLayer* ml, const QString& srcAuthId, const QString& destAuthId ); + //! return if canvas rotation is enabled + //! @note added in 2.8 + static bool rotationEnabled(); + + //! change canvas rotation support + //! @note added in 2.8 + static void enableRotation( bool enabled ); + private slots: //! called when current maptool is destroyed void mapToolDestroyed(); @@ -644,7 +652,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView QgsPreviewEffect* mPreviewEffect; QgsRectangle imageRect( const QImage& img ); - }; // class QgsMapCanvas