on xenial help sign in
refactor the Alt+F4 functionality into AbstractStage
1acaf83Lukáš Tinkl
qml/Stages/AbstractStage.qml+9
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
19+import GlobalShortcut 1.0
19import GSettings 1.0
20import GSettings 1.0
20
21
21FocusScope {
22FocusScope {
@@ -77,4 +78,12 @@ FocusScope {
77 color: "#060606"
78 color: "#060606"
78 anchors.fill: parent
79 anchors.fill: parent
79 }
80 }
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+ }
80}
89}
qml/Stages/DesktopStage.qml+5−7
@@ -36,6 +36,11 @@ AbstractStage {
36 edgeBarrier.push(amount);
36 edgeBarrier.push(amount);
37 }
37 }
38 }
38 }
39+ function closeFocusedDelegate() {
40+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
41+ priv.focusedAppDelegate.close();
42+ }
43+ }
39
44
40 // Used by TutorialRight
45 // Used by TutorialRight
41 property bool spreadShown: spread.state == "altTab"
46 property bool spreadShown: spread.state == "altTab"
@@ -47,13 +52,6 @@ AbstractStage {
47
52
48 orientationChangesEnabled: true
53 orientationChangesEnabled: true
49
54
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−
57 GlobalShortcut {
55 GlobalShortcut {
58 id: showSpreadShortcut
56 id: showSpreadShortcut
59 shortcut: Qt.MetaModifier|Qt.Key_W
57 shortcut: Qt.MetaModifier|Qt.Key_W
qml/Stages/PhoneStage.qml+6−7
@@ -20,7 +20,6 @@ import Ubuntu.Gestures 0.1
20import Unity.Application 0.1
20import Unity.Application 0.1
21import Unity.Session 0.1
21import Unity.Session 0.1
22import Utils 0.1
22import Utils 0.1
23−import GlobalShortcut 1.0
24import Powerd 0.1
23import Powerd 0.1
25import "../Components"
24import "../Components"
26
25
@@ -109,6 +108,12 @@ AbstractStage {
109 }
108 }
110 }
109 }
111
110
111+ function closeFocusedDelegate() {
112+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
113+ priv.focusedAppDelegate.closed();
114+ }
115+ }
116+
112 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
117 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
113
118
114 orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
119 orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
@@ -127,12 +132,6 @@ AbstractStage {
127
132
128 signal opened()
133 signal opened()
129
134
130− GlobalShortcut {
131− shortcut: Qt.AltModifier|Qt.Key_F4
132− onTriggered: priv.focusedAppDelegate.closed()
133− active: priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash
134− }
135−
136 function select(appId) {
135 function select(appId) {
137 spreadView.snapTo(priv.indexOf(appId));
136 spreadView.snapTo(priv.indexOf(appId));
138 }
137 }
qml/Stages/TabletStage.qml+6−7
@@ -19,7 +19,6 @@ import Ubuntu.Components 1.3
19import Ubuntu.Gestures 0.1
19import Ubuntu.Gestures 0.1
20import Unity.Application 0.1
20import Unity.Application 0.1
21import Utils 0.1
21import Utils 0.1
22−import GlobalShortcut 1.0
23import Powerd 0.1
22import Powerd 0.1
24import "../Components"
23import "../Components"
25
24
@@ -85,6 +84,12 @@ AbstractStage {
85 }
84 }
86 }
85 }
87
86
87+ function closeFocusedDelegate() {
88+ if (priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash) {
89+ priv.focusedAppDelegate.closed();
90+ }
91+ }
92+
88 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
93 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
89
94
90 mainApp: {
95 mainApp: {
@@ -115,12 +120,6 @@ AbstractStage {
115 }
120 }
116 }
121 }
117
122
118− GlobalShortcut {
119− shortcut: Qt.AltModifier|Qt.Key_F4
120− onTriggered: priv.focusedAppDelegate.closed()
121− active: priv.focusedAppDelegate && !priv.focusedAppDelegate.isDash
122− }
123−
124 // How far left the stage has been dragged, used externally by tutorial code
123 // How far left the stage has been dragged, used externally by tutorial code
125 dragProgress: spreadRepeater.count > 0 ? spreadRepeater.itemAt(0).animatedProgress : 0
124 dragProgress: spreadRepeater.count > 0 ? spreadRepeater.itemAt(0).animatedProgress : 0
126
125