on xenial help sign in
move the hide/reveal functions to Cursor.qml
commit5d641503f3cde1b5263d1cacd68ad8711993718f authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 3 Dec 2015, 00:29 (11 years ago) parentfc18645
2 files changed+22−22
plugins/Cursor/Cursor.qml+20 qml/Shell.qml+2−22
plugins/Cursor/Cursor.qml+20
@@ -19,10 +19,30 @@ import Cursor 1.0 // For MousePointer
1919
2020MousePointer {
2121 id: mousePointer
22+ opacity: cursorVisible ? 1 : 0
23+
24+ property bool cursorVisible: visible // initial value, based on shell.hasMouse
2225
2326 Image {
2427 x: -mousePointer.hotspotX
2528 y: -mousePointer.hotspotY
2629 source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
2730 }
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+ }
2848}
qml/Shell.qml+2−22
@@ -56,7 +56,6 @@ Item {
5656 property bool beingResized
5757 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
5858 property string mode: "full-greeter"
59− property bool cursorVisible: false
6059 function updateFocusedAppOrientation() {
6160 applicationsDisplayLoader.item.updateFocusedAppOrientation();
6261 }
@@ -132,24 +131,6 @@ Item {
132131 shell.activateApplication(app);
133132 }
134133
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−
153134 Binding {
154135 target: LauncherModel
155136 property: "applicationManager"
@@ -197,7 +178,7 @@ Item {
197178
198179 WindowInputMonitor {
199180 onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
200− onTouchBegun: { cursorPriv.hideCursor(); }
181+ onTouchBegun: { cursor.hideCursor(); }
201182 onTouchEnded: {
202183 // move the (hidden) cursor to the last known touch position
203184 cursor.x = pos.x;
@@ -688,7 +669,6 @@ Item {
688669 id: cursor
689670 visible: shell.hasMouse
690671 z: screenGrabber.z + 1
691− opacity: shell.cursorVisible ? 1 : 0
692672
693673 onPushedLeftBoundary: {
694674 if (buttons === Qt.NoButton) {
@@ -704,7 +684,7 @@ Item {
704684 }
705685
706686 onMouseMoved: {
707− cursorPriv.revealCursor();
687+ cursor.revealCursor();
708688 }
709689 }
710690