From 9f904ae04fe8cb8c18887a6ad36bac643cfcfae8 Mon Sep 17 00:00:00 2001 From: Paddle Date: Sat, 25 Mar 2023 08:49:21 +0100 Subject: [PATCH] Preference: Move workbench selector position to the workbench preference page. --- src/Gui/DlgGeneral.ui | 37 --------------------------- src/Gui/DlgGeneralImp.cpp | 23 ----------------- src/Gui/DlgGeneralImp.h | 2 -- src/Gui/DlgSettingsWorkbenches.ui | 37 +++++++++++++++++++++++++++ src/Gui/DlgSettingsWorkbenchesImp.cpp | 22 ++++++++++++++++ src/Gui/DlgSettingsWorkbenchesImp.h | 3 +++ 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/Gui/DlgGeneral.ui b/src/Gui/DlgGeneral.ui index d2a43592ab..542ffd0e88 100644 --- a/src/Gui/DlgGeneral.ui +++ b/src/Gui/DlgGeneral.ui @@ -508,43 +508,6 @@ this according to your screen size or personal taste - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Workbench selector position : - - - - - - - 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. - - - - - diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index fcfb8da8f7..e35375b69a 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -41,7 +41,6 @@ #include "DlgRevertToBackupConfigImp.h" #include "MainWindow.h" #include "PreferencePackManager.h" -#include "UserSettings.h" #include "Language/Translator.h" using namespace Gui::Dialog; @@ -223,8 +222,6 @@ void DlgGeneralImp::saveSettings() hGrp->GetGroup("TreeView")->SetBool("Enabled",treeView); hGrp->GetGroup("PropertyView")->SetBool("Enabled",propertyView); - saveWorkbenchSelector(); - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow"); hGrp->SetBool("TiledBackground", ui->tiledBackground->isChecked()); @@ -310,9 +307,6 @@ void DlgGeneralImp::loadSettings() } ui->treeMode->setCurrentIndex(index); - //workbench selector position combobox setup - loadWorkbenchSelector(); - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow"); ui->tiledBackground->setChecked(hGrp->GetBool("TiledBackground", false)); @@ -509,21 +503,4 @@ void DlgGeneralImp::onLoadPreferencePackClicked(const std::string& packName) } } -void DlgGeneralImp::saveWorkbenchSelector() -{ - //save workbench selector position - auto index = ui->WorkbenchSelectorPosition->currentIndex(); - WorkbenchSwitcher::setIndex(index); -} - -void DlgGeneralImp::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()); -} - #include "moc_DlgGeneralImp.cpp" diff --git a/src/Gui/DlgGeneralImp.h b/src/Gui/DlgGeneralImp.h index c92f9c0fc8..ae74bdae0c 100644 --- a/src/Gui/DlgGeneralImp.h +++ b/src/Gui/DlgGeneralImp.h @@ -69,8 +69,6 @@ private: bool setLanguage(); //Returns true if language has been changed void setNumberLocale(bool force = false); void setDecimalPointConversion(bool on); - void saveWorkbenchSelector(); - void loadWorkbenchSelector(); private: int localeIndex; diff --git a/src/Gui/DlgSettingsWorkbenches.ui b/src/Gui/DlgSettingsWorkbenches.ui index 79b3f3d2cd..50cc9cfbbf 100644 --- a/src/Gui/DlgSettingsWorkbenches.ui +++ b/src/Gui/DlgSettingsWorkbenches.ui @@ -40,6 +40,43 @@ Your currently system has the following workbenches:</p></body></ + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Workbench selector position : + + + + + + + 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. + + + + + diff --git a/src/Gui/DlgSettingsWorkbenchesImp.cpp b/src/Gui/DlgSettingsWorkbenchesImp.cpp index d75d386fa6..f41f7620e6 100644 --- a/src/Gui/DlgSettingsWorkbenchesImp.cpp +++ b/src/Gui/DlgSettingsWorkbenchesImp.cpp @@ -30,6 +30,7 @@ #include "DlgSettingsWorkbenchesImp.h" #include "ui_DlgSettingsWorkbenches.h" #include "Application.h" +#include "UserSettings.h" #include "Workbench.h" #include "WorkbenchManager.h" @@ -111,10 +112,14 @@ void DlgSettingsWorkbenchesImp::saveSettings() App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")-> SetASCII("BackgroundAutoloadModules", autoloadStr.str().c_str()); + + saveWorkbenchSelector(); } void DlgSettingsWorkbenchesImp::loadSettings() { + loadWorkbenchSelector(); + // There are two different "autoload" settings: the first, in FreeCAD since 2004, // controls the module the user sees first when starting FreeCAD, and defaults to the Start workbench std::string start = App::Application::Config()["StartWorkbench"]; @@ -372,4 +377,21 @@ void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e) } } +void DlgSettingsWorkbenchesImp::saveWorkbenchSelector() +{ + //save workbench selector position + auto index = ui->WorkbenchSelectorPosition->currentIndex(); + WorkbenchSwitcher::setIndex(index); +} + +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()); +} + #include "moc_DlgSettingsWorkbenchesImp.cpp" diff --git a/src/Gui/DlgSettingsWorkbenchesImp.h b/src/Gui/DlgSettingsWorkbenchesImp.h index d228c57811..3a5bd9a2c7 100644 --- a/src/Gui/DlgSettingsWorkbenchesImp.h +++ b/src/Gui/DlgSettingsWorkbenchesImp.h @@ -65,6 +65,9 @@ private: void addWorkbench(const QString& it, bool enabled); QWidget* createWorkbenchWidget(const QString& it, bool enabled); + void saveWorkbenchSelector(); + void loadWorkbenchSelector(); + std::unique_ptr ui; static const QString iconLabelStr; static const QString nameLabelStr;