From 16b2b9a864fbf8fcae6af1e38640995fd0fefeaf Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 8 Feb 2020 19:45:23 +0100 Subject: [PATCH] Sketcher: split huge settings page into two pages --- src/Mod/Sketcher/Gui/AppSketcherGui.cpp | 1 + src/Mod/Sketcher/Gui/CMakeLists.txt | 1 + src/Mod/Sketcher/Gui/SketcherSettings.cpp | 76 ++- src/Mod/Sketcher/Gui/SketcherSettings.h | 26 +- src/Mod/Sketcher/Gui/SketcherSettings.ui | 453 +++--------------- .../Sketcher/Gui/SketcherSettingsDisplay.ui | 368 ++++++++++++++ 6 files changed, 526 insertions(+), 399 deletions(-) create mode 100644 src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui diff --git a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp index 9611416055..d76d0c9e19 100644 --- a/src/Mod/Sketcher/Gui/AppSketcherGui.cpp +++ b/src/Mod/Sketcher/Gui/AppSketcherGui.cpp @@ -121,6 +121,7 @@ PyMOD_INIT_FUNC(SketcherGui) SketcherGui::PropertyConstraintListItem ::init(); (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Sketcher") ); + (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Sketcher") ); (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Sketcher") ); // add resources and reloads the translators diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index 190f38ddb3..c0db7a67eb 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -62,6 +62,7 @@ set(SketcherGui_UIC_SRCS SketchMirrorDialog.ui SketcherSettings.ui SketcherSettingsColors.ui + SketcherSettingsDisplay.ui SketchRectangularArrayDialog.ui SketcherRegularPolygonDialog.ui ) diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 09a7ef4f5d..2b9bae2c83 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -31,6 +31,7 @@ #include "SketcherSettings.h" #include "ui_SketcherSettings.h" +#include "ui_SketcherSettingsDisplay.h" #include "ui_SketcherSettingsColors.h" #include "TaskSketcherGeneral.h" #include @@ -48,13 +49,60 @@ SketcherSettings::SketcherSettings(QWidget* parent) : PreferencePage(parent), ui(new Ui_SketcherSettings) { ui->setupUi(this); - QGroupBox* groupBox = new QGroupBox(this); - QGridLayout* gridLayout = new QGridLayout(groupBox); + QGridLayout* gridLayout = new QGridLayout(ui->placeholder); gridLayout->setSpacing(0); gridLayout->setMargin(0); - form = new SketcherGeneralWidget(groupBox); + form = new SketcherGeneralWidget(ui->placeholder); gridLayout->addWidget(form, 0, 0, 1, 1); - ui->gridLayout_3->addWidget(groupBox, 1, 0, 1, 1); +} + +/** + * Destroys the object and frees any allocated resources + */ +SketcherSettings::~SketcherSettings() +{ + // no need to delete child widgets, Qt does it all for us + delete ui; +} + +void SketcherSettings::saveSettings() +{ + // Sketch editing + ui->checkBoxAdvancedSolverTaskBox->onSave(); + ui->checkBoxRecalculateInitialSolutionWhileDragging->onSave(); + ui->checkBoxNotifyConstraintSubstitutions->onSave(); + form->saveSettings(); +} + +void SketcherSettings::loadSettings() +{ + // Sketch editing + ui->checkBoxAdvancedSolverTaskBox->onRestore(); + ui->checkBoxRecalculateInitialSolutionWhileDragging->onRestore(); + ui->checkBoxNotifyConstraintSubstitutions->onRestore(); + form->loadSettings(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void SketcherSettings::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + + +/* TRANSLATOR SketcherGui::SketcherSettingsDisplay */ + +SketcherSettingsDisplay::SketcherSettingsDisplay(QWidget* parent) + : PreferencePage(parent), ui(new Ui_SketcherSettingsDisplay) +{ + ui->setupUi(this); QList < QPair > styles; styles << qMakePair(Qt::SolidLine, 0xffff) @@ -86,29 +134,24 @@ SketcherSettings::SketcherSettings(QWidget* parent) /** * Destroys the object and frees any allocated resources */ -SketcherSettings::~SketcherSettings() +SketcherSettingsDisplay::~SketcherSettingsDisplay() { // no need to delete child widgets, Qt does it all for us delete ui; } -void SketcherSettings::saveSettings() +void SketcherSettingsDisplay::saveSettings() { - // Sketch editing ui->EditSketcherFontSize->onSave(); ui->SegmentsPerGeometry->onSave(); ui->dialogOnDistanceConstraint->onSave(); ui->continueMode->onSave(); ui->constraintMode->onSave(); ui->checkBoxHideUnits->onSave(); - ui->checkBoxAdvancedSolverTaskBox->onSave(); - ui->checkBoxRecalculateInitialSolutionWhileDragging->onSave(); ui->checkBoxTVHideDependent->onSave(); ui->checkBoxTVShowLinks->onSave(); ui->checkBoxTVShowSupport->onSave(); ui->checkBoxTVRestoreCamera->onSave(); - ui->checkBoxNotifyConstraintSubstitutions->onSave(); - form->saveSettings(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex()); @@ -116,23 +159,18 @@ void SketcherSettings::saveSettings() hGrp->SetInt("GridLinePattern", pattern); } -void SketcherSettings::loadSettings() +void SketcherSettingsDisplay::loadSettings() { - // Sketch editing ui->EditSketcherFontSize->onRestore(); ui->SegmentsPerGeometry->onRestore(); ui->dialogOnDistanceConstraint->onRestore(); ui->continueMode->onRestore(); ui->constraintMode->onRestore(); ui->checkBoxHideUnits->onRestore(); - ui->checkBoxAdvancedSolverTaskBox->onRestore(); - ui->checkBoxRecalculateInitialSolutionWhileDragging->onRestore(); ui->checkBoxTVHideDependent->onRestore(); ui->checkBoxTVShowLinks->onRestore(); ui->checkBoxTVShowSupport->onRestore(); ui->checkBoxTVRestoreCamera->onRestore(); - ui->checkBoxNotifyConstraintSubstitutions->onRestore(); - form->loadSettings(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f); @@ -144,7 +182,7 @@ void SketcherSettings::loadSettings() /** * Sets the strings of the subwidgets using the current language. */ -void SketcherSettings::changeEvent(QEvent *e) +void SketcherSettingsDisplay::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { ui->retranslateUi(this); @@ -154,7 +192,7 @@ void SketcherSettings::changeEvent(QEvent *e) } } -void SketcherSettings::onBtnTVApplyClicked(bool) +void SketcherSettingsDisplay::onBtnTVApplyClicked(bool) { QString errMsg; try{ diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.h b/src/Mod/Sketcher/Gui/SketcherSettings.h index 0b3ba698a8..6887f217f9 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.h +++ b/src/Mod/Sketcher/Gui/SketcherSettings.h @@ -28,6 +28,7 @@ namespace SketcherGui { class Ui_SketcherSettings; +class Ui_SketcherSettingsDisplay; class Ui_SketcherSettingsColors; class SketcherGeneralWidget; /** @@ -48,11 +49,34 @@ public: protected: void changeEvent(QEvent *e); +private: + Ui_SketcherSettings* ui; + SketcherGeneralWidget* form; +}; + +/** + * The SketcherSettings class implements a preference page to change sketcher display settings. + * @author Werner Mayer + */ +class SketcherSettingsDisplay : public Gui::Dialog::PreferencePage +{ + Q_OBJECT + +public: + SketcherSettingsDisplay(QWidget* parent = 0); + ~SketcherSettingsDisplay(); + + void saveSettings(); + void loadSettings(); + +protected: + void changeEvent(QEvent *e); + private Q_SLOTS: void onBtnTVApplyClicked(bool); private: - Ui_SketcherSettings* ui; + Ui_SketcherSettingsDisplay* ui; SketcherGeneralWidget* form; }; diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.ui b/src/Mod/Sketcher/Gui/SketcherSettings.ui index fd0e88326e..0247f18a4c 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettings.ui @@ -7,380 +7,21 @@ 0 0 602 - 720 + 614 General - + - + - Sketch editing + Sketcher - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 0 - 0 - - - - Notifications - - - - - - Notifies about automatic constraint substitutions - - - Notify automatic constraint substitutions - - - true - - - NotifyConstraintSubstitutions - - - Mod/Sketcher/General - - - - - - - - - - - 182 - 0 - - - - Font size - - - - - - - Font size used for labels and constraints - - - px - - - 1 - - - 100 - - - 17 - - - EditSketcherFontSize - - - View - - - - - - - Line pattern used for grid lines - - - -1 - - - - - - - A dialog will pop up to input a value for new dimensional constraints - - - Ask for value after creating a dimensional constraint - - - true - - - ShowDialogOnDistanceConstraint - - - Mod/Sketcher - - - - - - - Grid line pattern - - - - - - - Current sketcher creation tool will remain active after creation - - - Geometry creation "Continue Mode" - - - true - - - ContinuousCreationMode - - - Mod/Sketcher - - - - - - - Current constraint creation tool will remain active after creation - - - Constraint creation "Continue Mode" - - - true - - - ContinuousConstraintMode - - - Mod/Sketcher - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 0 - 0 - - - - Visibility automation - - - - - - When opening sketch, hide all features that depend on it - - - Hide all objects that depend on the sketch - - - true - - - HideDependent - - - Mod/Sketcher/General - - - - - - - When opening sketch, show sources for external geometry links - - - Show objects used for external geometry - - - true - - - ShowLinks - - - Mod/Sketcher/General - - - - - - - When opening sketch, show objects the sketch is attached to - - - Show object(s) sketch is attached to - - - true - - - ShowSupport - - - Mod/Sketcher/General - - - - - - - When closing sketch, move camera back to where it was before sketch was opened - - - Restore camera position after editing - - - true - - - RestoreCamera - - - Mod/Sketcher/General - - - - - - - - 0 - 0 - - - - Note: these settings are defaults applied to new sketches. The behavior is remembered for each sketch individually as properties on View tab. - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - - - - - - 0 - 0 - - - - Applies current visibility automation settings to all sketches in open documents - - - Apply to existing sketches - - - - - - - - - - Segments per geometry - - - - - - - Number of polygons for geometry approximation - - - 50 - - - 1000 - - - SegmentsPerGeometry - - - View - - - - - - - Base length units will not be displayed in constraints. -Supports all unit systems except 'US customary' and 'Building US/Euro'. - - - Hide base length units for supported unit systems - - - HideUnits - - - Mod/Sketcher - - - - - + Sketcher solver @@ -406,7 +47,7 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. - + Dragging performance @@ -435,14 +76,77 @@ Requires to re-enter edit mode to take effect. + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 0 + 0 + + + + Notifications + + + + + + Notifies about automatic constraint substitutions + + + Notify automatic constraint substitutions + + + true + + + NotifyConstraintSubstitutions + + + Mod/Sketcher/General + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
Gui::PrefCheckBox QCheckBox @@ -450,15 +154,6 @@ Requires to re-enter edit mode to take effect.
- EditSketcherFontSize - comboBox - dialogOnDistanceConstraint - continueMode - checkBoxTVHideDependent - checkBoxTVShowLinks - checkBoxTVShowSupport - checkBoxTVRestoreCamera - btnTVApply checkBoxAdvancedSolverTaskBox diff --git a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui new file mode 100644 index 0000000000..55e3502b76 --- /dev/null +++ b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui @@ -0,0 +1,368 @@ + + + SketcherGui::SketcherSettingsDisplay + + + + 0 + 0 + 602 + 608 + + + + Display + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Sketch editing + + + + + + A dialog will pop up to input a value for new dimensional constraints + + + Ask for value after creating a dimensional constraint + + + true + + + ShowDialogOnDistanceConstraint + + + Mod/Sketcher + + + + + + + Segments per geometry + + + + + + + Current constraint creation tool will remain active after creation + + + Constraint creation "Continue Mode" + + + true + + + ContinuousConstraintMode + + + Mod/Sketcher + + + + + + + Line pattern used for grid lines + + + -1 + + + + + + + Base length units will not be displayed in constraints. +Supports all unit systems except 'US customary' and 'Building US/Euro'. + + + Hide base length units for supported unit systems + + + HideUnits + + + Mod/Sketcher + + + + + + + + 182 + 0 + + + + Font size + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 0 + 0 + + + + Visibility automation + + + + + + When opening sketch, hide all features that depend on it + + + Hide all objects that depend on the sketch + + + true + + + HideDependent + + + Mod/Sketcher/General + + + + + + + When opening sketch, show sources for external geometry links + + + Show objects used for external geometry + + + true + + + ShowLinks + + + Mod/Sketcher/General + + + + + + + When opening sketch, show objects the sketch is attached to + + + Show object(s) sketch is attached to + + + true + + + ShowSupport + + + Mod/Sketcher/General + + + + + + + When closing sketch, move camera back to where it was before sketch was opened + + + Restore camera position after editing + + + true + + + RestoreCamera + + + Mod/Sketcher/General + + + + + + + + 0 + 0 + + + + Note: these settings are defaults applied to new sketches. The behavior is remembered for each sketch individually as properties on View tab. + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + + + + + + 0 + 0 + + + + Applies current visibility automation settings to all sketches in open documents + + + Apply to existing sketches + + + + + + + + + + Font size used for labels and constraints + + + px + + + 1 + + + 100 + + + 17 + + + EditSketcherFontSize + + + View + + + + + + + Current sketcher creation tool will remain active after creation + + + Geometry creation "Continue Mode" + + + true + + + ContinuousCreationMode + + + Mod/Sketcher + + + + + + + Grid line pattern + + + + + + + Number of polygons for geometry approximation + + + 50 + + + 1000 + + + SegmentsPerGeometry + + + View + + + + + + + + + + + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+
+ + EditSketcherFontSize + comboBox + dialogOnDistanceConstraint + continueMode + checkBoxTVHideDependent + checkBoxTVShowLinks + checkBoxTVShowSupport + checkBoxTVRestoreCamera + btnTVApply + + + +