mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
customize mMenuToolbar according to toolbars customization
This commit is contained in:
parent
c2457ae4fd
commit
022be6e7a4
31
src/app/qgisapp.cpp
Executable file → Normal file
31
src/app/qgisapp.cpp
Executable file → Normal file
@ -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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user