Improve HScrollableTextArea disabled handling

Don't hide text if no disabledText is explicitely set, set opacity
using theme.disableElementsOpacity
This commit is contained in:
miruka 2019-12-13 06:22:09 -04:00
parent 2ca79a212f
commit 4cd4386abe
2 changed files with 9 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
ScrollView { ScrollView {
id: scrollView id: scrollView
opacity: enabled ? 1 : theme.disabledElementsOpacity
clip: true clip: true
ScrollBar.vertical.visible: contentHeight > height ScrollBar.vertical.visible: contentHeight > height
@ -27,11 +28,12 @@ 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 string disabledText: "" property var disabledText: null
property string disabledTextColor: theme.controls.textArea.disabledText
property var focusItemOnTab: null property var focusItemOnTab: null
Behavior on opacity { HOpacityAnimator {} }
TextArea { TextArea {
id: textArea id: textArea
enabled: parent.enabled enabled: parent.enabled
@ -64,14 +66,15 @@ ScrollView {
KeyNavigation.priority: KeyNavigation.BeforeItem KeyNavigation.priority: KeyNavigation.BeforeItem
KeyNavigation.tab: focusItemOnTab KeyNavigation.tab: focusItemOnTab
Binding on color { Binding on color {
value: "transparent" value: "transparent"
when: ! textArea.enabled when: disabledText !== null && ! textArea.enabled
} }
Binding on placeholderTextColor { Binding on placeholderTextColor {
value: "transparent" value: "transparent"
when: ! textArea.enabled when: disabledText !== null && ! textArea.enabled
} }
Behavior on color { HColorAnimation {} } Behavior on color { HColorAnimation {} }
@ -80,9 +83,8 @@ ScrollView {
HLabel { HLabel {
anchors.fill: parent anchors.fill: parent
visible: opacity > 0 visible: opacity > 0
opacity: parent.enabled ? 0 : 1 opacity: disabledText !== null && parent.enabled ? 0 : 1
color: disabledTextColor text: disabledText || ""
text: disabledText
leftPadding: parent.leftPadding leftPadding: parent.leftPadding
rightPadding: parent.rightPadding rightPadding: parent.rightPadding

View File

@ -171,13 +171,11 @@ controls:
color text: colors.text color text: colors.text
color focusedText: colors.text color focusedText: colors.text
color placeholderText: colors.dimText color placeholderText: colors.dimText
color disabledText: colors.dimText
textArea: textArea:
color background: colors.inputBackground color background: colors.inputBackground
color text: colors.text color text: colors.text
color placeholderText: controls.textField.placeholderText color placeholderText: controls.textField.placeholderText
color disabledText: controls.textField.disabledText
toolTip: toolTip:
int delay: 500 int delay: 500