diff --git a/src/gui/Base/HLabeledItem.qml b/src/gui/Base/HLabeledItem.qml index c81ef800..b36968d5 100644 --- a/src/gui/Base/HLabeledItem.qml +++ b/src/gui/Base/HLabeledItem.qml @@ -9,6 +9,8 @@ HColumnLayout { default property alias insideData: itemHolder.data + property bool loading: false + readonly property Item item: itemHolder.children[0] readonly property alias label: label readonly property alias errorLabel: errorLabel @@ -16,7 +18,7 @@ HColumnLayout { HRowLayout { - spacing: parent.spacing + spacing: theme.spacing HLabel { id: label @@ -51,6 +53,17 @@ HColumnLayout { id: toolTip visible: toolTip.text && hoverHandler.hovered } + + HLoader { + source: "HBusyIndicator.qml" + active: loading + visible: height > 0 + + Layout.preferredWidth: height + Layout.preferredHeight: active ? label.height : 0 + + Behavior on Layout.preferredHeight { HNumberAnimation {} } + } } Item { diff --git a/src/gui/Base/HTextArea.qml b/src/gui/Base/HTextArea.qml index 1ab98931..999a0f9f 100644 --- a/src/gui/Base/HTextArea.qml +++ b/src/gui/Base/HTextArea.qml @@ -25,6 +25,8 @@ TextArea { property color errorBorder: theme.controls.textArea.errorBorder property color focusedBorderColor: theme.controls.textArea.focusedBorder + property string previousDefaultText: "" // private + function reset() { clear(); text = Qt.binding(() => defaultText) } function insertAtCursor(text) { insert(cursorPosition, text) } @@ -62,17 +64,28 @@ TextArea { } } - // Set it only on component creation to avoid binding loops - Component.onCompleted: if (! text) { - text = window.getState(this, "text", "") - textArea.cursorPosition = text.length + Component.onCompleted: { + // Break binding + previousDefaultText = previousDefaultText + + // Set it only on component creation to avoid binding loops + if (! text) { + text = window.getState(this, "text", "") + cursorPosition = text.length + } } - onActiveFocusChanged: - text = activeFocus || changed ? text : Qt.binding(() => defaultText) - onTextChanged: window.saveState(this) + onActiveFocusChanged: text = text // Break binding + + onDefaultTextChanged: { + if (text === previousDefaultText) + text = Qt.binding(() => defaultText) + + previousDefaultText = defaultText + } + // Prevent alt/super+any key from typing text Keys.onPressed: if ( event.modifiers & Qt.AltModifier || diff --git a/src/gui/Base/HTextField.qml b/src/gui/Base/HTextField.qml index fcb66e93..99a0d46a 100644 --- a/src/gui/Base/HTextField.qml +++ b/src/gui/Base/HTextField.qml @@ -37,16 +37,27 @@ TextField { } } - // Set it only on component creation to avoid binding loops - Component.onCompleted: if (! text) { - text = window.getState(this, "text", "") - cursorPosition = text.length + Component.onCompleted: { + // Break binding + previousDefaultText = previousDefaultText + + // Set it only on component creation to avoid binding loops + if (! text) { + text = window.getState(this, "text", "") + cursorPosition = text.length + } } onTextChanged: window.saveState(this) - onActiveFocusChanged: - text = activeFocus || changed ? text : Qt.binding(() => defaultText) + onActiveFocusChanged: text = text // Break binding + + onDefaultTextChanged: { + if (text === previousDefaultText) + text = Qt.binding(() => defaultText) + + previousDefaultText = defaultText + } // Prevent alt/super+any key from typing text Keys.onPressed: if ( @@ -81,6 +92,8 @@ TextField { property string defaultText: "" readonly property bool changed: text !== defaultText + property string previousDefaultText: "" // private + function reset() { clear(); text = Qt.binding(() => defaultText)}