Sketcher: Remove grid settings from Edit Control widget.

This commit is contained in:
Paddle
2022-11-20 22:23:13 +01:00
committed by abdullahtahiriyo
parent 0a78933685
commit 7f18faae7d
3 changed files with 3 additions and 178 deletions

View File

@@ -45,12 +45,6 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
ui->renderingOrder->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
// connecting the needed signals
connect(ui->checkBoxShowGrid, &QCheckBox::toggled,
this, &SketcherGeneralWidget::emitToggleGridView);
connect(ui->checkBoxGridSnap, &QCheckBox::toggled,
this, &SketcherGeneralWidget::emitToggleGridSnap);
connect(ui->gridSize, qOverload<double>(&Gui::PrefQuantitySpinBox::valueChanged),
this, &SketcherGeneralWidget::emitSetGridSize);
connect(ui->checkBoxAutoconstraints, &QCheckBox::toggled,
this, &SketcherGeneralWidget::emitToggleAutoconstraints);
connect(ui->checkBoxRedundantAutoconstraints, &QCheckBox::toggled,
@@ -72,9 +66,6 @@ bool SketcherGeneralWidget::eventFilter(QObject *object, QEvent *event)
void SketcherGeneralWidget::saveSettings()
{
ui->checkBoxShowGrid->onSave();
ui->gridSize->onSave();
ui->checkBoxGridSnap->onSave();
ui->checkBoxAutoconstraints->onSave();
ui->checkBoxRedundantAutoconstraints->onSave();
@@ -95,10 +86,6 @@ void SketcherGeneralWidget::saveOrderingOrder()
void SketcherGeneralWidget::loadSettings()
{
ui->checkBoxShowGrid->onRestore();
ui->gridSize->onRestore();
if (ui->gridSize->rawValue() == 0) { ui->gridSize->setValue(10.0); }
ui->checkBoxGridSnap->onRestore();
ui->checkBoxAutoconstraints->onRestore();
ui->checkBoxRedundantAutoconstraints->onRestore();
@@ -135,21 +122,6 @@ void SketcherGeneralWidget::loadOrderingOrder()
}
}
void SketcherGeneralWidget::setGridSize(double val)
{
ui->gridSize->setValue(Base::Quantity(val,Base::Unit::Length));
}
void SketcherGeneralWidget::checkGridView(bool on)
{
ui->checkBoxShowGrid->setChecked(on);
}
void SketcherGeneralWidget::checkGridSnap(bool on)
{
ui->checkBoxGridSnap->setChecked(on);
}
void SketcherGeneralWidget::checkAutoconstraints(bool on)
{
ui->checkBoxAutoconstraints->setChecked(on);
@@ -160,12 +132,6 @@ void SketcherGeneralWidget::checkAvoidRedundant(bool on)
ui->checkBoxRedundantAutoconstraints->setChecked(on);
}
void SketcherGeneralWidget::enableGridSettings(bool on)
{
ui->gridSize->setEnabled(on);
ui->checkBoxGridSnap->setEnabled(on);
}
void SketcherGeneralWidget::enableAvoidRedundant(bool on)
{
ui->checkBoxRedundantAutoconstraints->setEnabled(on);
@@ -188,44 +154,23 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
// we need a separate container widget to add all controls to
widget = new SketcherGeneralWidget(this);
this->groupLayout()->addWidget(widget);
{
//Blocker probably not needed as signals aren't connected yet
QSignalBlocker block(widget);
//Load default settings to get ordering order & avoid redundant values
widget->loadSettings();
widget->checkGridView(sketchView->ShowGrid.getValue());
if (sketchView->GridSize.getValue() > 0) {
widget->setGridSize(sketchView->GridSize.getValue());
}
widget->checkGridSnap(sketchView->GridSnap.getValue());
widget->enableGridSettings(sketchView->ShowGrid.getValue());
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue());
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
}
// connecting the needed signals
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleGridView,
this , &TaskSketcherGeneral::onToggleGridView
);
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleGridSnap,
this , &TaskSketcherGeneral::onToggleGridSnap
);
QObject::connect(
widget, &SketcherGeneralWidget::emitSetGridSize,
this , &TaskSketcherGeneral::onSetGridSize
);
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleAutoconstraints,
this , &TaskSketcherGeneral::onToggleAutoconstraints
);
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleAvoidRedundant,
this , &TaskSketcherGeneral::onToggleAvoidRedundant
@@ -252,20 +197,7 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
const App::Property& prop)
{
if (sketchView == &vp) {
if (&sketchView->ShowGrid == &prop) {
QSignalBlocker block(widget);
widget->checkGridView(sketchView->ShowGrid.getValue());
widget->enableGridSettings(sketchView->ShowGrid.getValue());
}
else if (&sketchView->GridSize == &prop) {
QSignalBlocker block(widget);
widget->setGridSize(sketchView->GridSize.getValue());
}
else if (&sketchView->GridSnap == &prop) {
QSignalBlocker block(widget);
widget->checkGridSnap(sketchView->GridSnap.getValue());
}
else if (&sketchView->Autoconstraints == &prop) {
if (&sketchView->Autoconstraints == &prop) {
QSignalBlocker block(widget);
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
@@ -277,26 +209,6 @@ void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
}
}
void TaskSketcherGeneral::onToggleGridView(bool on)
{
Base::ConnectionBlocker block(changedSketchView);
sketchView->ShowGrid.setValue(on);
widget->enableGridSettings(on);
}
void TaskSketcherGeneral::onSetGridSize(double val)
{
Base::ConnectionBlocker block(changedSketchView);
if (val > 0)
sketchView->GridSize.setValue(val);
}
void TaskSketcherGeneral::onToggleGridSnap(bool on)
{
Base::ConnectionBlocker block(changedSketchView);
sketchView->GridSnap.setValue(on);
}
void TaskSketcherGeneral::onToggleAutoconstraints(bool on)
{
Base::ConnectionBlocker block(changedSketchView);

View File

@@ -56,18 +56,11 @@ public:
void saveOrderingOrder();
void loadSettings();
void loadOrderingOrder();
void setGridSize(double val);
void checkGridView(bool);
void checkGridSnap(bool);
void checkAutoconstraints(bool);
void checkAvoidRedundant(bool);
void enableGridSettings(bool);
void enableAvoidRedundant(bool);
Q_SIGNALS:
void emitToggleGridView(bool);
void emitToggleGridSnap(bool);
void emitSetGridSize(double);
void emitToggleAutoconstraints(bool);
void emitToggleAvoidRedundant(bool);
void emitRenderOrderChanged();
@@ -92,9 +85,6 @@ public:
Gui::SelectionSingleton::MessageType Reason) override;
public Q_SLOTS:
void onToggleGridView(bool on);
void onSetGridSize(double val);
void onToggleGridSnap(bool on);
void onToggleAutoconstraints(bool on);
void onToggleAvoidRedundant(bool);
void onRenderOrderChanged();

View File

@@ -14,83 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxShowGrid">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>A grid will be shown</string>
</property>
<property name="text">
<string>Grid</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowGrid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefQuantitySpinBox" name="gridSize">
<property name="toolTip">
<string>Distance between two subsequent grid lines</string>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="minimum">
<double>0.001000000000000</double>
</property>
<property name="maximum">
<double>99999999.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>GridSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General/GridSize</cstring>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxGridSnap">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>New points will snap to the nearest grid line.
Points must be set closer than a fifth of the grid size to a grid line to snap.</string>
</property>
<property name="text">
<string>Grid snap</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>GridSnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxAutoconstraints">
<property name="enabled">