@@ -32,20 +32,31 @@ Rectangle {
32 implicitWidth: units.gu(40)
32 implicitWidth: units.gu(40)
33 implicitHeight: units.gu(71)
33 implicitHeight: units.gu(71)
35− // NB: native and primary orientations here don't map exactly to their QScreen counterparts
36− readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
38− readonly property int primaryOrientation:
39− deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
40− ? nativeOrientation : deviceConfiguration.primaryOrientation
42 DeviceConfiguration {
35 DeviceConfiguration {
43 id: deviceConfiguration
36 id: deviceConfiguration
44 name: applicationArguments.deviceName
37 name: applicationArguments.deviceName
40+ property alias orientations: d.orientations
45+ property Orientations orientations: Orientations {
47+ // NB: native and primary orientations here don't map exactly to their QScreen counterparts
48+ native_: root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
50+ primary: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
51+ ? native_ : deviceConfiguration.primaryOrientation
53+ landscape: deviceConfiguration.landscapeOrientation
54+ invertedLandscape: deviceConfiguration.invertedLandscapeOrientation
55+ portrait: deviceConfiguration.portraitOrientation
56+ invertedPortrait: deviceConfiguration.invertedPortraitOrientation
48− // to be overwritten by tests
59+ // to be overwritten by tests
49 property var unity8Settings: Unity8Settings {}
60 property var unity8Settings: Unity8Settings {}
50 property var oskSettings: GSettings { schema.id: "com.canonical.keyboard.maliit" }
61 property var oskSettings: GSettings { schema.id: "com.canonical.keyboard.maliit" }
@@ -78,8 +89,8 @@ Rectangle {
79 // we must rotate to a supported orientation regardless of shell's preference
90 // we must rotate to a supported orientation regardless of shell's preference
80 property bool orientationChangesEnabled:
91 property bool orientationChangesEnabled:
81− (orientation & supportedOrientations) === 0 ? true
92+ (shell.orientation & supportedOrientations) === 0 ? true
82− : shell.orientationChangesEnabled
93+ : shell.orientationChangesEnabled
@@ -96,12 +107,12 @@ Rectangle {
97 readonly property int supportedOrientations: shell.supportedOrientations
108 readonly property int supportedOrientations: shell.supportedOrientations
98 & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
109 & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
99− ? nativeOrientation
110+ ? orientations.native_
100 : deviceConfiguration.supportedOrientations)
111 : deviceConfiguration.supportedOrientations)
102 property int acceptedOrientationAngle: {
113 property int acceptedOrientationAngle: {
103 if (orientation & supportedOrientations) {
114 if (orientation & supportedOrientations) {
104− return Screen.angleBetween(nativeOrientation, orientation);
115+ return Screen.angleBetween(orientations.native_, orientation);
105 } else if (shell.orientation & supportedOrientations) {
116 } else if (shell.orientation & supportedOrientations) {
106 // stay where we are
117 // stay where we are
107 return shell.orientationAngle;
118 return shell.orientationAngle;
@@ -111,16 +122,16 @@ Rectangle {
111 // rotate to some supported orientation as we can't stay where we currently are
122 // rotate to some supported orientation as we can't stay where we currently are
112 // TODO: Choose the closest to the current one
123 // TODO: Choose the closest to the current one
113 if (supportedOrientations & Qt.PortraitOrientation) {
124 if (supportedOrientations & Qt.PortraitOrientation) {
114− return Screen.angleBetween(nativeOrientation, Qt.PortraitOrientation);
125+ return Screen.angleBetween(orientations.native_, Qt.PortraitOrientation);
115 } else if (supportedOrientations & Qt.LandscapeOrientation) {
126 } else if (supportedOrientations & Qt.LandscapeOrientation) {
116− return Screen.angleBetween(nativeOrientation, Qt.LandscapeOrientation);
127+ return Screen.angleBetween(orientations.native_, Qt.LandscapeOrientation);
117 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
128 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
118− return Screen.angleBetween(nativeOrientation, Qt.InvertedPortraitOrientation);
129+ return Screen.angleBetween(orientations.native_, Qt.InvertedPortraitOrientation);
119 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
130 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
120− return Screen.angleBetween(nativeOrientation, Qt.InvertedLandscapeOrientation);
131+ return Screen.angleBetween(orientations.native_, Qt.InvertedLandscapeOrientation);
122 // if all fails, fallback to primary orientation
133 // if all fails, fallback to primary orientation
123− return Screen.angleBetween(nativeOrientation, primaryOrientation);
134+ return Screen.angleBetween(orientations.native_, orientations.primary);
@@ -128,19 +139,19 @@ Rectangle {
128 function angleToOrientation(angle) {
139 function angleToOrientation(angle) {
129 switch (angle) {
140 switch (angle) {
131− return nativeOrientation;
142+ return orientations.native_;
133− return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
144+ return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
134 : Qt.PortraitOrientation;
145 : Qt.PortraitOrientation;
135 case 180:
146 case 180:
136− return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
147+ return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
137 : Qt.InvertedLandscapeOrientation;
148 : Qt.InvertedLandscapeOrientation;
138 case 270:
149 case 270:
139− return nativeOrientation === Qt.PortraitOrientation ? Qt.LandscapeOrientation
150+ return orientations.native_ === Qt.PortraitOrientation ? Qt.LandscapeOrientation
140 : Qt.InvertedPortraitOrientation;
151 : Qt.InvertedPortraitOrientation;
142 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
153 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
143− return primaryOrientation;
154+ return orientations.primary;
@@ -159,8 +170,7 @@ Rectangle {
159 width: root.width
170 width: root.width
160 height: root.height
171 height: root.height
161 orientation: root.angleToOrientation(orientationAngle)
172 orientation: root.angleToOrientation(orientationAngle)
162− primaryOrientation: root.primaryOrientation
173+ orientations: root.orientations
163− nativeOrientation: root.nativeOrientation
164 nativeWidth: root.width
174 nativeWidth: root.width
165 nativeHeight: root.height
175 nativeHeight: root.height
166 mode: applicationArguments.mode
176 mode: applicationArguments.mode