Skip to content
Permalink
Browse files

customize mMenuToolbar according to toolbars customization

  • Loading branch information
blazek committed May 17, 2011
1 parent c2457ae commit 022be6e7a4f6f2a3ffee0ce68bb80814f9b2b9e2
Showing with 24 additions and 13 deletions.
  1. +20 −11 src/app/qgisapp.cpp
  2. +3 −1 src/app/qgscustomization.cpp
  3. +1 −1 src/app/qgscustomization.h
31 src/app/qgisapp.cpp 100755 → 100644
@@ -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 );

@@ -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
@@ -594,7 +594,7 @@ QgsCustomization::~QgsCustomization()
{
}

void QgsCustomization::updateMainWindow()
void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu )
{
// collect tree items even if the customization is disabled
createTreeItemMenus();
@@ -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
{
@@ -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; }

0 comments on commit 022be6e

Please sign in to comment.
You can’t perform that action at this time.