Implement HLabeledItem loading mode
This commit is contained in:
parent
da4a5ab5cd
commit
470b0f0de2
|
@ -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 {
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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)}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user