Skip to content

Commit

Permalink
Define OpenStreetMap actions in .ui file and make Vector menu permanent
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 5, 2013
1 parent 3cf8840 commit 5a9715d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 45 deletions.
44 changes: 5 additions & 39 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mSaveRollbackInProgress = false;
activateDeactivateLayerRelatedActions( NULL );

QAction* actionOSMDownload = new QAction( tr( "Download data" ), this );
connect( actionOSMDownload, SIGNAL( triggered() ), this, SLOT( osmDownloadDialog() ) );
QAction* actionOSMImport = new QAction( tr( "Import topology from XML" ), this );
connect( actionOSMImport, SIGNAL( triggered() ), this, SLOT( osmImportDialog() ) );
QAction* actionOSMExport = new QAction( tr( "Export topology to SpatiaLite" ), this );
connect( actionOSMExport, SIGNAL( triggered() ), this, SLOT( osmExportDialog() ) );
addPluginToVectorMenu( "OpenStreetMap", actionOSMDownload );
addPluginToVectorMenu( "OpenStreetMap", actionOSMImport );
addPluginToVectorMenu( "OpenStreetMap", actionOSMExport );

addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
mUndoWidget->hide();

Expand Down Expand Up @@ -1061,6 +1051,11 @@ void QgisApp::createActions()
connect( mActionLocalCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( localCumulativeCutStretch() ) );
connect( mActionFullCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( fullCumulativeCutStretch() ) );

// Vector Menu Items
connect( mActionOSMDownload, SIGNAL( triggered() ), this, SLOT( osmDownloadDialog() ) );
connect( mActionOSMImport, SIGNAL( triggered() ), this, SLOT( osmImportDialog() ) );
connect( mActionOSMExport, SIGNAL( triggered() ), this, SLOT( osmExportDialog() ) );

// Help Menu Items

#ifdef Q_WS_MAC
Expand Down Expand Up @@ -1312,10 +1307,6 @@ void QgisApp::createMenus()
// don't add it yet, wait for a plugin
mDatabaseMenu = new QMenu( tr( "&Database" ), menuBar() );
mDatabaseMenu->setObjectName( "mDatabaseMenu" );
// Vector Menu
// don't add it yet, wait for a plugin
mVectorMenu = new QMenu( tr( "Vect&or" ), menuBar() );
mVectorMenu->setObjectName( "mVectorMenu" );
// Web Menu
// don't add it yet, wait for a plugin
mWebMenu = new QMenu( tr( "&Web" ), menuBar() );
Expand Down Expand Up @@ -7101,31 +7092,6 @@ void QgisApp::addPluginToVectorMenu( QString name, QAction* action )
{
QMenu* menu = getVectorMenu( name );
menu->addAction( action );

// add the Vector menu to the menuBar if not added yet
if ( mVectorMenu->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() == mVectorMenu )
return;

// goes before Raster menu, which is already in qgisapp.ui
if ( actions.at( i )->menu() == mRasterMenu )
{
before = actions.at( i );
break;
}
}

if ( before )
menuBar()->insertMenu( before, mVectorMenu );
else
// fallback insert
menuBar()->insertMenu( firstRightStandardMenu()->menuAction(), mVectorMenu );
}

void QgisApp::addPluginToWebMenu( QString name, QAction* action )
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1257,8 +1257,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QMenu * mPopupMenu;
//! Top level database menu
QMenu *mDatabaseMenu;
//! Top level vector menu
QMenu *mVectorMenu;
//! Top level web menu
QMenu *mWebMenu;
//! Popup menu for the map overview tools
Expand Down
38 changes: 34 additions & 4 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1052</width>
<height>489</height>
<width>1050</width>
<height>487</height>
</rect>
</property>
<widget class="QWidget" name="centralwidget"/>
Expand All @@ -16,8 +16,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1052</width>
<height>24</height>
<width>1050</width>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="mEditMenu">
Expand Down Expand Up @@ -224,12 +224,27 @@
</property>
<addaction name="mActionShowRasterCalculator"/>
</widget>
<widget class="QMenu" name="mVectorMenu">
<property name="title">
<string>Vect&amp;or</string>
</property>
<widget class="QMenu" name="menuOpenStreetMap">
<property name="title">
<string>&amp;OpenStreetMap</string>
</property>
<addaction name="mActionOSMDownload"/>
<addaction name="mActionOSMImport"/>
<addaction name="mActionOSMExport"/>
</widget>
<addaction name="menuOpenStreetMap"/>
</widget>
<addaction name="mFileMenu"/>
<addaction name="mEditMenu"/>
<addaction name="mViewMenu"/>
<addaction name="mLayerMenu"/>
<addaction name="mSettingsMenu"/>
<addaction name="mPluginMenu"/>
<addaction name="mVectorMenu"/>
<addaction name="mRasterMenu"/>
<addaction name="mHelpMenu"/>
</widget>
Expand Down Expand Up @@ -1984,6 +1999,21 @@ Acts on currently active editable layer</string>
<string>Rotate Feature(s)</string>
</property>
</action>
<action name="mActionOSMDownload">
<property name="text">
<string>&amp;Download data</string>
</property>
</action>
<action name="mActionOSMImport">
<property name="text">
<string>&amp;Import topology from XML</string>
</property>
</action>
<action name="mActionOSMExport">
<property name="text">
<string>&amp;Export topology to SpatiaLite</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit 5a9715d

Please sign in to comment.