Skip to content

Commit

Permalink
customize mMenuToolbar according to toolbars customization
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 17, 2011
1 parent c2457ae commit 022be6e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
31 changes: 20 additions & 11 deletions src/app/qgisapp.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
restoreWindowState();

// do main window customization - after window state has been restored, before the window is shown
QgsCustomization::instance()->updateMainWindow();
QgsCustomization::instance()->updateMainWindow( mToolbarMenu );

mSplash->showMessage( tr( "QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom );

Expand Down Expand Up @@ -1065,17 +1065,26 @@ void QgisApp::createToolBars()
// qmainwindow::saveState and qmainwindow::restoreState
// work properly

QList<QToolBar*> toolbarMenuToolBars;
toolbarMenuToolBars << mFileToolBar
<< mLayerToolBar
<< mDigitizeToolBar
<< mAdvancedDigitizeToolBar
<< mMapNavToolBar
<< mAttributesToolBar
<< mPluginToolBar
<< mHelpToolBar
<< mRasterToolBar
<< mLabelToolBar;

QList<QAction*> toolbarMenuActions;
toolbarMenuActions << mFileToolBar->toggleViewAction()
<< mLayerToolBar->toggleViewAction()
<< mDigitizeToolBar->toggleViewAction()
<< mAdvancedDigitizeToolBar->toggleViewAction()
<< mMapNavToolBar->toggleViewAction()
<< mAttributesToolBar->toggleViewAction()
<< mPluginToolBar->toggleViewAction()
<< mHelpToolBar->toggleViewAction()
<< mRasterToolBar->toggleViewAction()
<< mLabelToolBar->toggleViewAction();
// Set action names so that they can be used in customization
foreach ( QToolBar *toolBar, toolbarMenuToolBars )
{
toolBar->toggleViewAction()->setObjectName ( "mActionToggle" + toolBar->objectName().mid(1) );
toolbarMenuActions << toolBar->toggleViewAction();
}

mToolbarMenu->addActions( toolbarMenuActions );

// select tool button
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ QgsCustomization::~QgsCustomization()
{
}

void QgsCustomization::updateMainWindow()
void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
{
// collect tree items even if the customization is disabled
createTreeItemMenus();
Expand Down Expand Up @@ -643,6 +643,8 @@ void QgsCustomization::updateMainWindow()
if (!visible)
{
mw->removeToolBar(tb);
// remove also from menu, because toolbars removed here, switched on later from menu don't work correctly
theToolBarMenu->removeAction( tb->toggleViewAction() );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgscustomization.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class QgsCustomization : public QObject
static void customizeWidget( QString path, QWidget * widget );
static void removeFromLayout( QLayout *theLayout, QWidget * widget );

void updateMainWindow();
void updateMainWindow( QMenu * theToolBarMenu );

// make sure to enable/disable before creating QgisApp in order to get it customized (or not)
void setEnabled(bool enabled) { mEnabled = enabled; }
Expand Down

0 comments on commit 022be6e

Please sign in to comment.