From e43b0bcc1fb9c25b3f8a2052bae3c93bb19c8fc8 Mon Sep 17 00:00:00 2001 From: Shrief Gabr Date: Mon, 5 Feb 2024 13:56:13 +0200 Subject: QmlDesigner: Fix unchangeable data in cells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Changes to the cell data are saved if Return or Enter keys are pressed. Task-number: QDS-11894 Change-Id: Ia3a1ff8f6c9275906736fa1e0638b81c92bea910 Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Henning Gründl --- .../CollectionDetailsEditDelegate.qml | 20 +++++++++++++++++++- .../imports/StudioControls/RealSpinBox.qml | 13 +++++++++++-- .../imports/StudioControls/SpinBox.qml | 12 ++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/share/qtcreator/qmldesigner/collectionEditorQmlSource/CollectionDetailsEditDelegate.qml b/share/qtcreator/qmldesigner/collectionEditorQmlSource/CollectionDetailsEditDelegate.qml index 6a3146a818..90b3021c96 100644 --- a/share/qtcreator/qmldesigner/collectionEditorQmlSource/CollectionDetailsEditDelegate.qml +++ b/share/qtcreator/qmldesigner/collectionEditorQmlSource/CollectionDetailsEditDelegate.qml @@ -91,6 +91,11 @@ Item { realStepSize: 1.0 decimals: 6 trailingZeroes: false + + onActiveFocusChanged: { + if (realField.activeFocus) + realField.contentItem.focus = true + } } } } @@ -112,6 +117,11 @@ Item { from: -2147483647 to: 2147483647 decimals: 0 + + onActiveFocusChanged: { + if (integerField.activeFocus) + integerField.contentItem.focus = true + } } } } @@ -149,7 +159,7 @@ Item { target: editorPopup.editor function onActiveFocusChanged() { - if (!editorPopup.activeFocus) + if (!editorPopup.editor.activeFocus) editorPopup.close() else if (edit) editorPopup.editor.editValue = edit @@ -163,6 +173,14 @@ Item { editorLoader.changesAccepted = false editorPopup.close() } + + function onReturnPressed() { + editorPopup.close() + } + + function onEnterPressed() { + editorPopup.close() + } } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml index 37612af13f..4f51d7aa1f 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml @@ -90,6 +90,11 @@ T.SpinBox { value: 0 to: 99 + function checkAndClearFocus() { + if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus) + control.focus = false + } + validator: DoubleValidator { id: doubleValidator locale: control.locale.name @@ -151,7 +156,7 @@ T.SpinBox { validator: doubleValidator function handleEditingFinished() { - control.focus = false + control.checkAndClearFocus() // Keep the dirty state before calling setValueFromInput(), // it will be set to false (cleared) internally @@ -165,7 +170,11 @@ T.SpinBox { control.compressedRealValueModified() } - onEditingFinished: spinBoxInput.handleEditingFinished() + onEditingFinished: { + spinBoxInput.focus = false + spinBoxInput.handleEditingFinished() + } + onTextEdited: control.dirty = true } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBox.qml index da2a7f1d5d..ffde6e4ad1 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBox.qml @@ -69,6 +69,11 @@ T.SpinBox { editable: true validator: control.decimals ? doubleValidator : intValidator + function checkAndClearFocus() { + if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus) + control.focus = false + } + DoubleValidator { id: doubleValidator locale: control.locale.name @@ -132,7 +137,7 @@ T.SpinBox { __parentControl: control function handleEditingFinished() { - control.focus = false + control.checkAndClearFocus() // Keep the dirty state before calling setValueFromInput(), // it will be set to false (cleared) internally @@ -146,7 +151,10 @@ T.SpinBox { control.compressedValueModified() } - onEditingFinished: spinBoxInput.handleEditingFinished() + onEditingFinished: { + spinBoxInput.focus = false + spinBoxInput.handleEditingFinished() + } } background: Rectangle { -- cgit v1.2.3