QmlDesigner: Fix unchangeable data in cells

* 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 <ci_patchbuild_bot@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Shrief Gabr
2024-02-05 13:56:13 +02:00
parent 3e70980279
commit e43b0bcc1f
3 changed files with 40 additions and 5 deletions

View File

@@ -91,6 +91,11 @@ Item {
realStepSize: 1.0 realStepSize: 1.0
decimals: 6 decimals: 6
trailingZeroes: false trailingZeroes: false
onActiveFocusChanged: {
if (realField.activeFocus)
realField.contentItem.focus = true
}
} }
} }
} }
@@ -112,6 +117,11 @@ Item {
from: -2147483647 from: -2147483647
to: 2147483647 to: 2147483647
decimals: 0 decimals: 0
onActiveFocusChanged: {
if (integerField.activeFocus)
integerField.contentItem.focus = true
}
} }
} }
} }
@@ -149,7 +159,7 @@ Item {
target: editorPopup.editor target: editorPopup.editor
function onActiveFocusChanged() { function onActiveFocusChanged() {
if (!editorPopup.activeFocus) if (!editorPopup.editor.activeFocus)
editorPopup.close() editorPopup.close()
else if (edit) else if (edit)
editorPopup.editor.editValue = edit editorPopup.editor.editValue = edit
@@ -163,6 +173,14 @@ Item {
editorLoader.changesAccepted = false editorLoader.changesAccepted = false
editorPopup.close() editorPopup.close()
} }
function onReturnPressed() {
editorPopup.close()
}
function onEnterPressed() {
editorPopup.close()
}
} }
} }

View File

@@ -90,6 +90,11 @@ T.SpinBox {
value: 0 value: 0
to: 99 to: 99
function checkAndClearFocus() {
if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus)
control.focus = false
}
validator: DoubleValidator { validator: DoubleValidator {
id: doubleValidator id: doubleValidator
locale: control.locale.name locale: control.locale.name
@@ -151,7 +156,7 @@ T.SpinBox {
validator: doubleValidator validator: doubleValidator
function handleEditingFinished() { function handleEditingFinished() {
control.focus = false control.checkAndClearFocus()
// Keep the dirty state before calling setValueFromInput(), // Keep the dirty state before calling setValueFromInput(),
// it will be set to false (cleared) internally // it will be set to false (cleared) internally
@@ -165,7 +170,11 @@ T.SpinBox {
control.compressedRealValueModified() control.compressedRealValueModified()
} }
onEditingFinished: spinBoxInput.handleEditingFinished() onEditingFinished: {
spinBoxInput.focus = false
spinBoxInput.handleEditingFinished()
}
onTextEdited: control.dirty = true onTextEdited: control.dirty = true
} }

View File

@@ -69,6 +69,11 @@ T.SpinBox {
editable: true editable: true
validator: control.decimals ? doubleValidator : intValidator validator: control.decimals ? doubleValidator : intValidator
function checkAndClearFocus() {
if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus)
control.focus = false
}
DoubleValidator { DoubleValidator {
id: doubleValidator id: doubleValidator
locale: control.locale.name locale: control.locale.name
@@ -132,7 +137,7 @@ T.SpinBox {
__parentControl: control __parentControl: control
function handleEditingFinished() { function handleEditingFinished() {
control.focus = false control.checkAndClearFocus()
// Keep the dirty state before calling setValueFromInput(), // Keep the dirty state before calling setValueFromInput(),
// it will be set to false (cleared) internally // it will be set to false (cleared) internally
@@ -146,7 +151,10 @@ T.SpinBox {
control.compressedValueModified() control.compressedValueModified()
} }
onEditingFinished: spinBoxInput.handleEditingFinished() onEditingFinished: {
spinBoxInput.focus = false
spinBoxInput.handleEditingFinished()
}
} }
background: Rectangle { background: Rectangle {