diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index a976f8baced..e179aec7bce 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -82,6 +82,12 @@ class QgisInterface : QObject //! Remove an action (icon) from the Database toolbar //! @note added in 2.0 virtual void removeDatabaseToolBarIcon(QAction *qAction) = 0; + //! Add an icon to the Web toolbar + //! @note added in 2.0 + virtual int addWebToolBarIcon(QAction *qAction) =0; + //! Remove an action (icon) from the Web toolbar + //! @note added in 2.0 + virtual void removeWebToolBarIcon(QAction *qAction) = 0; //! Add toolbar with specified name virtual QToolBar* addToolBar(QString name)=0 /Factory/; @@ -154,6 +160,16 @@ class QgisInterface : QObject */ virtual void removePluginVectorMenu(QString name, QAction* action)=0; + /** Add action to the Web menu + * @note added in 2.0 + */ + virtual void addPluginToWebMenu(QString name, QAction* action)=0; + + /** Remove action from the Web menu + * @note added in 2.0 + */ + virtual void removePluginWebMenu(QString name, QAction* action)=0; + /** Add a dock widget to the main window @note added in 1.7 */ virtual void addDockWidget ( Qt::DockWidgetArea area, QDockWidget * dockwidget )=0; @@ -209,6 +225,8 @@ class QgisInterface : QObject virtual QMenu *rasterMenu() = 0; //** @note added in 2.0 virtual QMenu *vectorMenu() = 0; + //** @note added in 2.0 + virtual QMenu *webMenu() = 0; virtual QMenu *databaseMenu() = 0; virtual QMenu *firstRightStandardMenu() = 0; virtual QMenu *windowMenu() = 0; @@ -228,6 +246,8 @@ class QgisInterface : QObject virtual QToolBar *vectorToolBar() = 0; //** @note added in 2.0 virtual QToolBar *databaseToolBar() = 0; + //** @note added in 2.0 + virtual QToolBar *webToolBar() = 0; //! File menu actions virtual QAction *actionNewProject() = 0; diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 288f1d0debf..155946e4a16 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1095,6 +1095,9 @@ void QgisApp::createMenus() // Vector Menu // don't add it yet, wait for a plugin mVectorMenu = new QMenu( tr( "Vect&or" ) ); + // Web Menu + // don't add it yet, wait for a plugin + mWebMenu = new QMenu( tr( "&Web" ) ); // Help menu // add What's this button to it @@ -1124,6 +1127,7 @@ void QgisApp::createToolBars() << mRasterToolBar << mVectorToolBar << mDatabaseToolBar + << mWebToolBar << mLabelToolBar; QList toolbarMenuActions; @@ -5381,6 +5385,45 @@ QMenu* QgisApp::getVectorMenu( QString menuName ) return menu; } +QMenu* QgisApp::getWebMenu( QString menuName ) +{ +#ifdef Q_WS_MAC + // Mac doesn't have '&' keyboard shortcuts. + menuName.remove( QChar( '&' ) ); +#endif + QString dst = menuName; + dst.remove( QChar( '&' ) ); + + QAction *before = NULL; + QList actions = mWebMenu->actions(); + for ( int i = 0; i < actions.count(); i++ ) + { + QString src = actions.at( i )->text(); + src.remove( QChar( '&' ) ); + + int comp = dst.localeAwareCompare( src ); + if ( comp < 0 ) + { + // Add item before this one + before = actions.at( i ); + break; + } + else if ( comp == 0 ) + { + // Plugin menu item already exists + return actions.at( i )->menu(); + } + } + // It doesn't exist, so create + QMenu *menu = new QMenu( menuName, this ); + if ( before ) + mWebMenu->insertMenu( before, menu ); + else + mWebMenu->addMenu( menu ); + + return menu; +} + void QgisApp::insertAddLayerAction( QAction *action ) { mLayerMenu->insertAction( mActionAddLayerSeparator, action ); @@ -5453,6 +5496,34 @@ void QgisApp::addPluginToVectorMenu( QString name, QAction* action ) menuBar()->addMenu( mVectorMenu ); } +void QgisApp::addPluginToWebMenu( QString name, QAction* action ) +{ + QMenu* menu = getWebMenu( name ); + menu->addAction( action ); + + // add the Vector menu to the menuBar if not added yet + if ( mWebMenu->actions().count() != 1 ) + return; + + QAction* before = NULL; + QList actions = menuBar()->actions(); + for ( int i = 0; i < actions.count(); i++ ) + { + if ( actions.at( i )->menu() == mWebMenu ) + return; + if ( actions.at( i )->menu() == mHelpMenu ) + { + before = actions.at( i ); + break; + } + } + + if ( before ) + menuBar()->insertMenu( before, mWebMenu ); + else + menuBar()->addMenu( mWebMenu ); +} + void QgisApp::removePluginDatabaseMenu( QString name, QAction* action ) { QMenu* menu = getDatabaseMenu( name ); @@ -5519,6 +5590,30 @@ void QgisApp::removePluginVectorMenu( QString name, QAction* action ) } } +void QgisApp::removePluginWebMenu( QString name, QAction* action ) +{ + QMenu* menu = getWebMenu( name ); + menu->removeAction( action ); + if ( menu->actions().count() == 0 ) + { + mWebMenu->removeAction( menu->menuAction() ); + } + + // remove the Web menu from the menuBar if there are no more actions + if ( mWebMenu->actions().count() > 0 ) + return; + + QList actions = menuBar()->actions(); + for ( int i = 0; i < actions.count(); i++ ) + { + if ( actions.at( i )->menu() == mWebMenu ) + { + menuBar()->removeAction( actions.at( i ) ); + return; + } + } +} + int QgisApp::addPluginToolBarIcon( QAction * qAction ) { mPluginToolBar->addAction( qAction ); @@ -5563,6 +5658,17 @@ void QgisApp::removeDatabaseToolBarIcon( QAction *qAction ) mDatabaseToolBar->removeAction( qAction ); } +int QgisApp::addWebToolBarIcon( QAction * qAction ) +{ + mWebToolBar->addAction( qAction ); + return 0; +} + +void QgisApp::removeWebToolBarIcon( QAction *qAction ) +{ + mWebToolBar->removeAction( qAction ); +} + void QgisApp::updateCRSStatusBar() { mOnTheFlyProjectionStatusLabel->setText( mMapCanvas->mapRenderer()->destinationCrs().authid() ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 65afcfc074b..8b6e6e7d759 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -314,6 +314,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QMenu *databaseMenu() { return mDatabaseMenu; } QMenu *rasterMenu() { return mRasterMenu; } QMenu *vectorMenu() { return mVectorMenu; } + QMenu *webMenu() { return mWebMenu; } #ifdef Q_WS_MAC QMenu *firstRightStandardMenu() { return mWindowMenu; } QMenu *windowMenu() { return mWindowMenu; } @@ -341,6 +342,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QToolBar *rasterToolBar() { return mRasterToolBar; } QToolBar *vectorToolBar() { return mVectorToolBar; } QToolBar *databaseToolBar() { return mDatabaseToolBar; } + QToolBar *webToolBar() { return mWebToolBar; } //! show layer properties void showLayerProperties( QgsMapLayer *ml ); @@ -543,6 +545,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow void addPluginToVectorMenu( QString name, QAction* action ); //! Remove the action to the submenu with the given name under the Vector menu void removePluginVectorMenu( QString name, QAction* action ); + //! Find the QMenu with the given name within the Web menu (ie the user visible text on the menu item) + QMenu* getWebMenu( QString menuName ); + //! Add the action to the submenu with the given name under the Web menu + void addPluginToWebMenu( QString name, QAction* action ); + //! Remove the action to the submenu with the given name under the Web menu + void removePluginWebMenu( QString name, QAction* action ); //! Add "add layer" action to layer menu void insertAddLayerAction( QAction* action ); //! Remove "add layer" action to layer menu @@ -563,6 +571,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow int addDatabaseToolBarIcon( QAction * qAction ); //! Remove an icon from the Database toolbar void removeDatabaseToolBarIcon( QAction *qAction ); + //! Add an icon to the Web toolbar + int addWebToolBarIcon( QAction * qAction ); + //! Remove an icon from the Web toolbar + void removeWebToolBarIcon( QAction *qAction ); //! Save window state void saveWindowState(); //! Restore the window and toolbar state @@ -1015,6 +1027,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QMenu *mDatabaseMenu; //! Top level vector menu QMenu *mVectorMenu; + //! Top level web menu + QMenu *mWebMenu; //! Popup menu for the map overview tools QMenu *toolPopupOverviews; //! Popup menu for the display tools diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index b10143b87ac..d6485026409 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -184,6 +184,16 @@ void QgisAppInterface::removePluginVectorMenu( QString name, QAction* action ) qgis->removePluginVectorMenu( name, action ); } +void QgisAppInterface::addPluginToWebMenu( QString name, QAction* action ) +{ + qgis->addPluginToWebMenu( name, action ); +} + +void QgisAppInterface::removePluginWebMenu( QString name, QAction* action ) +{ + qgis->removePluginWebMenu( name, action ); +} + int QgisAppInterface::addToolBarIcon( QAction * qAction ) { return qgis->addPluginToolBarIcon( qAction ); @@ -224,6 +234,16 @@ void QgisAppInterface::removeDatabaseToolBarIcon( QAction *qAction ) qgis->removeDatabaseToolBarIcon( qAction ); } +int QgisAppInterface::addWebToolBarIcon( QAction * qAction ) +{ + return qgis->addWebToolBarIcon( qAction ); +} + +void QgisAppInterface::removeWebToolBarIcon( QAction *qAction ) +{ + qgis->removeWebToolBarIcon( qAction ); +} + QToolBar* QgisAppInterface::addToolBar( QString name ) { return qgis->addToolBar( name ); @@ -331,6 +351,7 @@ QMenu *QgisAppInterface::pluginMenu() { return qgis->pluginMenu(); } QMenu *QgisAppInterface::rasterMenu() { return qgis->rasterMenu(); } QMenu *QgisAppInterface::vectorMenu() { return qgis->vectorMenu(); } QMenu *QgisAppInterface::databaseMenu() { return qgis->databaseMenu(); } +QMenu *QgisAppInterface::webMenu() { return qgis->webMenu(); } QMenu *QgisAppInterface::firstRightStandardMenu() { return qgis->firstRightStandardMenu(); } QMenu *QgisAppInterface::windowMenu() { return qgis->windowMenu(); } QMenu *QgisAppInterface::helpMenu() { return qgis->helpMenu(); } @@ -347,6 +368,7 @@ QToolBar *QgisAppInterface::helpToolBar() { return qgis->helpToolBar(); } QToolBar *QgisAppInterface::rasterToolBar() { return qgis->rasterToolBar(); } QToolBar *QgisAppInterface::vectorToolBar() { return qgis->vectorToolBar(); } QToolBar *QgisAppInterface::databaseToolBar() { return qgis->databaseToolBar(); } +QToolBar *QgisAppInterface::webToolBar() { return qgis->webToolBar(); } //! File menu actions QAction *QgisAppInterface::actionNewProject() { return qgis->actionNewProject(); } diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index 42b36319569..d782cb5c1f6 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -94,6 +94,10 @@ class QgisAppInterface : public QgisInterface int addDatabaseToolBarIcon( QAction *qAction ); //! Remove an icon (action) from the Database toolbar void removeDatabaseToolBarIcon( QAction *qAction ); + //! Add an icon to the Web toolbar + int addWebToolBarIcon( QAction *qAction ); + //! Remove an icon (action) from the Web toolbar + void removeWebToolBarIcon( QAction *qAction ); //! Add toolbar with specified name QToolBar* addToolBar( QString name ); @@ -139,6 +143,11 @@ class QgisAppInterface : public QgisInterface /** Remove action from the Raster menu */ void removePluginVectorMenu( QString name, QAction* action ); + /** Add action to the Web menu */ + void addPluginToWebMenu( QString name, QAction* action ); + /** Remove action from the Web menu */ + void removePluginWebMenu( QString name, QAction* action ); + /** Add "add layer" action to the layer menu */ void insertAddLayerAction( QAction *action ); /** remove "add layer" action from the layer menu */ @@ -193,6 +202,7 @@ class QgisAppInterface : public QgisInterface virtual QMenu *rasterMenu(); virtual QMenu *vectorMenu(); virtual QMenu *databaseMenu(); + virtual QMenu *webMenu(); virtual QMenu *firstRightStandardMenu(); virtual QMenu *windowMenu(); virtual QMenu *helpMenu(); @@ -209,6 +219,7 @@ class QgisAppInterface : public QgisInterface virtual QToolBar *rasterToolBar(); virtual QToolBar *vectorToolBar(); virtual QToolBar *databaseToolBar(); + virtual QToolBar *webToolBar(); //! File menu actions virtual QAction *actionNewProject(); diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index d8b74e14ab5..8328fd2c3d4 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -141,6 +141,14 @@ class GUI_EXPORT QgisInterface : public QObject //! @note added in 2.0 virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0; + //! Add an icon to the Web toolbar + //! @note added in 2.0 + virtual int addWebToolBarIcon( QAction *qAction ) = 0; + + //! Remove an action (icon) from the Web toolbar + //! @note added in 2.0 + virtual void removeWebToolBarIcon( QAction *qAction ) = 0; + //! Add toolbar with specified name virtual QToolBar * addToolBar( QString name ) = 0; @@ -199,6 +207,17 @@ class GUI_EXPORT QgisInterface : public QObject */ virtual void removePluginVectorMenu( QString name, QAction* action ) = 0; + /** Add action to the Web menu + * @note added in 2.0 + */ + virtual void addPluginToWebMenu( QString name, QAction* action ) = 0; + + /** Remove action from the Web menu + * @note added in 2.0 + */ + virtual void removePluginWebMenu( QString name, QAction* action ) = 0; + + /** Add a dock widget to the main window */ virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0; @@ -275,6 +294,9 @@ class GUI_EXPORT QgisInterface : public QObject /** \note added in 2.0 */ virtual QMenu *vectorMenu() = 0; + /** \note added in 2.0 + */ + virtual QMenu *webMenu() = 0; virtual QMenu *firstRightStandardMenu() = 0; virtual QMenu *windowMenu() = 0; virtual QMenu *helpMenu() = 0; @@ -297,6 +319,9 @@ class GUI_EXPORT QgisInterface : public QObject /** \note added in 2.0 */ virtual QToolBar *databaseToolBar() = 0; + /** \note added in 2.0 + */ + virtual QToolBar *webToolBar() = 0; //! File menu actions virtual QAction *actionNewProject() = 0; diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 4e6cbc3549d..7b7caadc76f 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -407,6 +407,17 @@ false + + + Web + + + TopToolBarArea + + + false + +