[Sketcher] Move general settings widget enable/disable logic in TaskSketcherGeneral so ...
... all options are freely accessible in the preferences editor ... ... eg. no need to check 'Show Grid' to customize grid size or snap Also remove the sparse automatical saving to preferences from sketcher Task pane ... ... (some settings were saved, some not)
This commit is contained in:
committed by
abdullahtahiriyo
parent
3528429363
commit
fece0f2dfc
@@ -53,13 +53,13 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
|
||||
|
||||
// connecting the needed signals
|
||||
connect(ui->checkBoxShowGrid, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onToggleGridView(bool)));
|
||||
connect(ui->checkBoxGridSnap, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(onToggleGridSnap(int)));
|
||||
this, SIGNAL(emitToggleGridView(bool)));
|
||||
connect(ui->checkBoxGridSnap, SIGNAL(toggled(bool)),
|
||||
this, SIGNAL(emitToggleGridSnap(bool)));
|
||||
connect(ui->gridSize, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onSetGridSize(double)));
|
||||
connect(ui->checkBoxAutoconstraints, SIGNAL(stateChanged(int)),
|
||||
this, SIGNAL(emitToggleAutoconstraints(int)));
|
||||
this, SIGNAL(emitSetGridSize(double)));
|
||||
connect(ui->checkBoxAutoconstraints, SIGNAL(toggled(bool)),
|
||||
this, SIGNAL(emitToggleAutoconstraints(bool)));
|
||||
ui->renderingOrder->installEventFilter(this);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ SketcherGeneralWidget::~SketcherGeneralWidget()
|
||||
bool SketcherGeneralWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if (object == ui->renderingOrder && event->type() == QEvent::ChildRemoved) {
|
||||
onRenderOrderChanged();
|
||||
emitRenderOrderChanged();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -160,36 +160,16 @@ void SketcherGeneralWidget::checkAutoconstraints(bool on)
|
||||
ui->checkBoxAutoconstraints->setChecked(on);
|
||||
}
|
||||
|
||||
bool SketcherGeneralWidget::isGridViewChecked() const
|
||||
void SketcherGeneralWidget::enableGridSettings(bool on)
|
||||
{
|
||||
return ui->checkBoxShowGrid->isChecked();
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::saveGridViewChecked()
|
||||
{
|
||||
// only save this setting
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher/General");
|
||||
hGrp->SetBool("ShowGrid", ui->checkBoxShowGrid->isChecked());
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::onToggleGridView(bool on)
|
||||
{
|
||||
checkGridView(on);
|
||||
ui->label->setEnabled(on);
|
||||
ui->gridSize->setEnabled(on);
|
||||
ui->checkBoxGridSnap->setEnabled(on);
|
||||
emitToggleGridView(on);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::onSetGridSize(double val)
|
||||
void SketcherGeneralWidget::enableAvoidRedundant(bool on)
|
||||
{
|
||||
emitSetGridSize(val);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::onToggleGridSnap(int state)
|
||||
{
|
||||
emitToggleGridSnap(state);
|
||||
ui->checkBoxRedundantAutoconstraints->setEnabled(on);
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::changeEvent(QEvent *e)
|
||||
@@ -200,16 +180,6 @@ void SketcherGeneralWidget::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::onRenderOrderChanged()
|
||||
{
|
||||
emitRenderOrderChanged();
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::on_checkBoxRedundantAutoconstraints_stateChanged(int /*state*/)
|
||||
{
|
||||
ui->checkBoxRedundantAutoconstraints->onSave();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
@@ -227,8 +197,8 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
widget, SIGNAL(emitToggleGridSnap(int)),
|
||||
this , SLOT (onToggleGridSnap(int))
|
||||
widget, SIGNAL(emitToggleGridSnap(bool)),
|
||||
this , SLOT (onToggleGridSnap(bool))
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
@@ -237,8 +207,8 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
widget, SIGNAL(emitToggleAutoconstraints(int)),
|
||||
this , SLOT (onToggleAutoconstraints(int))
|
||||
widget, SIGNAL(emitToggleAutoconstraints(bool)),
|
||||
this , SLOT (onToggleAutoconstraints(bool))
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
@@ -266,6 +236,9 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
|
||||
if (&sketchView->ShowGrid == &prop) {
|
||||
QSignalBlocker block(widget);
|
||||
widget->checkGridView(sketchView->ShowGrid.getValue());
|
||||
widget->enableGridSettings(sketchView->ShowGrid.getValue());
|
||||
if (sketchView->ShowGrid.getValue()) {
|
||||
sketchView->createGrid();
|
||||
}
|
||||
else if (&sketchView->GridSize == &prop) {
|
||||
QSignalBlocker block(widget);
|
||||
@@ -278,6 +251,7 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
|
||||
else if (&sketchView->Autoconstraints == &prop) {
|
||||
QSignalBlocker block(widget);
|
||||
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
|
||||
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,7 +260,7 @@ void TaskSketcherGeneral::onToggleGridView(bool on)
|
||||
{
|
||||
Base::ConnectionBlocker block(changedSketchView);
|
||||
sketchView->ShowGrid.setValue(on);
|
||||
widget->saveGridViewChecked();
|
||||
widget->enableGridSettings(on);
|
||||
}
|
||||
|
||||
void TaskSketcherGeneral::onSetGridSize(double val)
|
||||
@@ -296,16 +270,17 @@ void TaskSketcherGeneral::onSetGridSize(double val)
|
||||
sketchView->GridSize.setValue(val);
|
||||
}
|
||||
|
||||
void TaskSketcherGeneral::onToggleGridSnap(int state)
|
||||
void TaskSketcherGeneral::onToggleGridSnap(bool on)
|
||||
{
|
||||
Base::ConnectionBlocker block(changedSketchView);
|
||||
sketchView->GridSnap.setValue(state == Qt::Checked);
|
||||
sketchView->GridSnap.setValue(on);
|
||||
}
|
||||
|
||||
void TaskSketcherGeneral::onToggleAutoconstraints(int state)
|
||||
void TaskSketcherGeneral::onToggleAutoconstraints(bool on)
|
||||
{
|
||||
Base::ConnectionBlocker block(changedSketchView);
|
||||
sketchView->Autoconstraints.setValue(state == Qt::Checked);
|
||||
sketchView->Autoconstraints.setValue(on);
|
||||
widget->enableAvoidRedundant(on);
|
||||
}
|
||||
|
||||
/// @cond DOXERR
|
||||
@@ -324,6 +299,7 @@ void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller
|
||||
|
||||
void TaskSketcherGeneral::onRenderOrderChanged()
|
||||
{
|
||||
widget->saveOrderingOrder();
|
||||
sketchView->updateColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,24 +60,16 @@ public:
|
||||
void checkGridView(bool);
|
||||
void checkGridSnap(bool);
|
||||
void checkAutoconstraints(bool);
|
||||
|
||||
bool isGridViewChecked() const;
|
||||
void saveGridViewChecked();
|
||||
void enableGridSettings(bool);
|
||||
void enableAvoidRedundant(bool);
|
||||
|
||||
Q_SIGNALS:
|
||||
void emitToggleGridView(bool);
|
||||
void emitToggleGridSnap(int);
|
||||
void emitToggleGridSnap(bool);
|
||||
void emitSetGridSize(double);
|
||||
void emitToggleAutoconstraints(int);
|
||||
void emitToggleAutoconstraints(bool);
|
||||
void emitRenderOrderChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onToggleGridView(bool on);
|
||||
void onSetGridSize(double val);
|
||||
void onToggleGridSnap(int state);
|
||||
void onRenderOrderChanged();
|
||||
void on_checkBoxRedundantAutoconstraints_stateChanged(int);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
@@ -100,8 +92,8 @@ public:
|
||||
public Q_SLOTS:
|
||||
void onToggleGridView(bool on);
|
||||
void onSetGridSize(double val);
|
||||
void onToggleGridSnap(int state);
|
||||
void onToggleAutoconstraints(int state);
|
||||
void onToggleGridSnap(bool on);
|
||||
void onToggleAutoconstraints(bool on);
|
||||
void onRenderOrderChanged();
|
||||
|
||||
private:
|
||||
|
||||
@@ -142,7 +142,7 @@ Points must be set closer than a fifth of the grid size to a grid line to snap.<
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Rendering order:</string>
|
||||
<string>Rendering order (global) :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -2599,7 +2599,7 @@ void ViewProviderSketch::updateColor(void)
|
||||
//int32_t *index = edit->CurveSet->numVertices.startEditing();
|
||||
SbVec3f *pverts = edit->PointsCoordinate->point.startEditing();
|
||||
|
||||
ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
|
||||
// 1->Normal Geometry, 2->Construction, 3->External
|
||||
int topid = hGrpp->GetInt("TopRenderGeometryId",1);
|
||||
|
||||
Reference in New Issue
Block a user