fix(StatusListItem): ensure title area wraps text

This commit is contained in:
Pascal Precht 2021-07-22 16:27:29 +02:00 committed by Michał Cieślak
parent c6c9bc6a32
commit aadd10c29a
3 changed files with 25 additions and 2 deletions

View File

@ -152,6 +152,16 @@ GridLayout {
statusListItemTitle.font.weight: Font.Bold statusListItemTitle.font.weight: Font.Bold
} }
StatusListItem {
title: "Title"
subTitle: "Super long description that causes a multiline paragraph and makes the size of the component grow. Let's see how it behaves."
tertiaryTitle: "Tertiary title"
icon.name: "info"
statusListItemTitle.font.pixelSize: 17
statusListItemTitle.font.weight: Font.Bold
}
StatusListItem { StatusListItem {
title: "Title" title: "Title"
subTitle: "Subtitle" subTitle: "Subtitle"

View File

@ -68,6 +68,8 @@ Rectangle {
property int type: StatusListItem.Type.Primary property int type: StatusListItem.Type.Primary
property alias sensor: sensor property alias sensor: sensor
property alias statusListItemIcon: iconOrImage
property alias statusListItemTitle: statusListItemTitle property alias statusListItemTitle: statusListItemTitle
property alias statusListItemSubTitle: statusListItemSubTitle property alias statusListItemSubTitle: statusListItemSubTitle
property alias statusListItemTertiaryTitle: statusListItemTertiaryTitle property alias statusListItemTertiaryTitle: statusListItemTertiaryTitle
@ -95,7 +97,8 @@ Rectangle {
id: iconOrImage id: iconOrImage
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: statusListItem.leftPadding anchors.leftMargin: statusListItem.leftPadding
anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top
anchors.topMargin: 12
sourceComponent: { sourceComponent: {
if (statusListItem.icon.isLetterIdenticon) { if (statusListItem.icon.isLetterIdenticon) {
return statusLetterIdenticon return statusLetterIdenticon
@ -148,7 +151,10 @@ Rectangle {
Item { Item {
id: statusListItemTitleArea id: statusListItemTitleArea
anchors.left: iconOrImage.active ? iconOrImage.right : parent.left anchors.left: iconOrImage.active ? iconOrImage.right : parent.left
anchors.right: statusListItemLabel.visible ?
statusListItemLabel.left : statusListItemComponentsSlot.left
anchors.leftMargin: statusListItem.leftPadding anchors.leftMargin: statusListItem.leftPadding
anchors.rightMargin: statusListItem.rightPadding
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: statusListItemTitle.height + height: statusListItemTitle.height +
(statusListItemSubTitle.visible ? statusListItemSubTitle.height : 0) + (statusListItemSubTitle.visible ? statusListItemSubTitle.height : 0) +
@ -157,7 +163,9 @@ Rectangle {
StatusBaseText { StatusBaseText {
id: statusListItemTitle id: statusListItemTitle
text: statusListItem.title text: statusListItem.title
width: parent.width
font.pixelSize: 15 font.pixelSize: 15
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: { color: {
switch (statusListItem.type) { switch (statusListItem.type) {
case StatusListItem.Type.Primary: case StatusListItem.Type.Primary:
@ -173,24 +181,28 @@ Rectangle {
StatusBaseText { StatusBaseText {
id: statusListItemSubTitle id: statusListItemSubTitle
anchors.top: statusListItemTitle.bottom anchors.top: statusListItemTitle.bottom
width: parent.width
text: statusListItem.subTitle text: statusListItem.subTitle
font.pixelSize: 15 font.pixelSize: 15
color: !statusListItem.tertiaryTitle ? Theme.palette.baseColor1 : Theme.palette.directColor1 color: !statusListItem.tertiaryTitle ? Theme.palette.baseColor1 : Theme.palette.directColor1
visible: !!statusListItem.subTitle visible: !!statusListItem.subTitle
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
} }
StatusBaseText { StatusBaseText {
id: statusListItemTertiaryTitle id: statusListItemTertiaryTitle
anchors.top: statusListItemSubTitle.bottom anchors.top: statusListItemSubTitle.bottom
width: parent.width
text: statusListItem.tertiaryTitle text: statusListItem.tertiaryTitle
color: Theme.palette.baseColor1 color: Theme.palette.baseColor1
font.pixelSize: 13 font.pixelSize: 13
visible: !!statusListItem.tertiaryTitle visible: !!statusListItem.tertiaryTitle
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
} }
} }
StatusBaseText { StatusBaseText {
id: statusListItemLabel
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: statusListItemComponentsSlot.left anchors.right: statusListItemComponentsSlot.left
anchors.rightMargin: statusListItemComponentsSlot.width > 0 ? 10 : 0 anchors.rightMargin: statusListItemComponentsSlot.width > 0 ? 10 : 0

View File

@ -17,6 +17,7 @@ StatusListItem {
icon.background.height: 20 icon.background.height: 20
icon.background.color: "transparent" icon.background.color: "transparent"
statusListItemIcon.anchors.topMargin: 14
color: { color: {
if (selected) { if (selected) {