From fd78da890b7c80c56ddb640ced943f183ca55141 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 14 Jun 2020 01:48:56 +0300 Subject: [PATCH] systemtray items respect Fitt's Law when in panel --systemtray items are now using a rectangular form in order to specify their hit area. So they take into account the panel thickness in order to calculate properly their cell length and thickness to respect Fitt's Law. Items that are nearer to the screen edge can now trigger all their events when the user uses its mouse at the farest of the screen edge. --- .../package/contents/ui/items/AbstractItem.qml | 4 ++-- applets/systemtray/package/contents/ui/main.qml | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/applets/systemtray/package/contents/ui/items/AbstractItem.qml b/applets/systemtray/package/contents/ui/items/AbstractItem.qml index f8059fb9b..e882f8f30 100644 --- a/applets/systemtray/package/contents/ui/items/AbstractItem.qml +++ b/applets/systemtray/package/contents/ui/items/AbstractItem.qml @@ -136,8 +136,8 @@ PlasmaCore.ToolTipArea { readonly property int size: abstractItem.inVisibleLayout ? root.itemSize : units.iconSizes.medium Layout.alignment: Qt.AlignHCenter - implicitWidth: size - implicitHeight: size + implicitWidth: root.vertical && abstractItem.inVisibleLayout ? abstractItem.width : size + implicitHeight: !root.vertical && abstractItem.inVisibleLayout ? abstractItem.height : size Layout.topMargin: abstractItem.inHiddenLayout ? units.smallSpacing : 0 } PlasmaComponents.Label { diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index 6cd033a06..ba4f16964 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -156,13 +156,14 @@ MouseArea { interactive: false //disable features we don't need flow: vertical ? GridView.LeftToRight : GridView.TopToBottom - cellHeight: root.itemSize + units.smallSpacing - cellWidth: root.itemSize + units.smallSpacing - - readonly property int columns: !vertical ? Math.ceil(count / rows) - : Math.max(1, Math.floor(root.width / cellWidth)) - readonly property int rows: vertical ? Math.ceil(count / columns) - : Math.max(1, Math.floor(root.height / cellHeight)) + cellHeight: vertical ? cellLength : root.height / rows + cellWidth: vertical ? root.width / columns : cellLength + + readonly property int cellLength: root.itemSize + units.smallSpacing + readonly property int columns: !vertical ? Math.ceil(count / rows) : + Math.max(1, Math.floor(root.width / cellLength)) + readonly property int rows: vertical ? Math.ceil(count / columns) : + Math.max(1, Math.floor(root.height / cellLength)) implicitHeight: rows * cellHeight implicitWidth: columns * cellWidth