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

View File

@@ -47,7 +47,8 @@ SnapConfiguration::SnapConfiguration(Edit3DView *view)
SnapConfiguration::~SnapConfiguration() SnapConfiguration::~SnapConfiguration()
{ {
cleanup(); delete m_configDialog;
restoreCursor();
} }
void SnapConfiguration::apply() void SnapConfiguration::apply()
@@ -67,12 +68,10 @@ void SnapConfiguration::apply()
m_rotationInterval); m_rotationInterval);
Edit3DViewConfig::save(DesignerSettingsKey::EDIT3DVIEW_SNAP_SCALE_INTERVAL, Edit3DViewConfig::save(DesignerSettingsKey::EDIT3DVIEW_SNAP_SCALE_INTERVAL,
m_scaleInterval); m_scaleInterval);
m_view->syncSnapAuxPropsToSettings(); if (!m_view.isNull())
m_view->syncSnapAuxPropsToSettings();
} }
deleteLater();
restoreCursor();
cancel();
} }
void SnapConfiguration::resetDefaults() 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() void SnapConfiguration::cancel()
@@ -249,15 +251,13 @@ void SnapConfiguration::cancel()
bool SnapConfiguration::eventFilter(QObject *obj, QEvent *event) bool SnapConfiguration::eventFilter(QObject *obj, QEvent *event)
{ {
// Closing dialog always applies the changes
if (obj == m_configDialog) { if (obj == m_configDialog) {
if (event->type() == QEvent::FocusOut) { if (event->type() == QEvent::FocusOut) {
apply(); asyncClose();
} else if (event->type() == QEvent::KeyPress) { } else if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape) if (keyEvent->key() == Qt::Key_Escape)
apply(); asyncClose();
} else if (event->type() == QEvent::Close) { } else if (event->type() == QEvent::Close) {
apply(); apply();
} }

View File

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