Add default... + reset() to field, area & checkbox

This commit is contained in:
miruka 2019-12-13 09:56:52 -04:00
parent 407396e01e
commit 0ab7a008cf
3 changed files with 27 additions and 9 deletions

View File

@ -5,17 +5,10 @@ import "../utils.js" as Utils
CheckBox { CheckBox {
id: box id: box
checked: defaultChecked
spacing: theme.spacing spacing: theme.spacing
padding: 0 padding: 0
property alias mainText: mainText
property alias subtitle: subtitleText
Behavior on opacity { HOpacityAnimator { factor: 2 } }
indicator: Rectangle { indicator: Rectangle {
opacity: box.enabled ? 1 : theme.disabledElementsOpacity + 0.2 opacity: box.enabled ? 1 : theme.disabledElementsOpacity + 0.2
implicitWidth: theme.controls.checkBox.boxSize implicitWidth: theme.controls.checkBox.boxSize
@ -84,4 +77,16 @@ CheckBox {
Layout.fillWidth: true 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 } }
} }

View File

@ -28,14 +28,21 @@ ScrollView {
property alias placeholderTextColor: textArea.placeholderTextColor property alias placeholderTextColor: textArea.placeholderTextColor
property alias area: textArea property alias area: textArea
property alias text: textArea.text property alias text: textArea.text
property var disabledText: null
property var focusItemOnTab: 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 {} } Behavior on opacity { HOpacityAnimator {} }
TextArea { TextArea {
id: textArea id: textArea
text: defaultText
enabled: parent.enabled enabled: parent.enabled
leftPadding: theme.spacing leftPadding: theme.spacing
rightPadding: leftPadding rightPadding: leftPadding

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.12
TextField { TextField {
id: field id: field
text: defaultText
opacity: enabled ? 1 : theme.disabledElementsOpacity opacity: enabled ? 1 : theme.disabledElementsOpacity
selectByMouse: true selectByMouse: true
leftPadding: theme.spacing leftPadding: theme.spacing
@ -62,6 +63,11 @@ TextField {
property color focusedBorderColor: theme.controls.textField.focusedBorder property color focusedBorderColor: theme.controls.textField.focusedBorder
property var disabledText: null property var disabledText: null
property string defaultText: ""
readonly property bool changed: text !== defaultText
function reset() { clear(); text = defaultText }
Binding on color { Binding on color {