diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 344a249882..e2412c0c6d 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -317,6 +317,7 @@ set(Gui_MOC_HDRS DlgReportViewImp.h DlgSettings3DViewImp.h DlgSettingsNavigation.h + DlgSettingsSelection.h DlgSettingsViewColor.h DlgSettingsColorGradientImp.h DlgSettingsDocumentImp.h @@ -443,6 +444,7 @@ SET(Gui_UIC_SRCS DlgReportView.ui DlgSettings3DView.ui DlgSettingsNavigation.ui + DlgSettingsSelection.ui DlgSettingsUnits.ui DlgSettingsViewColor.ui DlgSettingsColorGradient.ui @@ -673,6 +675,7 @@ SET(Dialog_Settings_CPP_SRCS DlgReportViewImp.cpp DlgSettings3DViewImp.cpp DlgSettingsNavigation.cpp + DlgSettingsSelection.cpp DlgSettingsUnitsImp.cpp DlgSettingsViewColor.cpp DlgSettingsColorGradientImp.cpp @@ -688,6 +691,7 @@ SET(Dialog_Settings_HPP_SRCS DlgReportViewImp.h DlgSettings3DViewImp.h DlgSettingsNavigation.h + DlgSettingsSelection.h DlgSettingsUnitsImp.h DlgSettingsViewColor.h DlgSettingsColorGradientImp.h @@ -705,6 +709,7 @@ SET(Dialog_Settings_SRCS DlgReportView.ui DlgSettings3DView.ui DlgSettingsNavigation.ui + DlgSettingsSelection.ui DlgSettingsUnits.ui DlgSettingsViewColor.ui DlgSettingsColorGradient.ui diff --git a/src/Gui/DlgSettingsSelection.cpp b/src/Gui/DlgSettingsSelection.cpp new file mode 100644 index 0000000000..ec798f80b2 --- /dev/null +++ b/src/Gui/DlgSettingsSelection.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#ifndef _PreComp_ +#endif + +#include "DlgSettingsSelection.h" +#include "ui_DlgSettingsSelection.h" +#include + +using namespace Gui::Dialog; + +/* TRANSLATOR Gui::Dialog::DlgSettingsSelection */ + +DlgSettingsSelection::DlgSettingsSelection(QWidget* parent) + : PreferencePage(parent) + , ui(new Ui_DlgSettingsSelection) +{ + ui->setupUi(this); +} + +DlgSettingsSelection::~DlgSettingsSelection() +{ +} + +void DlgSettingsSelection::saveSettings() +{ + auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView"); + handle->SetBool("SyncView", ui->checkBoxAutoSwitch->isChecked()); + handle->SetBool("SyncSelection", ui->checkBoxAutoExpand->isChecked()); + handle->SetBool("PreSelection", ui->checkBoxPreselect->isChecked()); + handle->SetBool("RecordSelection", ui->checkBoxRecord->isChecked()); +} + +void DlgSettingsSelection::loadSettings() +{ + auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView"); + ui->checkBoxAutoSwitch->setChecked(handle->GetBool("SyncView")); + ui->checkBoxAutoExpand->setChecked(handle->GetBool("SyncSelection")); + ui->checkBoxPreselect->setChecked(handle->GetBool("PreSelection")); + ui->checkBoxRecord->setChecked(handle->GetBool("RecordSelection")); +} + +void DlgSettingsSelection::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +#include "moc_DlgSettingsSelection.cpp" + diff --git a/src/Gui/DlgSettingsSelection.h b/src/Gui/DlgSettingsSelection.h new file mode 100644 index 0000000000..b58846a6a5 --- /dev/null +++ b/src/Gui/DlgSettingsSelection.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef GUI_DIALOG_DLGSETTINGSSELECTION_H +#define GUI_DIALOG_DLGSETTINGSSELECTION_H + +#include "PropertyPage.h" +#include + +class QDoubleSpinBox; + +namespace Gui { +namespace Dialog { +class Ui_DlgSettingsSelection; + +/** + * The Ui_DlgSettingsSelection class implements a preference page to change settings + * for the selection. + * \author Werner Mayer + */ +class DlgSettingsSelection : public PreferencePage +{ + Q_OBJECT + +public: + DlgSettingsSelection(QWidget* parent = nullptr); + ~DlgSettingsSelection(); + + void saveSettings(); + void loadSettings(); + +protected: + void changeEvent(QEvent *e); + +private: + std::unique_ptr ui; +}; + +} // namespace Dialog +} // namespace Gui + +#endif // GUI_DIALOG_DLGSETTINGSSELECTION_H diff --git a/src/Gui/DlgSettingsSelection.ui b/src/Gui/DlgSettingsSelection.ui new file mode 100644 index 0000000000..02799e5312 --- /dev/null +++ b/src/Gui/DlgSettingsSelection.ui @@ -0,0 +1,62 @@ + + + Gui::Dialog::DlgSettingsSelection + + + + 0 + 0 + 670 + 411 + + + + Selection + + + + + + Auto switch to the 3D view containing the selected item + + + + + + + Auto expand tree item when the corresponding object is selected in 3D view + + + + + + + Preselect the object in 3D view when mouse over the tree item + + + + + + + Record selection in tree view in order to go back/forward using navigation button + + + + + + + Qt::Vertical + + + + 20 + 274 + + + + + + + + + diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp index 4449b09b3b..d3d3647690 100644 --- a/src/Gui/resource.cpp +++ b/src/Gui/resource.cpp @@ -32,6 +32,7 @@ #include "DlgPreferencesImp.h" #include "DlgSettings3DViewImp.h" #include "DlgSettingsNavigation.h" +#include "DlgSettingsSelection.h" #include "DlgSettingsViewColor.h" #include "DlgGeneralImp.h" #include "DlgEditorImp.h" @@ -66,6 +67,7 @@ WidgetFactorySupplier::WidgetFactorySupplier() new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); //new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );