Commit aa7570d5 authored by Nate Graham's avatar Nate Graham
Browse files

applets/kickoff: put descriptions below titles, as we do elsewhere

Kickoff uses an unusual way of locating list items' descriptions: it
puts them on the same line as the title, aligned to the right.

This saves vertical space but suffers from several issues:

- Because both labels need to inhabit the same line, a long title will
  cause the description to be elided into uselessness
- It's a different style than what we use for other list items with
  fundamentally the same set of data; we don't re-use users' existing
  familiarity with KDE-style list items that typically have the caption,
  subtitle, or description below the label/title
- Saving vertical space is not a win here because we want the applet to
  be touch-friendly, and short list items make that worse, not better

Accordingly, this MR changes the list items to put the descriptions
under the labels to resolve those issues. To avoid the result looking
weird, icon sizes for non-category list items are also increased.
parent d3c6306a
Pipeline #121832 passed with stage
in 3 minutes and 10 seconds
......@@ -94,16 +94,16 @@ T.ItemDelegate {
+ (!textUnderIcon && mirrored ? KickoffSingleton.fontMetrics.descent : 0)
rightPadding: KickoffSingleton.listItemMetrics.margins.right
+ (!textUnderIcon && !mirrored ? KickoffSingleton.fontMetrics.descent : 0)
topPadding: PlasmaCore.Units.smallSpacing*2
bottomPadding: PlasmaCore.Units.smallSpacing*2
topPadding: root.textUnderIcon ? PlasmaCore.Units.smallSpacing * 2 : PlasmaCore.Units.smallSpacing
bottomPadding: root.textUnderIcon ? PlasmaCore.Units.smallSpacing * 2 : PlasmaCore.Units.smallSpacing
spacing: KickoffSingleton.fontMetrics.descent
enabled: !model.disabled
hoverEnabled: false
icon.width: PlasmaCore.Units.iconSizes.smallMedium
icon.height: PlasmaCore.Units.iconSizes.smallMedium
icon.width: root.isCategory ? PlasmaCore.Units.iconSizes.smallMedium : PlasmaCore.Units.iconSizes.medium
icon.height: root.isCategory ? PlasmaCore.Units.iconSizes.smallMedium : PlasmaCore.Units.iconSizes.medium
text: model.name ?? model.display
Accessible.description: root.description != root.text ? root.description : ""
......@@ -144,38 +144,44 @@ T.ItemDelegate {
usesPlasmaTheme: false
source: root.decoration || root.icon.name || root.icon.source
}
PC3.Label {
id: label
ColumnLayout {
Layout.alignment: root.textUnderIcon ? Qt.AlignHCenter | Qt.AlignTop : Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: root.textUnderIcon ? 0 : PlasmaCore.Units.smallSpacing
Layout.fillWidth: true
Layout.preferredHeight: root.textUnderIcon && lineCount === 1 ? implicitHeight * 2 : implicitHeight
text: root.text
elide: Text.ElideRight
horizontalAlignment: root.textUnderIcon ? Text.AlignHCenter : Text.AlignLeft
verticalAlignment: root.textUnderIcon ? Text.AlignTop : Text.AlignVCenter
maximumLineCount: 2
wrapMode: Text.Wrap
textFormat: root.model && root.model.isMultilineText ? Text.StyledText : Text.PlainText
}
}
Layout.preferredHeight: {
// Make grid items bigger so they perfectly fit in the space
if (root.textUnderIcon) {
return label.lineCount === 1 ? label.implicitHeight * 2 : label.implicitHeight;
} else if (root.isCategory) {
return implicitHeight + PlasmaCore.Units.smallSpacing
}
return implicitHeight;
}
spacing: 0
PC3.Label {
id: descriptionLabel
parent: root
anchors {
left: root.contentItem.left
right: root.contentItem.right
baseline: root.contentItem.baseline
leftMargin: root.textUnderIcon ? 0 : root.implicitContentWidth + root.spacing
baselineOffset: root.textUnderIcon ? implicitHeight : 0
PC3.Label {
id: label
Layout.fillWidth: true
text: root.text
elide: Text.ElideRight
horizontalAlignment: root.textUnderIcon ? Text.AlignHCenter : Text.AlignLeft
verticalAlignment: root.textUnderIcon ? Text.AlignTop : Text.AlignVCenter
maximumLineCount: 2
wrapMode: Text.Wrap
}
PC3.Label {
id: descriptionLabel
Layout.fillWidth: true
visible: !textUnderIcon && text.length > 0 && text !== root.text && label.lineCount === 1
enabled: false
text: root.description
font: PlasmaCore.Theme.smallestFont
elide: Text.ElideRight
verticalAlignment: root.textUnderIcon ? Text.AlignTop : Text.AlignVCenter
maximumLineCount: 1
}
}
visible: !textUnderIcon && text.length > 0 && text !== root.text && label.lineCount === 1
enabled: false
text: root.description
elide: Text.ElideRight
horizontalAlignment: root.textUnderIcon ? Text.AlignHCenter : Text.AlignRight
verticalAlignment: root.textUnderIcon ? Text.AlignTop : Text.AlignVCenter
maximumLineCount: 1
}
Drag.active: mouseArea.drag.active
......
......@@ -135,11 +135,10 @@ EmptyPage {
property: "group"
criteria: ViewSection.FullString
delegate: PC3.Label {
//readonly property bool visualFocus: false
width: section.length === 1
? KickoffSingleton.listDelegateContentHeight + leftPadding + rightPadding
// Accessing implicitWidth fixes the width being 0 when loaded.
: Math.min(Math.ceil(implicitWidth), view.contentWidth)
? KickoffSingleton.listDelegateContentHeight + KickoffSingleton.listItemMetrics.margins.left + KickoffSingleton.listItemMetrics.margins.right
// Accessing implicitWidth fixes the width being 0 when loaded.
: Math.min(Math.ceil(implicitWidth), view.contentWidth)
height: KickoffSingleton.listDelegateHeight
leftPadding: view.effectiveLayoutDirection === Qt.LeftToRight
? KickoffSingleton.listItemMetrics.margins.left : 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment