From 2fd7625a9e1e3adbe2e7cc999d0311182c6f5e78 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Sat, 1 May 2021 11:58:46 +0100 Subject: [PATCH 1/2] [Gui] Preferences - Selection Fix Bug for new... ... users who save an unrelated Preference such as Stylesheet from loosing the default selection settings. See discussion : https://forum.freecadweb.org/viewtopic.php?f=3&t=58215 --- src/Gui/DlgSettingsSelection.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Gui/DlgSettingsSelection.cpp b/src/Gui/DlgSettingsSelection.cpp index aff8d341d2..9c52d37d90 100644 --- a/src/Gui/DlgSettingsSelection.cpp +++ b/src/Gui/DlgSettingsSelection.cpp @@ -58,6 +58,29 @@ void DlgSettingsSelection::saveSettings() void DlgSettingsSelection::loadSettings() { auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView"); + + // Stop new users loosing a number of default settings when changing an unrelated Preference Setting + bool treePreSelectionFalse = handle->GetBool("PreSelection", false); + bool treePreSelectionTrue = handle->GetBool("PreSelection", true); + bool treeRecordSelectionFalse = handle->GetBool("RecordSelection", false); + bool treeRecordSelectionTrue = handle->GetBool("RecordSelection", true); + bool treeSyncSelectionFalse = handle->GetBool("SyncSelection", false); + bool treeSyncSelectionTrue = handle->GetBool("SyncSelection", true); + bool treeSyncViewFalse = handle->GetBool("SyncView", false); + bool treeSyncViewTrue = handle->GetBool("SyncView", true); + if (treePreSelectionFalse != treePreSelectionTrue) { + handle->SetBool("PreSelection", true); + } + if (treeRecordSelectionFalse != treeRecordSelectionTrue) { + handle->SetBool("RecordSelection", true); + } + if (treeSyncSelectionFalse != treeSyncSelectionTrue) { + handle->SetBool("SyncSelection", true); + } + if (treeSyncViewFalse != treeSyncViewTrue) { + handle->SetBool("SyncView", true); + } + ui->checkBoxAutoSwitch->setChecked(handle->GetBool("SyncView")); ui->checkBoxAutoExpand->setChecked(handle->GetBool("SyncSelection")); ui->checkBoxPreselect->setChecked(handle->GetBool("PreSelection")); From 61b04b9969aba3643cb59d264c2cdfba2f454fd4 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Sun, 2 May 2021 12:04:03 +0100 Subject: [PATCH 2/2] Changes as per @Chennes advice --- src/Gui/DlgSettingsSelection.cpp | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/Gui/DlgSettingsSelection.cpp b/src/Gui/DlgSettingsSelection.cpp index 9c52d37d90..7ac6ddc2a2 100644 --- a/src/Gui/DlgSettingsSelection.cpp +++ b/src/Gui/DlgSettingsSelection.cpp @@ -58,33 +58,10 @@ void DlgSettingsSelection::saveSettings() void DlgSettingsSelection::loadSettings() { auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView"); - - // Stop new users loosing a number of default settings when changing an unrelated Preference Setting - bool treePreSelectionFalse = handle->GetBool("PreSelection", false); - bool treePreSelectionTrue = handle->GetBool("PreSelection", true); - bool treeRecordSelectionFalse = handle->GetBool("RecordSelection", false); - bool treeRecordSelectionTrue = handle->GetBool("RecordSelection", true); - bool treeSyncSelectionFalse = handle->GetBool("SyncSelection", false); - bool treeSyncSelectionTrue = handle->GetBool("SyncSelection", true); - bool treeSyncViewFalse = handle->GetBool("SyncView", false); - bool treeSyncViewTrue = handle->GetBool("SyncView", true); - if (treePreSelectionFalse != treePreSelectionTrue) { - handle->SetBool("PreSelection", true); - } - if (treeRecordSelectionFalse != treeRecordSelectionTrue) { - handle->SetBool("RecordSelection", true); - } - if (treeSyncSelectionFalse != treeSyncSelectionTrue) { - handle->SetBool("SyncSelection", true); - } - if (treeSyncViewFalse != treeSyncViewTrue) { - handle->SetBool("SyncView", true); - } - - ui->checkBoxAutoSwitch->setChecked(handle->GetBool("SyncView")); - ui->checkBoxAutoExpand->setChecked(handle->GetBool("SyncSelection")); - ui->checkBoxPreselect->setChecked(handle->GetBool("PreSelection")); - ui->checkBoxRecord->setChecked(handle->GetBool("RecordSelection")); + ui->checkBoxAutoSwitch->setChecked(handle->GetBool("SyncView", true)); + ui->checkBoxAutoExpand->setChecked(handle->GetBool("SyncSelection", true)); + ui->checkBoxPreselect->setChecked(handle->GetBool("PreSelection", true)); + ui->checkBoxRecord->setChecked(handle->GetBool("RecordSelection", true)); ui->checkBoxSelectionCheckBoxes->setChecked(handle->GetBool("CheckBoxesSelection")); }