diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 0fc346895317..f50800d3a08d 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -350,12 +350,14 @@ Application::Application(bool GUIenabled) throw Base::Exception("Invalid system settings"); } #endif +#if 0 // QuantitySpinBox and InputField try to handle the group separator now // http://forum.freecadweb.org/viewtopic.php?f=10&t=6910 // A workaround is to disable the group separator for double-to-string conversion, i.e. // setting the flag 'OmitGroupSeparator'. QLocale loc = QLocale::system(); loc.setNumberOptions(QLocale::OmitGroupSeparator); QLocale::setDefault(loc); +#endif // setting up Python binding Base::PyGILStateLocker lock; diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 41d6e6ce9536..2a64a610e7b4 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -180,7 +180,9 @@ void InputField::newInput(const QString & text) { Quantity res; try { - res = Quantity::parse(text); + QString input = text; + input.remove(locale().groupSeparator()); + res = Quantity::parse(input); } catch(Base::Exception &e){ ErrorText = e.what(); @@ -524,13 +526,16 @@ void InputField::wheelEvent (QWheelEvent * event) void InputField::fixup(QString& input) const { + input.remove(locale().groupSeparator()); } QValidator::State InputField::validate(QString& input, int& pos) const { try { Quantity res; - res = Quantity::parse(input); + QString text = input; + text.remove(locale().groupSeparator()); + res = Quantity::parse(text); double factor; QString unitStr; diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 4ec7d2a90231..e10aec1d19a3 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -145,7 +145,9 @@ void QuantitySpinBox::userInput(const QString & text) Q_D(QuantitySpinBox); Base::Quantity res; try { - res = Base::Quantity::parse(text); + QString input = text; + input.remove(locale().groupSeparator()); + res = Base::Quantity::parse(input); } catch (Base::Exception &e) { d->errorText = QString::fromAscii(e.what()); @@ -287,7 +289,7 @@ void QuantitySpinBox::stepBy(int steps) else if (val < d->minimum) val = d->minimum; - setValue(val); + lineEdit()->setText(QString::fromUtf8("%L1 %2").arg(val).arg(d->unitStr)); update(); selectNumber(); } @@ -354,6 +356,7 @@ Base::Quantity QuantitySpinBox::valueFromText(const QString &text) const Q_D(const QuantitySpinBox); QString copy = text; + copy.remove(locale().groupSeparator()); int pos = lineEdit()->cursorPosition(); QValidator::State state = QValidator::Acceptable; return d->validateAndInterpret(copy, pos, state); @@ -364,7 +367,9 @@ QValidator::State QuantitySpinBox::validate(QString &text, int &pos) const Q_D(const QuantitySpinBox); QValidator::State state; - d->validateAndInterpret(text, pos, state); + QString copy = text; + copy.remove(locale().groupSeparator()); + d->validateAndInterpret(copy, pos, state); return state; } diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp index 2f10598448a2..ccaf868c6e6d 100644 --- a/src/Gui/resource.cpp +++ b/src/Gui/resource.cpp @@ -47,6 +47,7 @@ #include "DlgCustomizeSpaceball.h" #include "DlgCustomizeSpNavSettings.h" #include "InputField.h" +#include "QuantitySpinBox.h" using namespace Gui; using namespace Gui::Dialog; @@ -100,4 +101,5 @@ WidgetFactorySupplier::WidgetFactorySupplier() new WidgetProducer; new WidgetProducer; new WidgetProducer; + new WidgetProducer; }