QmlDesigner: Ensure we save the latest values on 3D snap dialog close

Track value property of spin boxes changes directly instead of the
extra valueModified signal, which is not emitted in all cases.

Also removed duplicate applying of snap configuration.

Fixes: QDS-10653
Change-Id: If0ce7bffa1dcfb5b01e80b6e962f356f91f44d51
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-09-15 16:06:14 +03:00
parent 1a88cf1446
commit 516a2238e2
3 changed files with 16 additions and 16 deletions

View File

@@ -132,7 +132,7 @@ Rectangle {
ToolTip.text: qsTr("Snap interval for move gizmo.")
ToolTip.delay: root.toolTipDelay
onValueModified: posInt = value
onValueChanged: posInt = value
}
StudioControls.CheckBox {
@@ -167,7 +167,7 @@ Rectangle {
ToolTip.text: qsTr("Snap interval in degrees for rotation gizmo.")
ToolTip.delay: root.toolTipDelay
onValueModified: rotInt = value
onValueChanged: rotInt = value
}
StudioControls.CheckBox {
@@ -202,7 +202,7 @@ Rectangle {
ToolTip.text: qsTr("Snap interval for scale gizmo in percentage of original scale.")
ToolTip.delay: root.toolTipDelay
onValueModified: scaleInt = value
onValueChanged: scaleInt = value
}
StudioControls.CheckBox {

View File

@@ -47,7 +47,8 @@ SnapConfiguration::SnapConfiguration(Edit3DView *view)
SnapConfiguration::~SnapConfiguration()
{
cleanup();
delete m_configDialog;
restoreCursor();
}
void SnapConfiguration::apply()
@@ -67,12 +68,10 @@ void SnapConfiguration::apply()
m_rotationInterval);
Edit3DViewConfig::save(DesignerSettingsKey::EDIT3DVIEW_SNAP_SCALE_INTERVAL,
m_scaleInterval);
if (!m_view.isNull())
m_view->syncSnapAuxPropsToSettings();
}
restoreCursor();
cancel();
deleteLater();
}
void SnapConfiguration::resetDefaults()
@@ -234,9 +233,12 @@ void SnapConfiguration::setScaleInt(double value)
}
}
void SnapConfiguration::cleanup()
void SnapConfiguration::asyncClose()
{
delete m_configDialog;
QTimer::singleShot(0, this, [this]() {
if (!m_configDialog.isNull() && m_configDialog->isVisible())
m_configDialog->close();
});
}
void SnapConfiguration::cancel()
@@ -249,15 +251,13 @@ void SnapConfiguration::cancel()
bool SnapConfiguration::eventFilter(QObject *obj, QEvent *event)
{
// Closing dialog always applies the changes
if (obj == m_configDialog) {
if (event->type() == QEvent::FocusOut) {
apply();
asyncClose();
} else if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape)
apply();
asyncClose();
} else if (event->type() == QEvent::Close) {
apply();
}

View File

@@ -90,7 +90,7 @@ protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
void cleanup();
void asyncClose();
QPointer<QQuickView> m_configDialog;
QPointer<Edit3DView> m_view;