on xenial help sign in
Initial re-implementation of screenshot logic
ac73c26Josh Arenson
qml/Components/PhysicalKeysFilter.qml+43−6
@@ -36,20 +36,57 @@ import QtQuick 2.0
36QtObject {
36QtObject {
37 id: root
37 id: root
38
38
39− signal volumeUpPressed()
40 signal volumeDownPressed()
39 signal volumeDownPressed()
40+ signal volumeUpPressed()
41 signal screenshotPressed()
41 signal screenshotPressed()
42
42
43+ property bool powerKeyPressed: false
44+
43 property bool aVolumeKeyWasReleased: true
45 property bool aVolumeKeyWasReleased: true
44 property bool volumeDownKeyPressed: false
46 property bool volumeDownKeyPressed: false
45 property bool volumeUpKeyPressed: false
47 property bool volumeUpKeyPressed: false
46
48
47 function onKeyPressed(key) {
49 function onKeyPressed(key) {
48− switch(key) {
50+ if (key == Qt.Key_PowerDown || key == Qt.Key_PowerOff) {
51+ console.log("JOSH: Pressed power key");
52+ powerKeyPressed = true;
53+ }
49− case Qt.Key_VolumeDown:
54+ else if (key == Qt.Key_VolumeDown) {
50− volumeDownKeyPressed = true;
55+ volumeDownKeyPressed = true;
56+ }
51− case Qt.Key_VolumeUp:
57+ else if (key == Qt.Key_VolumeUp) {
58+ volumeUpKeyPressed = true;
59+ }
60+
61+ if (volumeDownKeyPressed && volumeUpKeyPressed) {
62+ if (aVolumeKeyWasReleased) {
63+ bothVolumeKeysPressed();
64+ }
65+ aVolumeKeyWasReleased = false;
66+ }
67+ else if (volumeDownKeyPressed) {
68+ console.log("JOSH: VolumeDown!");
69+ if (powerKeyPressed) {
70+ console.log("JOSH: TAKE A SCREENSHOT");
71+ }
72+ volumeDownPressed();
73+ }
74+ else if (volumeUpKeyPressed) {
75+ volumeUpPressed();
76+ }
77+ }
78+
79+ function onKeyReleased(key) {
80+ if (key == Qt.Key_PowerDown || key == Qt.Key_PowerOff) {
81+ powerKeyPressed = false;
82+ }
83+ else if (key == Qt.Key_VolumeDown) {
84+ volumeDownKeyPressed = false;
85+ aVolumeKeyWasReleased = false;
86+ }
87+ else if (key == Qt.Key_VolumeUp) {
52− volumeUpKeyPressed = true;
88+ volumeUpKeyPressed = false;
89+ aVolumeKeyWasReleased = true;
53 }
90 }
54 }
91 }
55}
92}
qml/Components/VolumeKeyFilter.qml+4
@@ -33,6 +33,10 @@ QtObject {
33 property bool aVolumeKeyWasReleased: true
33 property bool aVolumeKeyWasReleased: true
34
34
35 function onKeyPressed(key) {
35 function onKeyPressed(key) {
36+ if (key == Qt.Key_PowerOff || key == Qt.Key_PowerDown) {
37+ console.log("JOSH: POWER KEY");
38+ }
39+
36 if (key == Qt.Key_VolumeUp)
40 if (key == Qt.Key_VolumeUp)
37 volumeUpKeyPressed = true;
41 volumeUpKeyPressed = true;
38 else if (key == Qt.Key_VolumeDown)
42 else if (key == Qt.Key_VolumeDown)
qml/Shell.qml+10−4
@@ -156,6 +156,10 @@ Item {
156
156
157 PhysicalKeysFilter {
157 PhysicalKeysFilter {
158 id: physicalKeysFilter
158 id: physicalKeysFilter
159+
160+ onVolumeDownPressed: volumeControl.volumeDown()
161+ onVolumeUpPressed: volumeControl.volumeUp()
162+ //onBothVolumeKeysPressed: screenGrabber.capture()
159 }
163 }
160
164
161 ScreenGrabber {
165 ScreenGrabber {
@@ -170,30 +174,32 @@ Item {
170 value: launcher.shown || launcher.dashSwipe
174 value: launcher.shown || launcher.dashSwipe
171 }
175 }
172
176
173− VolumeKeyFilter {
177+ /*VolumeKeyFilter {
174 id: volumeKeyFilter
178 id: volumeKeyFilter
175 onVolumeDownPressed: volumeControl.volumeDown()
179 onVolumeDownPressed: volumeControl.volumeDown()
176 onVolumeUpPressed: volumeControl.volumeUp()
180 onVolumeUpPressed: volumeControl.volumeUp()
177 onBothVolumeKeysPressed: screenGrabber.capture()
181 onBothVolumeKeysPressed: screenGrabber.capture()
178− }
182+ }*/
179
183
180 WindowKeysFilter {
184 WindowKeysFilter {
181 Keys.onPressed: {
185 Keys.onPressed: {
186+ physicalKeysFilter.onKeyPressed(event.key);
182 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
187 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
183 dialogs.onPowerKeyPressed();
188 dialogs.onPowerKeyPressed();
184 event.accepted = true;
189 event.accepted = true;
185 } else {
190 } else {
186− volumeKeyFilter.onKeyPressed(event.key);
191+ //volumeKeyFilter.onKeyPressed(event.key);
187 event.accepted = false;
192 event.accepted = false;
188 }
193 }
189 }
194 }
190
195
191 Keys.onReleased: {
196 Keys.onReleased: {
197+ physicalKeysFilter.onKeyReleased(event.key);
192 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
198 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
193 dialogs.onPowerKeyReleased();
199 dialogs.onPowerKeyReleased();
194 event.accepted = true;
200 event.accepted = true;
195 } else {
201 } else {
196− volumeKeyFilter.onKeyReleased(event.key);
202+ //volumeKeyFilter.onKeyReleased(event.key);
197 event.accepted = false;
203 event.accepted = false;
198 }
204 }
199 }
205 }