From 85f646eb56494852434482664ca5b0804a54b1fb Mon Sep 17 00:00:00 2001 From: Konrad Materka Date: Mon, 9 Mar 2020 22:17:04 +0100 Subject: [PATCH] [SystemTray] Fix item size for very narrow panel Summary: For very narrow panel item size is too big (item + padding exceed panel size). This adds a check to not exceed panel size. Before: {F8167941} After: {F8167942} Test Plan: * Make panel very narrow - icons should fit into panel * Repeat for vertical/horizontal Reviewers: #plasma_workspaces, #plasma, ngraham, broulik Reviewed By: ngraham Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D27958 --- .../package/contents/ui/items/PlasmoidItem.qml | 16 +++++++++++----- applets/systemtray/package/contents/ui/main.qml | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml index c61d22e8c..2c7c5442d 100644 --- a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml +++ b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml @@ -54,7 +54,14 @@ AbstractItem { onHeightChanged: { if (applet) { - applet.width = height + applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height) + applet.height = applet.width + } + } + onWidthChanged: { + if (applet) { + applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height) + applet.height = applet.width } } @@ -71,11 +78,10 @@ AbstractItem { if (applet) { applet.parent = plasmoidContainer applet.anchors.left = plasmoidContainer.left - applet.anchors.top = plasmoidContainer.top - applet.anchors.bottom = plasmoidContainer.bottom - applet.width = plasmoidContainer.height + applet.anchors.verticalCenter = plasmoidContainer.verticalCenter + applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height) + applet.height = applet.width applet.visible = true - plasmoidContainer.visible = true preloadFullRepresentationItem(applet.fullRepresentationItem) } diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index a052e2644..ddc602b67 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -154,8 +154,8 @@ 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 + cellHeight: Math.min(root.itemSize + units.smallSpacing, root.height) + cellWidth: Math.min(root.itemSize + units.smallSpacing, root.width) readonly property int columns: !vertical ? Math.ceil(count / rows) : Math.max(1, Math.floor(root.width / cellWidth))