Changeset View
Changeset View
Standalone View
Standalone View
sfos/qml/pages/mousepad.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.0 | ||||
22 | import Sailfish.Silica 1.0 | ||||
23 | import org.kde.kdeconnect 1.0 | ||||
24 | | ||||
25 | Page | ||||
26 | { | ||||
27 | id: mousepad | ||||
28 | property QtObject pluginInterface | ||||
29 | backNavigation: false | ||||
30 | | ||||
31 | Column | ||||
32 | { | ||||
33 | anchors.fill: parent | ||||
34 | PageHeader { | ||||
35 | id: header | ||||
36 | title: "Remote Control" | ||||
37 | } | ||||
38 | MouseArea { | ||||
39 | id: area | ||||
40 | width: parent.width | ||||
41 | height: parent.height - buttons.height - header.height - 20 | ||||
42 | property var lastPos: Qt.point(-1, -1) | ||||
43 | | ||||
44 | //onClicked: mousepad.pluginInterface.sendCommand("singleclick", true); | ||||
45 | | ||||
46 | onPositionChanged: { | ||||
47 | if (lastPos.x > -1) { | ||||
48 | //console.log("move", mouse.x, mouse.y, lastPos) | ||||
49 | var delta = Qt.point(mouse.x-lastPos.x, mouse.y-lastPos.y); | ||||
50 | | ||||
51 | pluginInterface.moveCursor(delta); | ||||
52 | } | ||||
53 | lastPos = Qt.point(mouse.x, mouse.y); | ||||
54 | } | ||||
55 | onReleased: { | ||||
56 | lastPos = Qt.point(-1, -1) | ||||
57 | } | ||||
58 | } | ||||
59 | Row { | ||||
60 | id: buttons | ||||
61 | height: childrenRect.height | ||||
62 | width: parent.width | ||||
63 | | ||||
64 | Button { | ||||
65 | width: parent.width / 3 | ||||
66 | text: "Single" | ||||
67 | onClicked: mousepad.pluginInterface.sendCommand("singleclick", true); | ||||
68 | } | ||||
69 | Button { | ||||
70 | width: parent.width / 3 | ||||
71 | text: "Middle" | ||||
72 | onClicked: mousepad.pluginInterface.sendCommand("middleclick", true); | ||||
73 | } | ||||
74 | Button { | ||||
75 | width: parent.width / 3 | ||||
76 | text: "Right" | ||||
77 | onClicked: mousepad.pluginInterface.sendCommand("rightclick", true); | ||||
78 | } | ||||
79 | } | ||||
80 | } | ||||
81 | | ||||
82 | function myPop() { | ||||
83 | pageStack._pageStackIndicator._backPageIndicator().data[0].clicked.disconnect(myPop) | ||||
84 | pageStack.pop() | ||||
85 | } | ||||
86 | | ||||
87 | onStatusChanged: { | ||||
88 | if (status == PageStatus.Active) { | ||||
89 | pageStack._createPageIndicator() | ||||
90 | pageStack._pageStackIndicator.clickablePageIndicators = true | ||||
91 | pageStack._pageStackIndicator._backPageIndicator().backNavigation = true | ||||
92 | pageStack._pageStackIndicator._backPageIndicator().data[0].clicked.connect(myPop) | ||||
93 | } else if (status == PageStatus.Deactivating) { | ||||
94 | pageStack._pageStackIndicator.clickablePageIndicators = Qt.binding(function() { | ||||
95 | return pageStack.currentPage ? pageStack.currentPage._clickablePageIndicators : true | ||||
96 | }) | ||||
97 | pageStack._pageStackIndicator._backPageIndicator().backNavigation = Qt.binding(function() { | ||||
98 | return pageStack._currentContainer && pageStack._currentContainer.page | ||||
99 | && pageStack._currentContainer.page.backNavigation && pageStack._currentContainer.pageStackIndex !== 0 | ||||
100 | }) | ||||
101 | } | ||||
102 | } | ||||
103 | | ||||
104 | } |