Make image scaling command aware of user units (#7222)
* Image: image scaling command is user unit aware ; fixes #6118 - if unitless value entered, InputField uses user choosen base unit Before change, always used FC core base unit Only applies to GUI user entered values, value changed programmatically still ... ... considered in core base unit if applied unitless
This commit is contained in:
@@ -642,6 +642,19 @@ void InputField::focusInEvent(QFocusEvent *event)
|
||||
|
||||
void InputField::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
try {
|
||||
if (Quantity::parse(this->text()).getUnit().isEmpty()) {
|
||||
// if user didn't enter a unit, we virtually compensate
|
||||
// the multiplication factor induced by user unit system
|
||||
double factor;
|
||||
QString unitStr;
|
||||
actQuantity.getUserString(factor, unitStr);
|
||||
actQuantity = actQuantity * factor;
|
||||
}
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
// do nothing, let apply the last known good value
|
||||
}
|
||||
this->setText(actQuantity.getUserString());
|
||||
QLineEdit::focusOutEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user