From 5727362e3666f3d74c641665f5fb86b7d1434216 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 4 Mar 2022 00:54:40 +0000 Subject: [PATCH] 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 8fcdfc309fad296b73057d602817b9f595821ace) --- .../package/contents/ui/HiddenItemsView.qml | 21 +++++++++++++++++++ .../contents/ui/items/AbstractItem.qml | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/applets/systemtray/package/contents/ui/HiddenItemsView.qml b/applets/systemtray/package/contents/ui/HiddenItemsView.qml index 2a65a3336..011059aaf 100644 --- a/applets/systemtray/package/contents/ui/HiddenItemsView.qml +++ b/applets/systemtray/package/contents/ui/HiddenItemsView.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" diff --git a/applets/systemtray/package/contents/ui/items/AbstractItem.qml b/applets/systemtray/package/contents/ui/items/AbstractItem.qml index 205ed5465..aaa57c1d6 100644 --- a/applets/systemtray/package/contents/ui/items/AbstractItem.qml +++ b/applets/systemtray/package/contents/ui/items/AbstractItem.qml @@ -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