Sketcher: Allow user to reset OVP state using backspace key

Currently if user tries to reset OVP, they can only do that by entering
"0" for example, and then the parameters will get unset in
unsetOnViewParameter. But that will only happen if user types a value
that's under confusion point (typically 1e^-7). In my opinion, it would
be cool to reset that state if user deletes all content in the label, to
allow them to specify coordinates with mouse once again.

Also, this patch fixes a regression with backspace, where deleting stuff
from OVP was working on unix systems, but seems like on Windows it
doesn't pass the check.
This commit is contained in:
tetektoza
2025-06-07 21:00:27 +02:00
committed by Kacper Donat
parent e4b1512ae9
commit 6664907bd5
5 changed files with 29 additions and 3 deletions

View File

@@ -186,9 +186,16 @@ void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj, bool
return;
}
isSet = true;
if (!spinBox->hasValidInput()) {
// unset parameters in DrawSketchController, this is needed in a case
// when user removes values we reset state of the OVP
Q_EMIT this->parameterUnset();
return;
}
value = spinBox->rawValue();
isSet = true;
Q_EMIT this->valueChanged(value);
};

View File

@@ -94,6 +94,7 @@ public:
Q_SIGNALS:
void valueChanged(double val);
void parameterUnset();
protected:
bool eventFilter(QObject* watched, QEvent* event) override;

View File

@@ -571,6 +571,11 @@ void QuantitySpinBox::userInput(const QString & text)
}
else {
d->validInput = false;
// we have to emit here signal explicitly as validator will not pass
// this value further but we want to check it to disable isSet flag if
// it has been set previously
Q_EMIT valueChanged(d->quantity.getValue());
return;
}

View File

@@ -618,6 +618,16 @@ protected:
parameter->setColor(colorManager.dimConstrColor);
onViewValueChanged(i, value);
});
// this gets triggered whenever user deletes content in OVP, we remove the
// constraints and unset everything to give user another change to select stuff
// with mouse
QObject::connect(parameter,
&Gui::EditableDatumLabel::parameterUnset,
[this, parameter]() {
unsetOnViewParameter(parameter);
finishControlsChanged();
});
}
}

View File

@@ -101,8 +101,11 @@ void DrawSketchKeyboardManager::detectKeyboardEventHandlingMode(QKeyEvent* keyEv
if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return
|| keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt::Key_Backtab
|| keyEvent->key() == Qt::Key_Minus || keyEvent->key() == Qt::Key_Period
|| keyEvent->key() == Qt::Key_Comma || match.hasMatch()
|| keyEvent->matches(QKeySequence::Backspace) || keyEvent->matches(QKeySequence::Delete)) {
|| keyEvent->key() == Qt::Key_Comma
|| match.hasMatch()
// double check for backspace as there may be windows/unix inconsistencies
|| keyEvent->key() == Qt::Key_Backspace || keyEvent->matches(QKeySequence::Backspace)
|| keyEvent->matches(QKeySequence::Delete)) {
keyMode = KeyboardEventHandlingMode::DSHControl;
timer.start(timeOutValue);
}