on xenial help sign in
merge prereq
commit02d1a22f9cfb6c2f4991d3e93caa97342e9d6c08 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 26 Jan 2016, 16:29 (11 years ago) parent9e9055aace44c0
4 files changed+25−15
qml/Components/VirtualTouchPad.qml+10−6 qml/DisabledScreenNotice.qml+8−5 tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1 tests/qmltests/tst_DisabledScreenNotice.qml+4−3
qml/Components/VirtualTouchPad.qml+10−6
@@ -24,6 +24,7 @@ Item {
2424 Component.onDestruction: removeMouse();
2525 }
2626
27+ readonly property bool pressed: point1.pressed || point2.pressed
2728
2829 MultiPointTouchArea {
2930 objectName: "touchPadArea"
@@ -32,7 +33,8 @@ Item {
3233 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
3334 readonly property int clickThreshold: units.gu(1.5)
3435 property bool isClick: false
35− property bool pressed: false
36+ property bool isDoubleClick: false
37+ property bool isDrag: false
3638
3739 onPressed: {
3840 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
@@ -41,7 +43,7 @@ Item {
4143 && clickTimer.running) {
4244 clickTimer.stop();
4345 uinput.pressMouse(UInput.ButtonLeft)
44− pressed = true;
46+ isDoubleClick = true;
4547 }
4648 isClick = true;
4749 }
@@ -58,14 +60,15 @@ Item {
5860 }
5961
6062 onReleased: {
63+ if (isDoubleClick || isDrag) {
64+ uinput.releaseMouse(UInput.ButtonLeft)
65+ isDoubleClick = false;
66+ }
6167 if (isClick) {
62− if (pressed) {
63− uinput.releaseMouse(UInput.ButtonLeft)
64− pressed = false;
65− }
6668 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
6769 }
6870 isClick = false;
71+ isDrag = false;
6972 }
7073
7174 Timer {
@@ -89,6 +92,7 @@ Item {
8992 (Math.abs(tp.x - tp.startX) > clickThreshold ||
9093 Math.abs(tp.y - tp.startY) > clickThreshold)) {
9194 isClick = false;
95+ isDrag = true;
9296 }
9397
9498 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
qml/DisabledScreenNotice.qml+8−5
@@ -52,6 +52,12 @@ Item {
5252
5353 VirtualTouchPad {
5454 anchors.fill: parent
55+
56+ onPressedChanged: {
57+ if (pressed && infoNoteDisplayed) {
58+ infoNoteDisplayed = false;
59+ }
60+ }
5561 }
5662
5763 Image {
@@ -59,18 +65,15 @@ Item {
5965 source: wallpaperResolver.background
6066 }
6167
62− MouseArea {
63− objectName: "infoNoticeMouseArea"
68+ Item {
69+ objectName: "infoNoticeArea"
6470 anchors.fill: parent
6571 opacity: infoNoteDisplayed ? 1 : 0
6672 visible: opacity > 0
67− enabled: visible
6873 Behavior on opacity {
6974 UbuntuNumberAnimation { }
7075 }
7176
72− onClicked: root.infoNoteDisplayed = false;
73−
7477 Rectangle {
7578 anchors.fill: parent
7679 color: "black"
tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1
@@ -101,12 +101,14 @@ Item {
101101
102102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
103103
104− tap(touchPadArea)
104+ mouseClick(touchPadArea)
105105 mousePress(touchPadArea)
106+ mouseMove(touchPadArea, touchPadArea.width / 4, touchPadArea.height / 4)
106107
107108 tryCompare(mouseEventSpy1, "count", 1)
108109 tryCompare(mouseEventSpy2, "count", 0)
109110 mouseRelease(touchPadArea)
111+ tryCompare(mouseEventSpy2, "count", 1)
110112 }
111113
112114 function test_twoFingerScroll() {
tests/qmltests/tst_DisabledScreenNotice.qml+4−3
@@ -35,10 +35,11 @@ Item {
3535 when: windowShown
3636
3737 function test_mouseAreaHidesOnFirstTap() {
38− var mouseArea = findChild(touchScreenPad, "infoNoticeMouseArea")
39− compare(mouseArea.enabled, true)
38+ var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39+ print("noticeArea", noticeArea.visible)
40+ compare(noticeArea.visible, true)
4041 tap(root)
41− tryCompare(mouseArea, "enabled", false)
42+ tryCompare(noticeArea, "visible", false)
4243 }
4344 }
4445}