From 7801fbef3a4442915c1897f9e8c3b9430373d0a0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 11 Dec 2014 18:25:30 +0100 Subject: [PATCH] + fixes #0001849: Enable Spin Boxes support for Pad, Fillet and Chamfer --- src/Gui/PrefWidgets.cpp | 11 +++++------ src/Gui/PrefWidgets.h | 6 +++--- src/Gui/QuantitySpinBox.h | 2 +- src/Mod/PartDesign/Gui/TaskPadParameters.cpp | 6 +++--- src/Mod/PartDesign/Gui/TaskPadParameters.ui | 10 +++++----- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 2 +- src/Mod/Sketcher/Gui/EditDatumDialog.cpp | 2 +- src/Mod/Sketcher/Gui/InsertDatum.ui | 8 ++++---- src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui | 8 ++++---- 9 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp index 8a6880148..ee34d7ef8 100644 --- a/src/Gui/PrefWidgets.cpp +++ b/src/Gui/PrefWidgets.cpp @@ -519,13 +519,15 @@ void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event) // look what the user has choosen if (saveAction == saveValueAction) { - pushToSavedValues(); + pushToSavedValues(this->text()); } else { int i=0; for (std::vector::const_iterator it = actions.begin();it!=actions.end();++it,i++) { - if (*it == saveAction) + if (*it == saveAction) { lineEdit()->setText(values[i]); + break; + } } } @@ -595,10 +597,7 @@ void PrefQuantitySpinBox::pushToSavedValues(const QString &valueq) { Q_D(PrefQuantitySpinBox); std::string value; - if (valueq.isEmpty()) - value = this->text().toUtf8().constData(); - else - value = valueq.toUtf8().constData(); + value = valueq.toUtf8().constData(); if (d->handle.isValid()) { for (int i = d->saveSize -1 ; i>=0 ;i--) { diff --git a/src/Gui/PrefWidgets.h b/src/Gui/PrefWidgets.h index 284d4e0f6..5217f37fb 100644 --- a/src/Gui/PrefWidgets.h +++ b/src/Gui/PrefWidgets.h @@ -304,11 +304,11 @@ public: /// set the param group path where the widget writes and reads the default values void setParamGrpPath(const QByteArray& name); /// push a new value to the history, if no string given the actual text of the input field is used. - void pushToHistory(const QString &value = QString()); + void pushToHistory(const QString& value = QString()); /// get the history of the field, newest first std::vector getHistory() const; /// push a new value to the history, if no string given the actual text of the input field is used. - void pushToSavedValues(const QString &value = QString()); + void pushToSavedValues(const QString& value); /// get the history of the field, newest first std::vector getSavedValues() const; //@} @@ -317,7 +317,7 @@ protected: virtual void contextMenuEvent(QContextMenuEvent * event); private: - PrefQuantitySpinBoxPrivate * const d_ptr; + QScopedPointer d_ptr; Q_DISABLE_COPY(PrefQuantitySpinBox) Q_DECLARE_PRIVATE(PrefQuantitySpinBox) }; diff --git a/src/Gui/QuantitySpinBox.h b/src/Gui/QuantitySpinBox.h index e03d77e74..e7c6fe58a 100644 --- a/src/Gui/QuantitySpinBox.h +++ b/src/Gui/QuantitySpinBox.h @@ -128,7 +128,7 @@ Q_SIGNALS: void parseError(const QString& errorText); private: - QuantitySpinBoxPrivate * const d_ptr; + QScopedPointer d_ptr; Q_DISABLE_COPY(QuantitySpinBox) Q_DECLARE_PRIVATE(QuantitySpinBox) }; diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 025f3fc1b..281d36374 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -287,7 +287,7 @@ void TaskPadParameters::onModeChanged(int index) case 0: pcPad->Type.setValue("Length"); // Avoid error message - if (ui->lengthEdit->getQuantity().getValue() < Precision::Confusion()) + if (ui->lengthEdit->value().getValue() < Precision::Confusion()) ui->lengthEdit->setValue(5.0); break; case 1: pcPad->Type.setValue("UpToLast"); break; @@ -371,7 +371,7 @@ void TaskPadParameters::onUpdateView(bool on) double TaskPadParameters::getLength(void) const { - return ui->lengthEdit->getQuantity().getValue(); + return ui->lengthEdit->value().getValue(); } bool TaskPadParameters::getReversed(void) const @@ -386,7 +386,7 @@ bool TaskPadParameters::getMidplane(void) const double TaskPadParameters::getLength2(void) const { - return ui->lengthEdit2->getQuantity().getValue(); + return ui->lengthEdit2->value().getValue(); } int TaskPadParameters::getMode(void) const diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.ui b/src/Mod/PartDesign/Gui/TaskPadParameters.ui index c9544c795..aade56ebe 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.ui @@ -44,7 +44,7 @@ - + 0.000000000000000 @@ -88,7 +88,7 @@ - + 0.000000000000000 @@ -141,9 +141,9 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::PrefQuantitySpinBox + QWidget +
Gui/PrefWidgets.h
diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 99ba0b001..4dc2d0a25 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -1578,7 +1578,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg) ui_Datum.labelEdit->selectNumber(); if (dlg.exec() == QDialog::Accepted) { - Base::Quantity newQuant = ui_Datum.labelEdit->getQuantity(); + Base::Quantity newQuant = ui_Datum.labelEdit->value(); double newRadius = newQuant.getValue(); try { diff --git a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp index 8d2b0815c..359504f23 100644 --- a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp +++ b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp @@ -130,7 +130,7 @@ void EditDatumDialog::exec(bool atCursor) dlg.setGeometry(QCursor::pos().x() - dlg.geometry().width() / 2, QCursor::pos().y(), dlg.geometry().width(), dlg.geometry().height()); if (dlg.exec()) { - Base::Quantity newQuant = ui_ins_datum.labelEdit->getQuantity(); + Base::Quantity newQuant = ui_ins_datum.labelEdit->value(); if (newQuant.isQuantity()) { // save the value for the history ui_ins_datum.labelEdit->pushToHistory(); diff --git a/src/Mod/Sketcher/Gui/InsertDatum.ui b/src/Mod/Sketcher/Gui/InsertDatum.ui index e9f3db8c8..93dea8e73 100644 --- a/src/Mod/Sketcher/Gui/InsertDatum.ui +++ b/src/Mod/Sketcher/Gui/InsertDatum.ui @@ -27,7 +27,7 @@
- + @@ -46,9 +46,9 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::PrefQuantitySpinBox + QWidget +
Gui/PrefWidgets.h
diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui index ce257dcbf..fd4ddf16d 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui +++ b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui @@ -34,7 +34,7 @@ - + mm @@ -85,9 +85,9 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::PrefQuantitySpinBox + QWidget +
Gui/PrefWidgets.h