applets/systray: align applet labels with differing line counts in hidden view

Discover current minimum height of applet labels in hidden
view and apply it for all of them when they are shown
inside hidden applets view. This implementation provides
always only the maximum needed label height based on label
contents.

BUG: 438347
FIXED-IN: 5.24.3


(cherry picked from commit 8fcdfc309f)
wilder-5.24
Michail Vourlakos 4 years ago committed by Nate Graham
parent 83400745d8
commit 5727362e36
  1. 21
      applets/systemtray/package/contents/ui/HiddenItemsView.qml
  2. 6
      applets/systemtray/package/contents/ui/items/AbstractItem.qml

@ -46,6 +46,27 @@ PlasmaComponents3.ScrollView {
readonly property int itemCount: model.count
//! This is used in order to identify the minimum required label height in order for all
//! labels to be aligned properly at all items. At the same time this approach does not
//! enforce labels with 3 lines at all cases so translations that require only one or two
//! lines will always look consistent with no too much padding
readonly property int minLabelHeight: {
var minHeight = 0;
for(let i in contentItem.children){
var gridItem = contentItem.children[i];
if (!gridItem || !gridItem.hasOwnProperty("item") || !gridItem.item.hasOwnProperty("labelHeight")) {
continue;
}
if (gridItem.item.labelHeight > minHeight) {
minHeight = gridItem.item.labelHeight;
}
}
return minHeight;
}
model: PlasmaCore.SortFilterModel {
sourceModel: plasmoid.nativeInterface.systemTrayModel
filterRole: "effectiveStatus"

@ -21,6 +21,7 @@ PlasmaCore.ToolTipArea {
property string itemId
property alias text: label.text
property alias labelHeight: label.implicitHeight
property alias iconContainer: iconContainer
property int /*PlasmaCore.Types.ItemStatus*/ status: model.status || PlasmaCore.Types.UnknownStatus
property int /*PlasmaCore.Types.ItemStatus*/ effectiveStatus: model.effectiveStatus || PlasmaCore.Types.UnknownStatus
@ -140,6 +141,11 @@ PlasmaCore.ToolTipArea {
Layout.fillWidth: true
Layout.fillHeight: abstractItem.inHiddenLayout ? true : false
//! Minimum required height for all labels is used in order for all
//! labels to be aligned properly at all items. At the same time this approach does not
//! enforce labels with 3 lines at all cases so translations that require only one or two
//! lines will always look consistent with no too much padding
Layout.minimumHeight: abstractItem.inHiddenLayout ? hiddenTasks.minLabelHeight : 0
Layout.leftMargin: abstractItem.inHiddenLayout ? PlasmaCore.Units.smallSpacing : 0
Layout.rightMargin: abstractItem.inHiddenLayout ? PlasmaCore.Units.smallSpacing : 0
Layout.bottomMargin: abstractItem.inHiddenLayout ? PlasmaCore.Units.smallSpacing : 0

Loading…
Cancel
Save