on xenial help sign in
refactor the Alt+F4 functionality into AbstractStage
commit1acaf838147bafdc7d5c12c89be5527d891595cd authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 31 May 2016, 19:54 (10 years ago) parentaa9dcd0
4 files changed+26−21
qml/Stages/AbstractStage.qml+9 qml/Stages/DesktopStage.qml+5−7 qml/Stages/PhoneStage.qml+6−7 qml/Stages/TabletStage.qml+6−7
qml/Stages/AbstractStage.qml+9
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
19+import GlobalShortcut 1.0
1920import GSettings 1.0
2021
2122FocusScope {
@@ -77,4 +78,12 @@ FocusScope {
7778 color: "#060606"
7879 anchors.fill: parent
7980 }
81+
82+ // shared Alt+F4 functionality
83+ function closeFocusedDelegate() {} // to be implemented by stages
84+
85+ GlobalShortcut {
86+ shortcut: Qt.AltModifier|Qt.Key_F4
87+ onTriggered: closeFocusedDelegate()
88+ }
8089}
qml/Stages/DesktopStage.qml+5−7
@@ -36,6 +36,11 @@ AbstractStage {
3636 edgeBarrier.push(amount);
3737 }
3838 }
39+ function closeFocusedDelegate() {
40+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
41+ priv.focusedAppDelegate.close();
42+ }
43+ }
3944
4045 // Used by TutorialRight
4146 property bool spreadShown: spread.state == "altTab"
@@ -47,13 +52,6 @@ AbstractStage {
4752
4853 orientationChangesEnabled: true
4954
50− GlobalShortcut {
51− id: closeWindowShortcut
52− shortcut: Qt.AltModifier|Qt.Key_F4
53− onTriggered: priv.focusedAppDelegate.close();
54− active: priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash
55− }
56−
5755 GlobalShortcut {
5856 id: showSpreadShortcut
5957 shortcut: Qt.MetaModifier|Qt.Key_W
qml/Stages/PhoneStage.qml+6−7
@@ -20,7 +20,6 @@ import Ubuntu.Gestures 0.1
2020import Unity.Application 0.1
2121import Unity.Session 0.1
2222import Utils 0.1
23−import GlobalShortcut 1.0
2423import Powerd 0.1
2524import "../Components"
2625
@@ -109,6 +108,12 @@ AbstractStage {
109108 }
110109 }
111110
111+ function closeFocusedDelegate() {
112+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
113+ priv.focusedAppDelegate.closed();
114+ }
115+ }
116+
112117 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
113118
114119 orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
@@ -127,12 +132,6 @@ AbstractStage {
127132
128133 signal opened()
129134
130− GlobalShortcut {
131− shortcut: Qt.AltModifier|Qt.Key_F4
132− onTriggered: priv.focusedAppDelegate.closed()
133− active: priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash
134− }
135−
136135 function select(appId) {
137136 spreadView.snapTo(priv.indexOf(appId));
138137 }
qml/Stages/TabletStage.qml+6−7
@@ -19,7 +19,6 @@ import Ubuntu.Components 1.3
1919import Ubuntu.Gestures 0.1
2020import Unity.Application 0.1
2121import Utils 0.1
22−import GlobalShortcut 1.0
2322import Powerd 0.1
2423import "../Components"
2524
@@ -85,6 +84,12 @@ AbstractStage {
8584 }
8685 }
8786
87+ function closeFocusedDelegate() {
88+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
89+ priv.focusedAppDelegate.closed();
90+ }
91+ }
92+
8893 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
8994
9095 mainApp: {
@@ -115,12 +120,6 @@ AbstractStage {
115120 }
116121 }
117122
118− GlobalShortcut {
119− shortcut: Qt.AltModifier|Qt.Key_F4
120− onTriggered: priv.focusedAppDelegate.closed()
121− active: priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash
122− }
123−
124123 // How far left the stage has been dragged, used externally by tutorial code
125124 dragProgress: spreadRepeater.count > 0 ? spreadRepeater.itemAt(0).animatedProgress : 0
126125