From 3b87c6ea2dd854b4f5ce0f7f7af66d0184e9104f Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Thu, 7 Jan 2021 00:42:01 +0100 Subject: [PATCH] kcm/kwinrules: Update values on text edit Previously the text values were updated to the model after `onEditingFinished()`, that is after losing focus, to prevent erroneus updates. This was making also the `needsSaving` signal fire only after a focus change, which is not consistent with the behavior of other KCMs. Use `onTextEdit()` instead, so the model is updated as the user types. BUG: 431211 --- .../kwinrules/package/contents/ui/ValueEditor.qml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml b/src/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml index 5b99d165fc..1a31e9ee2a 100644 --- a/src/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml +++ b/src/kcmkwin/kwinrules/package/contents/ui/ValueEditor.qml @@ -68,14 +68,19 @@ Loader { Component { id: stringEditor QQC2.TextField { + id: stringTextField property bool isTextEdited: false - text: ruleValue horizontalAlignment: Text.AlignLeft - onTextEdited: { isTextEdited = true; } - onEditingFinished: { - if (isTextEdited) { valueEditor.valueEdited(text); } - isTextEdited = false; + onTextEdited: { valueEditor.valueEdited(text); } + Connections { + target: valueEditor + function onRuleValueChanged() { + if (!stringTextField.activeFocus) { // Protects from self-updating when editing + stringTextField.text = valueEditor.ruleValue + } + } } + Component.onCompleted: { this.text = valueEditor.ruleValue } } }