on xenial help sign in
move the hide/reveal functions to Cursor.qml
5d64150Lukáš Tinkl
plugins/Cursor/Cursor.qml+20
@@ -19,10 +19,30 @@ import Cursor 1.0 // For MousePointer
19
19
20MousePointer {
20MousePointer {
21 id: mousePointer
21 id: mousePointer
22+ opacity: cursorVisible ? 1 : 0
23+
24+ property bool cursorVisible: visible // initial value, based on shell.hasMouse
22
25
23 Image {
26 Image {
24 x: -mousePointer.hotspotX
27 x: -mousePointer.hotspotX
25 y: -mousePointer.hotspotY
28 y: -mousePointer.hotspotY
26 source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
29 source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
27 }
30 }
31+
32+ QtObject {
33+ id: d
34+ property bool touchDetected: false;
35+ }
36+
37+ function hideCursor() {
38+ d.touchDetected = true;
39+ cursorVisible = false;
40+ }
41+
42+ function revealCursor() {
43+ if (d.touchDetected) {
44+ d.touchDetected = false;
45+ cursorVisible = true;
46+ }
47+ }
28}
48}
qml/Shell.qml+2−22
@@ -56,7 +56,6 @@ Item {
56 property bool beingResized
56 property bool beingResized
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58 property string mode: "full-greeter"
58 property string mode: "full-greeter"
59− property bool cursorVisible: false
60 function updateFocusedAppOrientation() {
59 function updateFocusedAppOrientation() {
61 applicationsDisplayLoader.item.updateFocusedAppOrientation();
60 applicationsDisplayLoader.item.updateFocusedAppOrientation();
62 }
61 }
@@ -132,24 +131,6 @@ Item {
132 shell.activateApplication(app);
131 shell.activateApplication(app);
133 }
132 }
134
133
135− QtObject {
136− id: cursorPriv
137− property bool touchDetected: false;
138−
139− function hideCursor() {
140− touchDetected = true;
141− shell.cursorVisible = false;
142− }
143−
144− function revealCursor() {
145− if (touchDetected) {
146− touchDetected = false;
147− //Mir.cursorName = "";
148− shell.cursorVisible = true;
149− }
150− }
151− }
152−
153 Binding {
134 Binding {
154 target: LauncherModel
135 target: LauncherModel
155 property: "applicationManager"
136 property: "applicationManager"
@@ -197,7 +178,7 @@ Item {
197
178
198 WindowInputMonitor {
179 WindowInputMonitor {
199 onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
180 onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
200− onTouchBegun: { cursorPriv.hideCursor(); }
181+ onTouchBegun: { cursor.hideCursor(); }
201 onTouchEnded: {
182 onTouchEnded: {
202 // move the (hidden) cursor to the last known touch position
183 // move the (hidden) cursor to the last known touch position
203 cursor.x = pos.x;
184 cursor.x = pos.x;
@@ -688,7 +669,6 @@ Item {
688 id: cursor
669 id: cursor
689 visible: shell.hasMouse
670 visible: shell.hasMouse
690 z: screenGrabber.z + 1
671 z: screenGrabber.z + 1
691− opacity: shell.cursorVisible ? 1 : 0
692
672
693 onPushedLeftBoundary: {
673 onPushedLeftBoundary: {
694 if (buttons === Qt.NoButton) {
674 if (buttons === Qt.NoButton) {
@@ -704,7 +684,7 @@ Item {
704 }
684 }
705
685
706 onMouseMoved: {
686 onMouseMoved: {
707− cursorPriv.revealCursor();
687+ cursor.revealCursor();
708 }
688 }
709 }
689 }
710
690