diff --git a/share/qtcreator/qmldesigner/edit3dQmlSource/SnapConfigurationDialog.qml b/share/qtcreator/qmldesigner/edit3dQmlSource/SnapConfigurationDialog.qml index 340570ff9b2..43460b7f719 100644 --- a/share/qtcreator/qmldesigner/edit3dQmlSource/SnapConfigurationDialog.qml +++ b/share/qtcreator/qmldesigner/edit3dQmlSource/SnapConfigurationDialog.qml @@ -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 { diff --git a/src/plugins/qmldesigner/components/edit3d/snapconfiguration.cpp b/src/plugins/qmldesigner/components/edit3d/snapconfiguration.cpp index 1412588f902..f1d8889364b 100644 --- a/src/plugins/qmldesigner/components/edit3d/snapconfiguration.cpp +++ b/src/plugins/qmldesigner/components/edit3d/snapconfiguration.cpp @@ -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); - m_view->syncSnapAuxPropsToSettings(); + 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(event); if (keyEvent->key() == Qt::Key_Escape) - apply(); + asyncClose(); } else if (event->type() == QEvent::Close) { apply(); } diff --git a/src/plugins/qmldesigner/components/edit3d/snapconfiguration.h b/src/plugins/qmldesigner/components/edit3d/snapconfiguration.h index b744e63053f..729e6ce7d10 100644 --- a/src/plugins/qmldesigner/components/edit3d/snapconfiguration.h +++ b/src/plugins/qmldesigner/components/edit3d/snapconfiguration.h @@ -90,7 +90,7 @@ protected: bool eventFilter(QObject *obj, QEvent *event) override; private: - void cleanup(); + void asyncClose(); QPointer m_configDialog; QPointer m_view;