chore(StatusInput): use layouts for elements positioning
It removes complexity and fixes StatusInput to follow the size assigned by client.
This commit is contained in:
parent
be0f49a8d8
commit
406e4a1177
|
@ -1,4 +1,5 @@
|
||||||
import QtQuick 2.14
|
import QtQuick 2.14
|
||||||
|
import QtQuick.Layouts 1.14
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Backpressure 1.0
|
import StatusQ.Core.Backpressure 1.0
|
||||||
|
@ -29,23 +30,7 @@ import StatusQ.Controls.Validators 0.1
|
||||||
*/
|
*/
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
implicitWidth: 480
|
|
||||||
implicitHeight: (label.visible ?
|
|
||||||
label.anchors.topMargin +
|
|
||||||
label.height :
|
|
||||||
charLimitLabel.visible ?
|
|
||||||
charLimitLabel.anchors.topMargin +
|
|
||||||
charLimitLabel.height :
|
|
||||||
0) +
|
|
||||||
statusBaseInput.anchors.topMargin +
|
|
||||||
statusBaseInput.height +
|
|
||||||
(errorMessage.visible ?
|
|
||||||
errorMessage.anchors.topMargin +
|
|
||||||
errorMessage.height :
|
|
||||||
0) + 8
|
|
||||||
|
|
||||||
height: implicitHeight
|
|
||||||
width: implicitWidth
|
|
||||||
/*!
|
/*!
|
||||||
\qmlproperty alias StatusInput::input
|
\qmlproperty alias StatusInput::input
|
||||||
This property holds a reference to the TextEdit component.
|
This property holds a reference to the TextEdit component.
|
||||||
|
@ -320,21 +305,24 @@ Item {
|
||||||
root.valid = Object.values(asyncErrors).length == 0
|
root.valid = Object.values(asyncErrors).length == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicitWidth: inputLayout.implicitWidth
|
||||||
|
implicitHeight: inputLayout.implicitHeight
|
||||||
|
height: implicitHeight
|
||||||
|
width: implicitWidth
|
||||||
|
|
||||||
Component.onCompleted: validate()
|
Component.onCompleted: validate()
|
||||||
|
|
||||||
Row {
|
ColumnLayout {
|
||||||
id: labelRow
|
id: inputLayout
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
anchors.fill: parent
|
||||||
anchors.topMargin: visible ? 8 : 0
|
|
||||||
anchors.leftMargin: root.leftPadding
|
RowLayout {
|
||||||
anchors.right: (charLimitLabel.visible ? charLimitLabel.right : parent.right)
|
Layout.fillWidth: true
|
||||||
anchors.rightMargin: root.rightPadding
|
|
||||||
height: visible ? 17 : 0
|
|
||||||
visible: !!root.label
|
|
||||||
spacing: 5
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: label
|
id: label
|
||||||
|
visible: !!root.label
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
text: root.label
|
text: root.label
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
@ -343,38 +331,34 @@ Item {
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: secondaryLabel
|
id: secondaryLabel
|
||||||
height: visible ? 17 : 0
|
|
||||||
visible: !!root.secondaryLabel
|
visible: !!root.secondaryLabel
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
text: root.secondaryLabel
|
text: root.secondaryLabel
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Theme.palette.baseColor1
|
color: Theme.palette.baseColor1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: charLimitLabel
|
id: charLimitLabel
|
||||||
height: visible ? implicitHeight : 0
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.topMargin: visible ? 11 : 0
|
|
||||||
anchors.rightMargin: root.rightPadding
|
|
||||||
visible: root.charLimit > 0
|
visible: root.charLimit > 0
|
||||||
|
|
||||||
text: "%1 / %2".arg(statusBaseInput.text.length).arg(root.charLimit)
|
text: "%1 / %2".arg(statusBaseInput.text.length).arg(root.charLimit)
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
color: statusBaseInput.enabled ? Theme.palette.baseColor1 : Theme.palette.directColor6
|
color: statusBaseInput.enabled ? Theme.palette.baseColor1 : Theme.palette.directColor6
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StatusBaseInput {
|
StatusBaseInput {
|
||||||
id: statusBaseInput
|
id: statusBaseInput
|
||||||
anchors.top: labelRow.visible ? labelRow.bottom :
|
|
||||||
charLimitLabel.visible ? charLimitLabel.bottom : parent.top
|
Layout.fillWidth: true
|
||||||
anchors.left: parent.left
|
Layout.fillHeight: true
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.topMargin: charLimitLabel.visible ? 11 : 8
|
|
||||||
anchors.leftMargin: root.leftPadding
|
|
||||||
anchors.rightMargin: root.rightPadding
|
|
||||||
maximumLength: root.charLimit
|
maximumLength: root.charLimit
|
||||||
onTextChanged: root.validate()
|
onTextChanged: root.validate()
|
||||||
|
|
||||||
|
@ -391,21 +375,13 @@ Item {
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: errorMessage
|
id: errorMessage
|
||||||
|
|
||||||
anchors.top: statusBaseInput.bottom
|
|
||||||
anchors.topMargin: 11
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: root.rightPadding
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: root.leftPadding
|
|
||||||
|
|
||||||
height: visible ? implicitHeight : 0
|
|
||||||
visible: !!text && !statusBaseInput.valid
|
visible: !!text && !statusBaseInput.valid
|
||||||
|
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
color: Theme.palette.dangerColor1
|
color: Theme.palette.dangerColor1
|
||||||
|
|
||||||
|
|
||||||
horizontalAlignment: Text.AlignRight
|
horizontalAlignment: Text.AlignRight
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue