on xenial help sign in
Remove VolumeKeyFilter
commitb95edd15768583dfbc7ca323b3644e2248521bb8 authorJosh Arenson <joshua.arenson@canonical.com> dateTue 9 Dec 2014, 16:43 (12 years ago) parent3660d9c
1 file changed−67
qml/Components/VolumeKeyFilter.qml−67
qml/Components/VolumeKeyFilter.qmldeleted−67
@@ -1,67 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−/*!
19− \brief A filter for volume keys
20−
21−A filter which treats volume keys as single tri-state key with the states:
22−VolumeUp Pressed, VolumeDown Pressed or Volume Up+Down pressed
23−*/
24−QtObject {
25− id: root
26−
27− signal volumeUpPressed()
28− signal volumeDownPressed()
29− signal bothVolumeKeysPressed()
30−
31− property bool volumeUpKeyPressed: false
32− property bool volumeDownKeyPressed: false
33− property bool aVolumeKeyWasReleased: true
34−
35− function onKeyPressed(key) {
36− if (key == Qt.Key_PowerOff || key == Qt.Key_PowerDown) {
37− console.log("JOSH: POWER KEY");
38− }
39−
40− if (key == Qt.Key_VolumeUp)
41− volumeUpKeyPressed = true;
42− else if (key == Qt.Key_VolumeDown)
43− volumeDownKeyPressed = true;
44−
45− if (volumeDownKeyPressed && volumeUpKeyPressed) {
46− //avoids sending a signal repeatedly if both keys are held
47− //instead one of the keys must have been previously released
48− if (aVolumeKeyWasReleased)
49− bothVolumeKeysPressed();
50− aVolumeKeyWasReleased = false;
51− } else if (volumeDownKeyPressed) {
52− volumeDownPressed();
53− } else if (volumeUpKeyPressed) {
54− volumeUpPressed();
55− }
56− }
57−
58− function onKeyReleased(key) {
59− if (key == Qt.Key_VolumeUp) {
60− volumeUpKeyPressed = false;
61− aVolumeKeyWasReleased = true;
62− } else if (key == Qt.Key_VolumeDown) {
63− volumeDownKeyPressed = false;
64− aVolumeKeyWasReleased = true;
65− }
66− }
67−}