From 6ede699fdfa6ac3e6827a012b622efe2e2b796a8 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 17 Mar 2020 17:41:15 -0400 Subject: [PATCH] Fix text area/field disabled text wrapping --- src/gui/Base/HScrollableTextArea.qml | 13 ++++++++++++- src/gui/Base/HTextField.qml | 14 +++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gui/Base/HScrollableTextArea.qml b/src/gui/Base/HScrollableTextArea.qml index 88ed0b26..012a9720 100644 --- a/src/gui/Base/HScrollableTextArea.qml +++ b/src/gui/Base/HScrollableTextArea.qml @@ -87,10 +87,16 @@ ScrollView { when: disabledText !== null && ! textArea.enabled } + Binding on implicitHeight { + value: disabledTextLabel.implicitHeight + when: disabledText !== null && ! textArea.enabled + } + Behavior on color { HColorAnimation {} } Behavior on placeholderTextColor { HColorAnimation {} } HLabel { + id: disabledTextLabel anchors.fill: parent visible: opacity > 0 opacity: disabledText !== null && parent.enabled ? 0 : 1 @@ -101,7 +107,12 @@ ScrollView { topPadding: parent.topPadding bottomPadding: parent.bottomPadding - wrapMode: parent.wrapMode + wrapMode: + parent.wrapMode === TextEdit.Wrap ? Text.Wrap : + parent.wrapMode === TextEdit.WordWrap ? Text.WordWrap : + parent.wrapMode === TextEdit.WrapAnywhere ? Text.WrapAnywhere : + Text.NoWrap + font.family: parent.font.family font.pixelSize: parent.font.pixelSize diff --git a/src/gui/Base/HTextField.qml b/src/gui/Base/HTextField.qml index c2acbf0e..3edd5f51 100644 --- a/src/gui/Base/HTextField.qml +++ b/src/gui/Base/HTextField.qml @@ -83,11 +83,18 @@ TextField { when: disabledText !== null && ! field.enabled } + Binding on implicitHeight { + value: disabledTextLabel.implicitHeight + when: disabledText !== null && ! textArea.enabled + } + + Behavior on opacity { HNumberAnimation {} } Behavior on color { HColorAnimation {} } Behavior on placeholderTextColor { HColorAnimation {} } HLabel { + id: disabledTextLabel anchors.fill: parent visible: opacity > 0 opacity: disabledText !== null && parent.enabled ? 0 : 1 @@ -98,7 +105,12 @@ TextField { topPadding: parent.topPadding bottomPadding: parent.bottomPadding - wrapMode: parent.wrapMode + wrapMode: + parent.wrapMode === TextField.Wrap ? Text.Wrap : + parent.wrapMode === TextField.WordWrap ? Text.WordWrap : + parent.wrapMode === TextField.WrapAnywhere ? Text.WrapAnywhere : + Text.NoWrap + font.family: parent.font.family font.pixelSize: parent.font.pixelSize