Gui: support toolbar drag and drop to status bar and menu bar (#13571)

* Gui: support toolbar drag and drop to status bar and menu bar

Closes FreeCAD/FreeCAD#12979

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Gui: improve toolbar handling in status and menu bar

* Gui: fix workbench tab bar orientation in status or menu bar

* Gui: remove workbench toolbar position settings

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Zheng Lei
2024-05-06 23:59:16 +08:00
committed by GitHub
parent 8f7424820c
commit b00a4384bf
15 changed files with 816 additions and 393 deletions

View File

@@ -14,6 +14,75 @@
<string>Available Workbenches</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="4" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="WorkbenchSelectorItemLabel">
<property name="text">
<string>Workbench selector items style:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="WorkbenchSelectorItem">
<property name="toolTip">
<string>Customize how the items are displayed.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="ListWidgetDragBugFix" name="wbList"/>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="WorkbenchSelectorTypeLabel">
<property name="text">
<string>Workbench selector type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="WorkbenchSelectorType">
<property name="toolTip">
<string>Choose the workbench selector widget type (restart required).</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="noteLabel">
<property name="sizePolicy">
@@ -37,8 +106,24 @@ Currently, your system has the following workbenches:&lt;/p&gt;&lt;/body&gt;&lt;
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="ListWidgetDragBugFix" name="wbList"/>
<item row="5" column="0">
<widget class="Gui::PrefCheckBox" name="CheckBox_WbByTab">
<property name="toolTip">
<string>If checked, application will remember which workbench is active for each tab of the viewport</string>
</property>
<property name="text">
<string>Remember active workbench by tab</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SaveWBbyTab</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout">
@@ -74,142 +159,20 @@ after FreeCAD launches</string>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="WorkbenchSelectorTypeLabel">
<property name="text">
<string>Workbench selector type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="WorkbenchSelectorType">
<property name="toolTip">
<string>Choose the workbench selector widget type (restart required).</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="WorkbenchSelectorPositionLabel">
<property name="text">
<string>Workbench selector position:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="WorkbenchSelectorPosition">
<property name="toolTip">
<string>Customize where the workbench selector appears (restart required).
'Toolbar': In the toolbars, as a movable toolbar.
'Left Corner': In the menu bar, on the left corner.
'Right Corner': In the menu bar, on the right corner.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="WorkbenchSelectorItemLabel">
<property name="text">
<string>Workbench selector items style:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="WorkbenchSelectorItem">
<property name="toolTip">
<string>Customize how the items are displayed.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="Gui::PrefCheckBox" name="CheckBox_WbByTab">
<property name="toolTip">
<string>If checked, application will remember which workbench is active for each tab of the viewport</string>
</property>
<property name="text">
<string>Remember active workbench by tab</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SaveWBbyTab</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>ListWidgetDragBugFix</class>
<extends>QListWidget</extends>
<header>ListWidgetDragBugFix.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>ListWidgetDragBugFix</class>
<extends>QListWidget</extends>
<header>ListWidgetDragBugFix.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -33,7 +33,6 @@
#endif
#include <Gui/Application.h>
#include <Gui/UserSettings.h>
#include <Gui/Workbench.h>
#include <Gui/WorkbenchManager.h>
@@ -365,9 +364,6 @@ void DlgSettingsWorkbenchesImp::resetSettingsToDefaults()
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
hGrp->RemoveASCII("WSPosition");
if (ui->WorkbenchSelectorPosition->currentIndex() != WorkbenchSwitcher::getIndex()) {
requireRestart();
}
//finally reset all the parameters associated to Gui::Pref* widgets
PreferencePage::resetSettingsToDefaults();
@@ -499,19 +495,11 @@ void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e)
void DlgSettingsWorkbenchesImp::saveWorkbenchSelector()
{
//save workbench selector position
int prevIndex = WorkbenchSwitcher::getIndex();
auto index = ui->WorkbenchSelectorPosition->currentIndex();
if (prevIndex != index) {
WorkbenchSwitcher::setIndex(index);
requireRestart();
}
//save workbench selector type
ParameterGrp::handle hGrp;
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
prevIndex = hGrp->GetInt("WorkbenchSelectorType", 0);
index = ui->WorkbenchSelectorType->currentIndex();
int prevIndex = hGrp->GetInt("WorkbenchSelectorType", 0);
int index = ui->WorkbenchSelectorType->currentIndex();
if (prevIndex != index) {
hGrp->SetInt("WorkbenchSelectorType", index);
requireRestart();
@@ -528,13 +516,6 @@ void DlgSettingsWorkbenchesImp::saveWorkbenchSelector()
void DlgSettingsWorkbenchesImp::loadWorkbenchSelector()
{
//workbench selector position combobox setup
ui->WorkbenchSelectorPosition->clear();
ui->WorkbenchSelectorPosition->addItem(tr("Toolbar"));
ui->WorkbenchSelectorPosition->addItem(tr("Left corner"));
ui->WorkbenchSelectorPosition->addItem(tr("Right corner"));
ui->WorkbenchSelectorPosition->setCurrentIndex(WorkbenchSwitcher::getIndex());
//workbench selector type setup
ParameterGrp::handle hGrp;
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");