better layout when the space is scarce

This commit is contained in:
Marco Martin 2015-06-18 18:53:17 -07:00
parent 58bc75eef4
commit c52a96e984

View file

@ -97,11 +97,8 @@ MouseArea {
PlasmaComponents.Label { PlasmaComponents.Label {
id: appLabel id: appLabel
anchors { anchors.leftMargin: units.gridUnit * 3
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: units.gridUnit * 3
}
color: PlasmaCore.ColorScope.textColor color: PlasmaCore.ColorScope.textColor
text: model.appName text: model.appName
} }
@ -109,23 +106,24 @@ MouseArea {
Column { Column {
id: messageLayout id: messageLayout
anchors { anchors {
left: appLabel.right
right: icon.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
rightMargin: units.smallSpacing left: parent.left
right: icon.left
leftMargin: units.gridUnit * 3
} }
PlasmaComponents.Label { PlasmaComponents.Label {
anchors { id: summaryLabel
right: parent.right anchors.right: parent.right
left: parent.left width: messageLayout.width - appLabel.width
}
horizontalAlignment: Qt.AlignRight horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
text: summary + (!notificationItem.expanded && body ? "..." : "") text: summary + (!notificationItem.expanded && body ? "..." : "")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
PlasmaComponents.Label { PlasmaComponents.Label {
id: bodyLabel
anchors { anchors {
right: parent.right right: parent.right
left: parent.left left: parent.left
@ -136,9 +134,9 @@ MouseArea {
text: body text: body
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
} }
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: icon id: icon
anchors { anchors {
@ -174,4 +172,34 @@ MouseArea {
} }
} }
} }
states: [
State {
name: "large"
when: appLabel.width + bodyLabel.paintedWidth < messageLayout.width
AnchorChanges {
target: appLabel
anchors {
verticalCenter: parent.verticalCenter
top: undefined
left: parent.left
}
}
PropertyChanges {
}
},
State {
name: "compact"
when: notificationItem.state != "large"
AnchorChanges {
target: appLabel
anchors {
verticalCenter: undefined
top: messageLayout.top
left: parent.left
}
}
}
]
} }