Unify text field/area focus line into a component

This commit is contained in:
miruka 2020-06-23 08:44:58 -04:00
parent 8b0f408f34
commit 07013d0ed4
3 changed files with 26 additions and 24 deletions

View File

@ -0,0 +1,22 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
HRectangleBottomBorder {
id: line
property bool show: false
transform: Scale {
origin.x: line.width / 2
origin.y: line.height / 2
xScale: line.show ? 1 : 0
Behavior on xScale { HNumberAnimation {} }
}
Behavior on color { HColorAnimation {} }
}

View File

@ -55,20 +55,10 @@ TextArea {
border.width: bordered ? theme.controls.textArea.borderWidth : 0 border.width: bordered ? theme.controls.textArea.borderWidth : 0
border.color: borderColor border.color: borderColor
HRectangleBottomBorder { HBottomFocusLine {
id: bottomBorder show: textArea.activeFocus
borderHeight: theme.controls.textArea.borderWidth borderHeight: theme.controls.textArea.borderWidth
color: error ? errorBorder : focusedBorderColor color: error ? errorBorder : focusedBorderColor
transform: Scale {
origin.x: bottomBorder.width / 2
origin.y: bottomBorder.height / 2
xScale: textArea.activeFocus ? 1 : 0
Behavior on xScale { HNumberAnimation {} }
}
Behavior on color { HColorAnimation {} }
} }
} }

View File

@ -30,20 +30,10 @@ TextField {
border.width: bordered ? theme.controls.textField.borderWidth : 0 border.width: bordered ? theme.controls.textField.borderWidth : 0
border.color: borderColor border.color: borderColor
HRectangleBottomBorder { HBottomFocusLine {
id: bottomBorder show: field.activeFocus
borderHeight: theme.controls.textField.borderWidth borderHeight: theme.controls.textField.borderWidth
color: error ? errorBorder : focusedBorderColor color: error ? errorBorder : focusedBorderColor
transform: Scale {
origin.x: bottomBorder.width / 2
origin.y: bottomBorder.height / 2
xScale: field.activeFocus ? 1 : 0
Behavior on xScale { HNumberAnimation {} }
}
Behavior on color { HColorAnimation {} }
} }
} }