diff --git a/python/plugins/GdalTools/GdalTools.py b/python/plugins/GdalTools/GdalTools.py index f5e3d7134c4..728b761444a 100644 --- a/python/plugins/GdalTools/GdalTools.py +++ b/python/plugins/GdalTools/GdalTools.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ /*************************************************************************** -Name : GdalTools +Name : GdalTools Description : Integrate gdal tools into qgis Date : 17/Sep/09 copyright : (C) 2009 by Lorenzo Masini (Faunalia) @@ -81,8 +81,27 @@ class GdalTools: from tools.GdalTools_utils import Version, GdalConfig self.GdalVersion = Version( GdalConfig.version() ) - self.menu = QMenu() - self.menu.setTitle( QCoreApplication.translate( "GdalTools", "&Raster" ) ) + # find the Raster menu + rasterMenu = None + menu_bar = self.iface.mainWindow().menuBar() + actions = menu_bar.actions() + + rasterText = QCoreApplication.translate( "QgisApp", "&Raster" ) + + for a in actions: + if a.menu().title() == rasterText: + rasterMenu = a.menu() + break + + if rasterMenu == None: + # no Raster menu, create and insert it before the Help menu + self.menu = QMenu() + self.menu.setTitle( QCoreApplication.translate( "GdalTools", "&Raster" ) ) + lastAction = actions[ len( actions ) - 1 ] + menu_bar.insertMenu( lastAction, self.menu ) + else: + self.menu = rasterMenu + self.menu.addSeparator() if self.GdalVersion >= "1.6": self.buildVRT = QAction( QIcon(":/icons/vrt.png"), QCoreApplication.translate( "GdalTools", "Build Virtual Raster (catalog)" ), self.iface.mainWindow() ) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index a59ad7fa70d..cc047d2d638 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1528,9 +1528,6 @@ void QgisApp::createMenus() mLayerMenu->addAction( mActionNewVectorLayer ); #endif - //todo: should probably go into a raster menu - mLayerMenu->addAction( mActionShowRasterCalculator ); - mLayerMenu->addAction( mActionAddOgrLayer ); mLayerMenu->addAction( mActionAddRasterLayer ); #ifdef HAVE_POSTGRESQL @@ -1609,6 +1606,13 @@ void QgisApp::createMenus() // don't add it yet, wait for a plugin mDatabaseMenu = new QMenu( tr( "&Database" ) ); + + // Raster Menu + + mRasterMenu = menuBar()->addMenu( tr( "&Raster" ) ); + + mRasterMenu->addAction( mActionShowRasterCalculator ); + // Help Menu diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index f493b299b45..75496dff19d 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -333,6 +333,7 @@ class QgisApp : public QMainWindow QMenu *settingsMenu() { return mSettingsMenu; } QMenu *pluginMenu() { return mPluginMenu; } QMenu *databaseMenu() { return mDatabaseMenu; } + QMenu *rasterMenu() { return mRasterMenu; } #ifdef Q_WS_MAC QMenu *firstRightStandardMenu() { return mWindowMenu; } QMenu *windowMenu() { return mWindowMenu; } @@ -1100,6 +1101,8 @@ class QgisApp : public QMainWindow QMenu *mPluginMenu; //! Top level database menu QMenu *mDatabaseMenu; + //! Top level raster menu + QMenu *mRasterMenu; //! Popup menu for the map overview tools QMenu *toolPopupOverviews; //! Popup menu for the display tools