on xenial help sign in
Some visual updates and rotation lock for the virtual touchpad Fixes: #1549087
857f0f0Michael Zanetti
qml/DisabledScreenNotice.qml+44−20
@@ -17,6 +17,7 @@
17import QtQuick 2.4
17import QtQuick 2.4
18import QtQuick.Layouts 1.1
18import QtQuick.Layouts 1.1
19import Ubuntu.Components 1.3
19import Ubuntu.Components 1.3
20+import Unity.Session 0.1
20import QtQuick.Window 2.2
21import QtQuick.Window 2.2
21import "Components"
22import "Components"
22
23
@@ -25,19 +26,36 @@ Item {
25
26
26 property bool infoNoteDisplayed: true
27 property bool infoNoteDisplayed: true
27
28
28− WallpaperResolver {
29+ // For testing
29− width: root.width
30+ property var screen: Screen
30− id: wallpaperResolver
31+ property var orientationLock: OrientationLock
32+
33+ DeviceConfiguration {
34+ id: deviceConfiguration
35+ name: applicationArguments.deviceName
31 }
36 }
32
37
33 Item {
38 Item {
34 id: contentContainer
39 id: contentContainer
40+ objectName: "contentContainer"
35 anchors.centerIn: parent
41 anchors.centerIn: parent
36 height: rotation == 90 || rotation == 270 ? parent.width : parent.height
42 height: rotation == 90 || rotation == 270 ? parent.width : parent.height
37 width: rotation == 90 || rotation == 270 ? parent.height : parent.width
43 width: rotation == 90 || rotation == 270 ? parent.height : parent.width
38
44
45+ property int savedOrientation: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
46+ ? (root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation)
47+ : deviceConfiguration.primaryOrientation
48+
39 rotation: {
49 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) {
41 case Qt.PortraitOrientation:
59 case Qt.PortraitOrientation:
42 return 0;
60 return 0;
43 case Qt.LandscapeOrientation:
61 case Qt.LandscapeOrientation:
@@ -47,6 +65,8 @@ Item {
47 case Qt.InvertedLandscapeOrientation:
65 case Qt.InvertedLandscapeOrientation:
48 return 90;
66 return 90;
49 }
67 }
68+
69+ return 0;
50 }
70 }
51 transformOrigin: Item.Center
71 transformOrigin: Item.Center
52
72
@@ -60,9 +80,9 @@ Item {
60 }
80 }
61 }
81 }
62
82
63− Image {
83+ Rectangle {
64 anchors.fill: parent
84 anchors.fill: parent
65− source: wallpaperResolver.background
85+ color: "#3b3b3b"
66 }
86 }
67
87
68 Item {
88 Item {
@@ -74,22 +94,26 @@ Item {
74 UbuntuNumberAnimation { }
94 UbuntuNumberAnimation { }
75 }
95 }
76
96
77− Rectangle {
97+ Column {
78− anchors.fill: parent
79− color: "black"
80− opacity: 0.4
81− }
82−
83− Label {
84− id: text
85 anchors.centerIn: parent
98 anchors.centerIn: parent
86 width: parent.width - units.gu(8)
99 width: parent.width - units.gu(8)
100+ spacing: units.gu(4)
101+
102+ Label {
103+ id: text
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.")
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.")
88− color: "white"
105+ color: "white"
89− horizontalAlignment: Text.AlignHCenter
106+ width: parent.width
90− verticalAlignment: Text.AlignVCenter
91− fontSize: "x-large"
107+ fontSize: "large"
92− wrapMode: Text.Wrap
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+ }
93 }
117 }
94 }
118 }
95
119
tests/qmltests/tst_DisabledScreenNotice.qml+76−2
@@ -15,18 +15,62 @@
15 */
15 */
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import Unity.Test 0.1
20import Unity.Test 0.1
21+import Ubuntu.Components 1.3
22+import Ubuntu.Components.ListItems 1.3
20import "../../qml"
23import "../../qml"
21
24
22Item {
25Item {
23 id: root
26 id: root
24− width: units.gu(40)
27+ width: units.gu(80)
25 height: units.gu(70)
28 height: units.gu(70)
26
29
27 DisabledScreenNotice {
30 DisabledScreenNotice {
28 id: touchScreenPad
31 id: touchScreenPad
29 anchors.fill: parent
32 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+ }
30 }
74 }
31
75
32 UnityTestCase {
76 UnityTestCase {
@@ -36,10 +80,40 @@ Item {
36
80
37 function test_mouseAreaHidesOnFirstTap() {
81 function test_mouseAreaHidesOnFirstTap() {
38 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
82 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39− print("noticeArea", noticeArea.visible)
40 compare(noticeArea.visible, true)
83 compare(noticeArea.visible, true)
41 tap(root)
84 tap(root)
42 tryCompare(noticeArea, "visible", false)
85 tryCompare(noticeArea, "visible", false)
43 }
86 }
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+ }
44 }
118 }
45}
119}