fix(StatusInput): Add labelPadding customization and improve height calculation
This commit is contained in:
parent
f09565a4fa
commit
ad962a6009
|
@ -94,6 +94,11 @@ Item {
|
||||||
\qmlproperty string StatusInput::label
|
\qmlproperty string StatusInput::label
|
||||||
This property sets the label text.
|
This property sets the label text.
|
||||||
*/
|
*/
|
||||||
|
property int labelPadding: 8
|
||||||
|
/*!
|
||||||
|
\qmlproperty string StatusInput::label
|
||||||
|
This property sets the label text.
|
||||||
|
*/
|
||||||
property string label: ""
|
property string label: ""
|
||||||
/*!
|
/*!
|
||||||
\qmlproperty string StatusInput::secondaryLabel
|
\qmlproperty string StatusInput::secondaryLabel
|
||||||
|
@ -347,9 +352,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
implicitWidth: 448
|
implicitWidth: 448
|
||||||
implicitHeight: ((internal.inputHeight + topRow.height + errorMessage.height) +
|
implicitHeight: inputLayout.implicitHeight
|
||||||
((topRow.height > 0) && (errorMessage.height > 0) ? 16 :
|
|
||||||
(topRow.height > 0) || (errorMessage.height > 0) ? 8 : 0))
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
validate()
|
validate()
|
||||||
|
@ -364,6 +367,7 @@ Item {
|
||||||
id: topRow
|
id: topRow
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: (!!root.label || !!root.secondaryLabel || root.charLimit > 0) ? 22 : 0
|
Layout.preferredHeight: (!!root.label || !!root.secondaryLabel || root.charLimit > 0) ? 22 : 0
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: label
|
id: label
|
||||||
visible: !!text
|
visible: !!text
|
||||||
|
@ -404,7 +408,7 @@ Item {
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: internal.inputHeight
|
implicitHeight: internal.inputHeight
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.topMargin: (topRow.height > 0) ? 8 : 0
|
Layout.topMargin: (topRow.height > 0) ? labelPadding : 0
|
||||||
maximumLength: root.charLimit
|
maximumLength: root.charLimit
|
||||||
onTextChanged: root.validate()
|
onTextChanged: root.validate()
|
||||||
Keys.forwardTo: [root]
|
Keys.forwardTo: [root]
|
||||||
|
@ -419,13 +423,22 @@ Item {
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: errorMessage
|
id: errorMessage
|
||||||
visible: !!text && !statusBaseInput.valid
|
visible: {
|
||||||
height: visible ? contentHeight : 0
|
if (!text)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((root.validationMode == StatusInput.ValidationMode.OnlyWhenDirty && statusBaseInput.dirty) ||
|
||||||
|
root.validationMode == StatusInput.ValidationMode.Always)
|
||||||
|
return !statusBaseInput.valid;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
color: Theme.palette.dangerColor1
|
color: Theme.palette.dangerColor1
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
Layout.topMargin: visible ? 8 : 0
|
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
Layout.topMargin: 8
|
||||||
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue