From fe07909cd8d24fa3fa32119508f90f18c7dac220 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sun, 28 Oct 2018 16:46:15 +0000 Subject: [PATCH] [desktopchangeosd] Sync desktop switch OSD font size to Plasma OSD font size Summary: Plasma's OSDs for volume/screens etc use PlasmaExtras.Heading, this should to. Also correct centering text to constrain the text element and align the text within that bounding box. Previous code could have overflown in the event of a really really long desktop name if we're resizing to the grid. BUG: 356600 Test Plan: Switched desktop with OSD on Tried with and without "show desktop layout indicators" Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16420 --- scripts/desktopchangeosd/contents/ui/osd.qml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/desktopchangeosd/contents/ui/osd.qml b/scripts/desktopchangeosd/contents/ui/osd.qml index 269b29e8b1..b32db04863 100644 --- a/scripts/desktopchangeosd/contents/ui/osd.qml +++ b/scripts/desktopchangeosd/contents/ui/osd.qml @@ -20,6 +20,7 @@ along with this program. If not, see . import QtQuick 2.0; import QtQuick.Window 2.0; import org.kde.plasma.core 2.0 as PlasmaCore; +import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.components 2.0 as Plasma; import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons; import org.kde.kwin 2.0; @@ -75,15 +76,20 @@ PlasmaCore.Dialog { property int animationDuration: 1000 property bool showGrid: true - width: dialogItem.showGrid ? view.itemWidth * view.columns : textElement.width + width: dialogItem.showGrid ? view.itemWidth * view.columns : Math.ceil(textElement.implicitWidth) height: dialogItem.showGrid ? view.itemHeight * view.rows + textElement.height : textElement.height - Plasma.Label { + PlasmaExtras.Heading { id: textElement anchors.top: dialogItem.showGrid ? parent.top : undefined - anchors.horizontalCenter: parent.horizontalCenter + anchors.left: parent.left + anchors.right: parent.right + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.NoWrap + elide: Text.ElideRight text: workspace.desktopName(workspace.currentDesktop) } + Grid { id: view columns: 1