Skip to content

Commit

Permalink
Sketcher: split huge settings page into two pages
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 8, 2020
1 parent 85aeef9 commit 16b2b9a
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 399 deletions.
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/AppSketcherGui.cpp
Expand Up @@ -121,6 +121,7 @@ PyMOD_INIT_FUNC(SketcherGui)
SketcherGui::PropertyConstraintListItem ::init();

(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettings> ( QT_TRANSLATE_NOOP("QObject","Sketcher") );
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettingsDisplay> ( QT_TRANSLATE_NOOP("QObject","Sketcher") );
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettingsColors> ( QT_TRANSLATE_NOOP("QObject","Sketcher") );

// add resources and reloads the translators
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/CMakeLists.txt
Expand Up @@ -62,6 +62,7 @@ set(SketcherGui_UIC_SRCS
SketchMirrorDialog.ui
SketcherSettings.ui
SketcherSettingsColors.ui
SketcherSettingsDisplay.ui
SketchRectangularArrayDialog.ui
SketcherRegularPolygonDialog.ui
)
Expand Down
76 changes: 57 additions & 19 deletions src/Mod/Sketcher/Gui/SketcherSettings.cpp
Expand Up @@ -31,6 +31,7 @@

#include "SketcherSettings.h"
#include "ui_SketcherSettings.h"
#include "ui_SketcherSettingsDisplay.h"
#include "ui_SketcherSettingsColors.h"
#include "TaskSketcherGeneral.h"
#include <Base/Console.h>
Expand All @@ -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<Qt::PenStyle, int> > styles;
styles << qMakePair(Qt::SolidLine, 0xffff)
Expand Down Expand Up @@ -86,53 +134,43 @@ 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());
int pattern = data.toInt();
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);
Expand All @@ -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);
Expand All @@ -154,7 +192,7 @@ void SketcherSettings::changeEvent(QEvent *e)
}
}

void SketcherSettings::onBtnTVApplyClicked(bool)
void SketcherSettingsDisplay::onBtnTVApplyClicked(bool)
{
QString errMsg;
try{
Expand Down
26 changes: 25 additions & 1 deletion src/Mod/Sketcher/Gui/SketcherSettings.h
Expand Up @@ -28,6 +28,7 @@

namespace SketcherGui {
class Ui_SketcherSettings;
class Ui_SketcherSettingsDisplay;
class Ui_SketcherSettingsColors;
class SketcherGeneralWidget;
/**
Expand All @@ -48,11 +49,34 @@ class SketcherSettings : public Gui::Dialog::PreferencePage
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;
};

Expand Down

0 comments on commit 16b2b9a

Please sign in to comment.