From c93049afd19ced6fe5064aefd0449e750c89a2c4 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 7 May 2020 16:02:44 +0300 Subject: [PATCH] add "Selection" toolbar to the QGIS main window and move all selection-related actions to it (fix #21045, refs #20350) --- python/gui/auto_generated/qgisinterface.sip.in | 7 +++++++ src/app/qgisapp.cpp | 18 +++++++----------- src/app/qgisapp.h | 6 ++++++ src/app/qgisappinterface.cpp | 1 + src/app/qgisappinterface.h | 1 + src/gui/qgisinterface.h | 6 ++++++ src/ui/qgisapp.ui | 15 +++++++++++++++ 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/python/gui/auto_generated/qgisinterface.sip.in b/python/gui/auto_generated/qgisinterface.sip.in index 8dafdc6846e..0037ce1c16f 100644 --- a/python/gui/auto_generated/qgisinterface.sip.in +++ b/python/gui/auto_generated/qgisinterface.sip.in @@ -300,6 +300,13 @@ Returns a reference to the main window "Shape Digitizing" toolbar. virtual QToolBar *attributesToolBar() = 0; %Docstring Returns a reference to the main window "Attributes" toolbar. +%End + + virtual QToolBar *selectionToolBar() = 0; +%Docstring +Returns a reference to the main window "Selection" toolbar. + +.. versionadded:: 3.14 %End virtual QToolBar *pluginToolBar() = 0; diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 18bd8acd190..c9ccabcc7c6 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1050,7 +1050,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh connect( QgsProject::instance(), &QgsProject::collectAttachedFiles, this, &QgisApp::generateProjectAttachedFiles ); connect( mSnappingUtils, &QgsSnappingUtils::configChanged, QgsProject::instance(), &QgsProject::setSnappingConfig ); - endProfile(); functionProfile( &QgisApp::createMenus, this, QStringLiteral( "Create menus" ) ); @@ -3129,6 +3128,7 @@ void QgisApp::createToolBars() << mShapeDigitizeToolBar << mMapNavToolBar << mAttributesToolBar + << mSelectionToolBar << mPluginToolBar << mHelpToolBar << mRasterToolBar @@ -3166,7 +3166,7 @@ void QgisApp::createToolBars() mToolbarMenu->addActions( toolbarMenuActions ); // advanced selection tool button - QToolButton *bt = new QToolButton( mAttributesToolBar ); + QToolButton *bt = new QToolButton( mSelectionToolBar ); bt->setPopupMode( QToolButton::MenuButtonPopup ); bt->addAction( mActionSelectByForm ); bt->addAction( mActionSelectByExpression ); @@ -3190,13 +3190,12 @@ void QgisApp::createToolBars() break; } bt->setDefaultAction( defAdvancedSelectionAction ); - QAction *advancedSelectionAction = mAttributesToolBar->insertWidget( mActionOpenTable, bt ); + QAction *advancedSelectionAction = mSelectionToolBar->insertWidget( mActionOpenTable, bt ); advancedSelectionAction->setObjectName( QStringLiteral( "ActionSelection" ) ); connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered ); - // mouse select tool button - bt = new QToolButton( mAttributesToolBar ); + bt = new QToolButton( mSelectionToolBar ); bt->setPopupMode( QToolButton::MenuButtonPopup ); bt->addAction( mActionSelectFeatures ); bt->addAction( mActionSelectPolygon ); @@ -3220,13 +3219,12 @@ void QgisApp::createToolBars() break; } bt->setDefaultAction( defMouseSelectAction ); - QAction *mouseSelectionAction = mAttributesToolBar->insertWidget( advancedSelectionAction, bt ); + QAction *mouseSelectionAction = mSelectionToolBar->insertWidget( advancedSelectionAction, bt ); mouseSelectionAction->setObjectName( QStringLiteral( "ActionSelect" ) ); connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered ); - // deselection tool button - bt = new QToolButton( mAttributesToolBar ); + bt = new QToolButton( mSelectionToolBar ); bt->setPopupMode( QToolButton::MenuButtonPopup ); bt->addAction( mActionDeselectAll ); bt->addAction( mActionDeselectActiveLayer ); @@ -3242,13 +3240,11 @@ void QgisApp::createToolBars() break; } bt->setDefaultAction( defDeselectionAction ); - QAction *deselectionAction = mAttributesToolBar->insertWidget( mActionOpenTable, bt ); + QAction *deselectionAction = mSelectionToolBar->insertWidget( mActionOpenTable, bt ); deselectionAction->setObjectName( QStringLiteral( "ActionDeselection" ) ); connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered ); - // feature action tool button - bt = new QToolButton( mAttributesToolBar ); bt->setPopupMode( QToolButton::MenuButtonPopup ); bt->setDefaultAction( mActionFeatureAction ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 2e1b7c91a3b..8760800e765 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -642,6 +642,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QToolBar *advancedDigitizeToolBar() { return mAdvancedDigitizeToolBar; } QToolBar *shapeDigitizeToolBar() { return mShapeDigitizeToolBar; } QToolBar *attributesToolBar() { return mAttributesToolBar; } + + /** + * Returns selection toolbar + * \since QGIS 3.14 + */ + QToolBar *selectionToolBar() { return mSelectionToolBar; } QToolBar *pluginToolBar() { return mPluginToolBar; } QToolBar *helpToolBar() { return mHelpToolBar; } QToolBar *rasterToolBar() { return mRasterToolBar; } diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index 6f52b7fdcc1..4e1225fc748 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -611,6 +611,7 @@ QToolBar *QgisAppInterface::digitizeToolBar() { return qgis->digitizeToolBar(); QToolBar *QgisAppInterface::advancedDigitizeToolBar() { return qgis->advancedDigitizeToolBar(); } QToolBar *QgisAppInterface::shapeDigitizeToolBar() { return qgis->shapeDigitizeToolBar(); } QToolBar *QgisAppInterface::attributesToolBar() { return qgis->attributesToolBar(); } +QToolBar *QgisAppInterface::selectionToolBar() { return qgis->selectionToolBar(); } QToolBar *QgisAppInterface::pluginToolBar() { return qgis->pluginToolBar(); } QToolBar *QgisAppInterface::helpToolBar() { return qgis->helpToolBar(); } QToolBar *QgisAppInterface::rasterToolBar() { return qgis->rasterToolBar(); } diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index c6d2836a8b4..c936a1afcbd 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -177,6 +177,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface QToolBar *advancedDigitizeToolBar() override; QToolBar *shapeDigitizeToolBar() override; QToolBar *attributesToolBar() override; + QToolBar *selectionToolBar() override; QToolBar *pluginToolBar() override; QToolBar *helpToolBar() override; QToolBar *rasterToolBar() override; diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index 90955b8781d..6fa98a83060 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -332,6 +332,12 @@ class GUI_EXPORT QgisInterface : public QObject */ virtual QToolBar *attributesToolBar() = 0; + /** + * Returns a reference to the main window "Selection" toolbar. + * \since QGIS 3.14 + */ + virtual QToolBar *selectionToolBar() = 0; + /** * Returns a reference to the main window "Plugin" toolbar. */ diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 31c6ea9f003..970e11960df 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -705,6 +705,7 @@ + @@ -720,6 +721,20 @@ false + + + Selection Toolbar + + + Selection Toolbar + + + TopToolBarArea + + + false + +