on xenial help sign in
merge prereq
02d1a22Michael Zanetti
qml/Components/VirtualTouchPad.qml+10−6
@@ -24,6 +24,7 @@ Item {
24 Component.onDestruction: removeMouse();
24 Component.onDestruction: removeMouse();
25 }
25 }
26
26
27+ readonly property bool pressed: point1.pressed || point2.pressed
27
28
28 MultiPointTouchArea {
29 MultiPointTouchArea {
29 objectName: "touchPadArea"
30 objectName: "touchPadArea"
@@ -32,7 +33,8 @@ Item {
32 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
33 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
33 readonly property int clickThreshold: units.gu(1.5)
34 readonly property int clickThreshold: units.gu(1.5)
34 property bool isClick: false
35 property bool isClick: false
35− property bool pressed: false
36+ property bool isDoubleClick: false
37+ property bool isDrag: false
36
38
37 onPressed: {
39 onPressed: {
38 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
40 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
@@ -41,7 +43,7 @@ Item {
41 && clickTimer.running) {
43 && clickTimer.running) {
42 clickTimer.stop();
44 clickTimer.stop();
43 uinput.pressMouse(UInput.ButtonLeft)
45 uinput.pressMouse(UInput.ButtonLeft)
44− pressed = true;
46+ isDoubleClick = true;
45 }
47 }
46 isClick = true;
48 isClick = true;
47 }
49 }
@@ -58,14 +60,15 @@ Item {
58 }
60 }
59
61
60 onReleased: {
62 onReleased: {
63+ if (isDoubleClick || isDrag) {
64+ uinput.releaseMouse(UInput.ButtonLeft)
65+ isDoubleClick = false;
66+ }
61 if (isClick) {
67 if (isClick) {
62− if (pressed) {
63− uinput.releaseMouse(UInput.ButtonLeft)
64− pressed = false;
65− }
66 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
68 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
67 }
69 }
68 isClick = false;
70 isClick = false;
71+ isDrag = false;
69 }
72 }
70
73
71 Timer {
74 Timer {
@@ -89,6 +92,7 @@ Item {
89 (Math.abs(tp.x - tp.startX) > clickThreshold ||
92 (Math.abs(tp.x - tp.startX) > clickThreshold ||
90 Math.abs(tp.y - tp.startY) > clickThreshold)) {
93 Math.abs(tp.y - tp.startY) > clickThreshold)) {
91 isClick = false;
94 isClick = false;
95+ isDrag = true;
92 }
96 }
93
97
94 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
98 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
qml/DisabledScreenNotice.qml+8−5
@@ -52,6 +52,12 @@ Item {
52
52
53 VirtualTouchPad {
53 VirtualTouchPad {
54 anchors.fill: parent
54 anchors.fill: parent
55+
56+ onPressedChanged: {
57+ if (pressed && infoNoteDisplayed) {
58+ infoNoteDisplayed = false;
59+ }
60+ }
55 }
61 }
56
62
57 Image {
63 Image {
@@ -59,18 +65,15 @@ Item {
59 source: wallpaperResolver.background
65 source: wallpaperResolver.background
60 }
66 }
61
67
62− MouseArea {
68+ Item {
63− objectName: "infoNoticeMouseArea"
69+ objectName: "infoNoticeArea"
64 anchors.fill: parent
70 anchors.fill: parent
65 opacity: infoNoteDisplayed ? 1 : 0
71 opacity: infoNoteDisplayed ? 1 : 0
66 visible: opacity > 0
72 visible: opacity > 0
67− enabled: visible
68 Behavior on opacity {
73 Behavior on opacity {
69 UbuntuNumberAnimation { }
74 UbuntuNumberAnimation { }
70 }
75 }
71
76
72− onClicked: root.infoNoteDisplayed = false;
73−
74 Rectangle {
77 Rectangle {
75 anchors.fill: parent
78 anchors.fill: parent
76 color: "black"
79 color: "black"
tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1
@@ -101,12 +101,14 @@ Item {
101
101
102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
103
103
104− tap(touchPadArea)
104+ mouseClick(touchPadArea)
105 mousePress(touchPadArea)
105 mousePress(touchPadArea)
106+ mouseMove(touchPadArea, touchPadArea.width / 4, touchPadArea.height / 4)
106
107
107 tryCompare(mouseEventSpy1, "count", 1)
108 tryCompare(mouseEventSpy1, "count", 1)
108 tryCompare(mouseEventSpy2, "count", 0)
109 tryCompare(mouseEventSpy2, "count", 0)
109 mouseRelease(touchPadArea)
110 mouseRelease(touchPadArea)
111+ tryCompare(mouseEventSpy2, "count", 1)
110 }
112 }
111
113
112 function test_twoFingerScroll() {
114 function test_twoFingerScroll() {
tests/qmltests/tst_DisabledScreenNotice.qml+4−3
@@ -35,10 +35,11 @@ Item {
35 when: windowShown
35 when: windowShown
36
36
37 function test_mouseAreaHidesOnFirstTap() {
37 function test_mouseAreaHidesOnFirstTap() {
38− var mouseArea = findChild(touchScreenPad, "infoNoticeMouseArea")
38+ var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39+ print("noticeArea", noticeArea.visible)
39− compare(mouseArea.enabled, true)
40+ compare(noticeArea.visible, true)
40 tap(root)
41 tap(root)
41− tryCompare(mouseArea, "enabled", false)
42+ tryCompare(noticeArea, "visible", false)
42 }
43 }
43 }
44 }
44}
45}