Skip to content

Commit

Permalink
add "Selection" toolbar to the QGIS main window and move all
Browse files Browse the repository at this point in the history
selection-related actions to it (fix #21045, refs #20350)
  • Loading branch information
alexbruy authored and nyalldawson committed May 13, 2020
1 parent 0fa4718 commit c93049a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgisinterface.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 7 additions & 11 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down Expand Up @@ -3129,6 +3128,7 @@ void QgisApp::createToolBars()
<< mShapeDigitizeToolBar
<< mMapNavToolBar
<< mAttributesToolBar
<< mSelectionToolBar
<< mPluginToolBar
<< mHelpToolBar
<< mRasterToolBar
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
15 changes: 15 additions & 0 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@
<addaction name="mActionNewMemoryLayer"/>
<addaction name="separator"/>
<addaction name="mActionNewVirtualLayer"/>
<addaction name="separator"/>
</widget>
<widget class="QToolBar" name="mShapeDigitizeToolBar">
<property name="windowTitle">
Expand All @@ -720,6 +721,20 @@
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="mSelectionToolBar">
<property name="windowTitle">
<string>Selection Toolbar</string>
</property>
<property name="toolTip">
<string>Selection Toolbar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="mActionNewProject">
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down

0 comments on commit c93049a

Please sign in to comment.