From 926a7f71df80bdcc0f2816a03658342a3f4e8f32 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 4 Nov 2016 09:39:42 +0000 Subject: [PATCH] Close the system tray on escape - system tray Summary: A lot of applets have independent handling making escape close the expanded representation. However not all of them do. This leads to both duplicated code and inconsistencies, so we should tackle this at the source. If an applet was already using escape internally it will be accepting the event, and so this code will not cause any regressions. This patch also removes the stackview forwarding events to the active child as this doesn't make sense - the active child will already have focus and get the key event first, so this just created a recursive chain (which Qt was thankfully fixing for us). Removing it is needed for this to work. BUG: 362657 Test Plan: Pressed escape on various applets (e.g plasma-pa) Pressed escape on the expander applet list view Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D3257 --- .../package/contents/ui/PlasmoidPopupsContainer.qml | 1 - applets/systemtray/package/contents/ui/main.qml | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml index 44ab0ae74..3ea78728d 100644 --- a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml +++ b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml @@ -27,7 +27,6 @@ StackView { id: mainStack clip: true focus: true - Keys.forwardTo: [currentItem] Layout.minimumWidth: units.gridUnit * 12 Layout.minimumHeight: units.gridUnit * 12 diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index 6d59b31ac..a608b242a 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -328,6 +328,7 @@ MouseArea { flags: Qt.WindowStaysOnTopHint location: plasmoid.location hideOnWindowDeactivate: expandedRepresentation.hideOnWindowDeactivate + onVisibleChanged: { if (!visible) { plasmoid.status = PlasmaCore.Types.PassiveStatus; @@ -340,6 +341,11 @@ MouseArea { } mainItem: ExpandedRepresentation { id: expandedRepresentation + + Keys.onEscapePressed: { + root.expanded = false; + } + activeApplet: root.activeApplet LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft