20 changes: 20 additions & 0 deletions python/gui/qgisinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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/;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/mapserver_export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def name():
def description():
return "Export a saved QGIS project file to a MapServer map file"
def category():
return "Plugins"
return "Web"
def version():
return "Version 0.4.3"
def qgisMinimumVersion():
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/mapserver_export/mapserverexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def initGui(self):
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
QObject.connect(self.iface, SIGNAL("currentThemeChanged ( QString )"), self.setCurrentTheme)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu("&MapServer Export...", self.action)
self.iface.addWebToolBarIcon(self.action)
self.iface.addPluginToWebMenu("&MapServer Export...", self.action)

def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu("&MapServer Export...",self.action)
self.iface.removeToolBarIcon(self.action)
self.iface.removePluginWebMenu("&MapServer Export...",self.action)
self.iface.removeWebToolBarIcon(self.action)

# run method that performs all the real work
def run(self):
Expand Down
24 changes: 12 additions & 12 deletions python/plugins/osm/OsmPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def initGui(self):
self.toolBar.addAction(self.actionSave)

# populate plugins menu
self.iface.addPluginToMenu("&OpenStreetMap", self.actionLoad)
self.iface.addPluginToMenu("&OpenStreetMap", self.actionDockWidget)
self.iface.addPluginToMenu("&OpenStreetMap", self.actionDownload)
self.iface.addPluginToMenu("&OpenStreetMap", self.actionUpload)
self.iface.addPluginToMenu("&OpenStreetMap", self.actionImport)
self.iface.addPluginToMenu("&OpenStreetMap", self.actionSave)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionLoad)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionDockWidget)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionDownload)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionUpload)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionImport)
self.iface.addPluginToWebMenu("&OpenStreetMap", self.actionSave)

# create manager of sqlite database(-s)
self.dbm=OsmDatabaseManager(self)
Expand Down Expand Up @@ -153,12 +153,12 @@ def unload(self):
self.dockWidget.mapTool=None

# remove the plugin menu items
self.iface.removePluginMenu("&OpenStreetMap",self.actionLoad)
self.iface.removePluginMenu("&OpenStreetMap",self.actionSave)
self.iface.removePluginMenu("&OpenStreetMap",self.actionDownload)
self.iface.removePluginMenu("&OpenStreetMap",self.actionUpload)
self.iface.removePluginMenu("&OpenStreetMap",self.actionImport)
self.iface.removePluginMenu("&OpenStreetMap",self.actionDockWidget)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionLoad)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionSave)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionDownload)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionUpload)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionImport)
self.iface.removePluginWebMenu("&OpenStreetMap",self.actionDockWidget)

self.dockWidget.close()
if self.dockWidget.rubBand:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/osm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def category():
@return category of this plugin.
"""

return "Plugins"
return "Web"


def version():
Expand Down
113 changes: 112 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1124,6 +1127,7 @@ void QgisApp::createToolBars()
<< mRasterToolBar
<< mVectorToolBar
<< mDatabaseToolBar
<< mWebToolBar
<< mLabelToolBar;

QList<QAction*> toolbarMenuActions;
Expand Down Expand Up @@ -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<QAction*> 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 );
Expand All @@ -5406,7 +5449,12 @@ void QgisApp::addPluginToDatabaseMenu( QString name, QAction* action )
{
if ( actions.at( i )->menu() == mDatabaseMenu )
return;
if ( actions.at( i )->menu() == mHelpMenu )
if ( actions.at( i )->menu() == mWebMenu )
{
before = actions.at( i );
break;
}
else if ( actions.at( i )->menu() == mHelpMenu )
{
before = actions.at( i );
break;
Expand Down Expand Up @@ -5453,6 +5501,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<QAction*> 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 );
Expand Down Expand Up @@ -5519,6 +5595,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<QAction*> 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 );
Expand Down Expand Up @@ -5563,6 +5663,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() );
Expand Down
14 changes: 14 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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(); }
Expand All @@ -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(); }
Expand Down
Loading