From 0ab7a008cf978adfb91cb876acd2f7446efaca02 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 13 Dec 2019 09:56:52 -0400 Subject: [PATCH] Add default... + reset() to field, area & checkbox --- src/qml/Base/HCheckBox.qml | 21 +++++++++++++-------- src/qml/Base/HScrollableTextArea.qml | 9 ++++++++- src/qml/Base/HTextField.qml | 6 ++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/qml/Base/HCheckBox.qml b/src/qml/Base/HCheckBox.qml index 8d7493e6..53cc8503 100644 --- a/src/qml/Base/HCheckBox.qml +++ b/src/qml/Base/HCheckBox.qml @@ -5,17 +5,10 @@ import "../utils.js" as Utils CheckBox { id: box + checked: defaultChecked spacing: theme.spacing padding: 0 - - property alias mainText: mainText - property alias subtitle: subtitleText - - - Behavior on opacity { HOpacityAnimator { factor: 2 } } - - indicator: Rectangle { opacity: box.enabled ? 1 : theme.disabledElementsOpacity + 0.2 implicitWidth: theme.controls.checkBox.boxSize @@ -84,4 +77,16 @@ CheckBox { Layout.fillWidth: true } } + + + property alias mainText: mainText + property alias subtitle: subtitleText + property bool defaultChecked: false + readonly property bool changed: checked !== defaultChecked + + + function reset() { checked = defaultChecked } + + + Behavior on opacity { HOpacityAnimator { factor: 2 } } } diff --git a/src/qml/Base/HScrollableTextArea.qml b/src/qml/Base/HScrollableTextArea.qml index aab6e8fa..88daa392 100644 --- a/src/qml/Base/HScrollableTextArea.qml +++ b/src/qml/Base/HScrollableTextArea.qml @@ -28,14 +28,21 @@ ScrollView { property alias placeholderTextColor: textArea.placeholderTextColor property alias area: textArea property alias text: textArea.text - property var disabledText: null + property var focusItemOnTab: null + property var disabledText: null + property string defaultText: "" + readonly property bool changed: text !== defaultText + + + function reset() { area.clear(); text = defaultText } Behavior on opacity { HOpacityAnimator {} } TextArea { id: textArea + text: defaultText enabled: parent.enabled leftPadding: theme.spacing rightPadding: leftPadding diff --git a/src/qml/Base/HTextField.qml b/src/qml/Base/HTextField.qml index b3dc2a7d..693063fa 100644 --- a/src/qml/Base/HTextField.qml +++ b/src/qml/Base/HTextField.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.12 TextField { id: field + text: defaultText opacity: enabled ? 1 : theme.disabledElementsOpacity selectByMouse: true leftPadding: theme.spacing @@ -62,6 +63,11 @@ TextField { property color focusedBorderColor: theme.controls.textField.focusedBorder property var disabledText: null + property string defaultText: "" + readonly property bool changed: text !== defaultText + + + function reset() { clear(); text = defaultText } Binding on color {