diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index d53120b7e8c..667d54de06e 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -170,6 +170,10 @@ class QgsMapCanvas : QGraphicsView //! Zoom out with fixed factor void zoomOut( ); + + //! Zoom to a specific scale + // added in 1.5 + void zoomScale( double scale ); //! Zoom with the factor supplied. Factor > 1 zooms in void zoomByFactor( double scaleFactor ); diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 3ae1778a81d..0585c8801d5 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1220,6 +1220,12 @@ void QgisApp::showPythonDialog() mPythonUtils->getError( className, text ); QMessageBox::critical( this, tr( "Error" ), tr( "Failed to open Python console:" ) + "\n" + className + ": " + text ); } +#ifdef Q_WS_MAC + else + { + addWindow( mActionShowPythonDialog ); + } +#endif } void QgisApp::createActionGroups() @@ -4779,8 +4785,6 @@ void QgisApp::showScale( double theScale ) void QgisApp::userScale() { - double currentScale = mMapCanvas->scale(); - QStringList parts = mScaleEdit->text().split( ':' ); if ( parts.size() == 2 ) { @@ -4789,8 +4793,7 @@ void QgisApp::userScale() double rightSide = parts.at( 1 ).toDouble( &rightOk ); if ( leftSide > 0.0 && leftOk && rightOk ) { - double wantedScale = rightSide / leftSide; - mMapCanvas->zoomByFactor( wantedScale / currentScale ); + mMapCanvas->zoomScale( rightSide / leftSide ); } } } @@ -4998,7 +5001,6 @@ void QgisApp::loadPythonSupport() mActionPluginSeparator2 = mPluginMenu->addSeparator(); mPluginMenu->addAction( mActionShowPythonDialog ); std::cout << "Python support ENABLED :-) " << std::endl; // OK - } } @@ -5255,7 +5257,7 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa else { QMessageBox::critical( this, tr( "Layer is not valid" ), - tr( "The layer is not a valid layer and can not be added to the map" ) ); + tr( "The layer %1 is not a valid layer and can not be added to the map" ).arg( vectorLayerPath ) ); delete layer; mMapCanvas->freeze( false ); diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index eabff7943a2..0e7e83034bb 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -1057,6 +1057,11 @@ void QgsMapCanvas::zoomOut() zoomByFactor( mWheelZoomFactor ); } +void QgsMapCanvas::zoomScale( double newScale ) +{ + zoomByFactor( newScale / scale() ); +} + void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn ) { if ( mDrawing ) diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index baaee2945ca..25854866b65 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -228,6 +228,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! Zoom out with fixed factor void zoomOut( ); + //! Zoom to a specific scale + // added in 1.5 + void zoomScale( double scale ); + //! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in void zoomByFactor( double scaleFactor );