on xenial help sign in
Some visual updates and rotation lock for the virtual touchpad Fixes: #1549087

Approved by: Unity8 CI Bot, Albert Astals Cid

commit857f0f0bc1a0b61c219d1f3dc007d04dae3c00ef authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Mar 2016, 22:36 (11 years ago) parentcde6a49c2d8f1f
2 files changed+120−22
qml/DisabledScreenNotice.qml+44−20 tests/qmltests/tst_DisabledScreenNotice.qml+76−2
qml/DisabledScreenNotice.qml+44−20
@@ -17,6 +17,7 @@
1717import QtQuick 2.4
1818import QtQuick.Layouts 1.1
1919import Ubuntu.Components 1.3
20+import Unity.Session 0.1
2021import QtQuick.Window 2.2
2122import "Components"
2223
@@ -25,19 +26,36 @@ Item {
2526
2627 property bool infoNoteDisplayed: true
2728
28− WallpaperResolver {
29− width: root.width
30− id: wallpaperResolver
29+ // For testing
30+ property var screen: Screen
31+ property var orientationLock: OrientationLock
32+
33+ DeviceConfiguration {
34+ id: deviceConfiguration
35+ name: applicationArguments.deviceName
3136 }
3237
3338 Item {
3439 id: contentContainer
40+ objectName: "contentContainer"
3541 anchors.centerIn: parent
3642 height: rotation == 90 || rotation == 270 ? parent.width : parent.height
3743 width: rotation == 90 || rotation == 270 ? parent.height : parent.width
3844
45+ property int savedOrientation: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
46+ ? (root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation)
47+ : deviceConfiguration.primaryOrientation
48+
3949 rotation: {
40− switch (Screen.orientation) {
50+ var usedOrientation = root.screen.orientation;
51+
52+ if (root.orientationLock.enabled) {
53+ usedOrientation = savedOrientation;
54+ }
55+
56+ savedOrientation = usedOrientation;
57+
58+ switch (usedOrientation) {
4159 case Qt.PortraitOrientation:
4260 return 0;
4361 case Qt.LandscapeOrientation:
@@ -47,6 +65,8 @@ Item {
4765 case Qt.InvertedLandscapeOrientation:
4866 return 90;
4967 }
68+
69+ return 0;
5070 }
5171 transformOrigin: Item.Center
5272
@@ -60,9 +80,9 @@ Item {
6080 }
6181 }
6282
63− Image {
83+ Rectangle {
6484 anchors.fill: parent
65− source: wallpaperResolver.background
85+ color: "#3b3b3b"
6686 }
6787
6888 Item {
@@ -74,22 +94,26 @@ Item {
7494 UbuntuNumberAnimation { }
7595 }
7696
77− Rectangle {
78− anchors.fill: parent
79− color: "black"
80− opacity: 0.4
81− }
82−
83− Label {
84− id: text
97+ Column {
8598 anchors.centerIn: parent
8699 width: parent.width - units.gu(8)
87− text: i18n.tr("Your device is now connected to an external display. Use this screen as a touch pad to interact with the mouse.")
88− color: "white"
89− horizontalAlignment: Text.AlignHCenter
90− verticalAlignment: Text.AlignVCenter
91− fontSize: "x-large"
92− wrapMode: Text.Wrap
100+ spacing: units.gu(4)
101+
102+ Label {
103+ id: text
104+ text: i18n.tr("Your device is now connected to an external display. Use this screen as a touch pad to interact with the pointer.")
105+ color: "white"
106+ width: parent.width
107+ fontSize: "large"
108+ wrapMode: Text.Wrap
109+ }
110+ Icon {
111+ height: units.gu(8)
112+ width: height
113+ name: "input-touchpad-symbolic"
114+ color: "white"
115+ anchors.horizontalCenter: parent.horizontalCenter
116+ }
93117 }
94118 }
95119
tests/qmltests/tst_DisabledScreenNotice.qml+76−2
@@ -15,18 +15,62 @@
1515 */
1616
1717import QtQuick 2.4
18+import QtQuick.Layouts 1.1
1819import QtTest 1.0
1920import Unity.Test 0.1
21+import Ubuntu.Components 1.3
22+import Ubuntu.Components.ListItems 1.3
2023import "../../qml"
2124
2225Item {
2326 id: root
24− width: units.gu(40)
27+ width: units.gu(80)
2528 height: units.gu(70)
2629
2730 DisabledScreenNotice {
2831 id: touchScreenPad
2932 anchors.fill: parent
33+ anchors.rightMargin: units.gu(40)
34+
35+ screen: QtObject {
36+ property int orientation: {
37+ switch (orientationSelector.selectedIndex) {
38+ case 0:
39+ return Qt.PortraitOrientation;
40+ case 1:
41+ return Qt.LandscapeOrientation;
42+ case 2:
43+ return Qt.InvertedPortraitOrientation;
44+ case 3:
45+ return Qt.InvertedLandscapeOrientation;
46+ }
47+ }
48+ }
49+ orientationLock: QtObject {
50+ property bool enabled: orientationLockCheckBox.checked
51+ }
52+ }
53+
54+ Column {
55+ anchors.fill: parent
56+ anchors.leftMargin: units.gu(40)
57+
58+ ItemSelector {
59+ id: orientationSelector
60+ model: ["Portrait", "Landscape", "InvertedPortrait", "InvertedLandscape"]
61+ selectedIndex: 0
62+ }
63+
64+ RowLayout {
65+ CheckBox {
66+ id: orientationLockCheckBox
67+ checked: false
68+ }
69+ Label {
70+ text: "Rotation lock"
71+ Layout.fillWidth: true
72+ }
73+ }
3074 }
3175
3276 UnityTestCase {
@@ -36,10 +80,40 @@ Item {
3680
3781 function test_mouseAreaHidesOnFirstTap() {
3882 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39− print("noticeArea", noticeArea.visible)
4083 compare(noticeArea.visible, true)
4184 tap(root)
4285 tryCompare(noticeArea, "visible", false)
4386 }
87+
88+ function test_rotation_data() {
89+ return [
90+ {tag: "portrait", selectedOrientation: 0, expectedAngle: 0},
91+ {tag: "landscape", selectedOrientation: 1, expectedAngle: 270},
92+ {tag: "invertedportrait", selectedOrientation: 2, expectedAngle: 180},
93+ {tag: "invertetlandscape", selectedOrientation: 3, expectedAngle: 90}
94+ ];
95+ }
96+
97+ function test_rotation(data) {
98+ var content = findChild(touchScreenPad, "contentContainer");
99+
100+ var oldRotation = content.rotation;
101+
102+ // Turn on orientation lock
103+ orientationLockCheckBox.checked = true;
104+
105+ // simulate the rotation
106+ orientationSelector.selectedIndex = data.selectedOrientation;
107+
108+ // Make sure it is still in the old rotation (as we have the lock turned on)
109+ expectFail("", "Rotation lock set. Expecting automatic rotation to fail.");
110+ tryCompareFunction(function() { return content.rotation != oldRotation; }, true, 300);
111+
112+ // Now uncheck the rotation lock
113+ orientationLockCheckBox.checked = false;
114+
115+ // And make sure it catches up to the expected angle
116+ tryCompare(content, "rotation", data.expectedAngle);
117+ }
44118 }
45119}