2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import QtQuick.Window 2.2
19import Unity.InputInfo 0.1
20import Unity.Session 0.1
24// Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
25import Ubuntu.Components 1.3
31 implicitWidth: units.gu(40)
32 implicitHeight: units.gu(71)
35 id: deviceConfiguration
36 name: applicationArguments.deviceName
39 property alias orientations: d.orientations
44 property Orientations orientations: Orientations {
46 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
47 native_: root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
49 primary: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
50 ? native_ : deviceConfiguration.primaryOrientation
52 landscape: deviceConfiguration.landscapeOrientation
53 invertedLandscape: deviceConfiguration.invertedLandscapeOrientation
54 portrait: deviceConfiguration.portraitOrientation
55 invertedPortrait: deviceConfiguration.invertedPortraitOrientation
58 // to be overwritten by tests
59 property var unity8Settings: Unity8Settings {}
60 property var oskSettings: GSettings { schema.id: "com.canonical.keyboard.maliit" }
62 property int physicalOrientation: Screen.orientation
63 property bool orientationLocked: OrientationLock.enabled
64 property var orientationLock: OrientationLock
68 deviceFilter: InputInfo.Mouse
73 deviceFilter: InputInfo.Keyboard
76 property int orientation
77 onPhysicalOrientationChanged: {
78 if (!orientationLocked) {
79 orientation = physicalOrientation;
82 onOrientationLockedChanged: {
83 if (orientationLocked) {
84 orientationLock.savedOrientation = physicalOrientation;
86 orientation = physicalOrientation;
89 Component.onCompleted: {
90 if (orientationLocked) {
91 orientation = orientationLock.savedOrientation;
93 // We need to manually update this on startup as the binding
94 // below doesn't seem to have any effect at that stage
95 oskSettings.stayHidden = keyboardsModel.count > 0
96 oskSettings.disableHeight = shell.usageScenario == "desktop"
99 // we must rotate to a supported orientation regardless of shell's preference
100 property bool orientationChangesEnabled:
101 (shell.orientation & supportedOrientations) === 0 ? true
102 : shell.orientationChangesEnabled
107 property: "stayHidden"
108 value: keyboardsModel.count > 0
113 property: "disableHeight"
114 value: shell.usageScenario == "desktop"
117 readonly property int supportedOrientations: shell.supportedOrientations
118 & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
119 ? orientations.native_
120 : deviceConfiguration.supportedOrientations)
122 property int acceptedOrientationAngle: {
123 if (orientation & supportedOrientations) {
124 return Screen.angleBetween(orientations.native_, orientation);
125 } else if (shell.orientation & supportedOrientations) {
127 return shell.orientationAngle;
128 } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
129 return shell.mainAppWindowOrientationAngle;
131 // rotate to some supported orientation as we can't stay where we currently are
132 // TODO: Choose the closest to the current one
133 if (supportedOrientations & Qt.PortraitOrientation) {
134 return Screen.angleBetween(orientations.native_, Qt.PortraitOrientation);
135 } else if (supportedOrientations & Qt.LandscapeOrientation) {
136 return Screen.angleBetween(orientations.native_, Qt.LandscapeOrientation);
137 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
138 return Screen.angleBetween(orientations.native_, Qt.InvertedPortraitOrientation);
139 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
140 return Screen.angleBetween(orientations.native_, Qt.InvertedLandscapeOrientation);
142 // if all fails, fallback to primary orientation
143 return Screen.angleBetween(orientations.native_, orientations.primary);
148 function angleToOrientation(angle) {
151 return orientations.native_;
153 return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
154 : Qt.PortraitOrientation;
156 return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
157 : Qt.InvertedLandscapeOrientation;
159 return orientations.native_ === Qt.PortraitOrientation ? Qt.LandscapeOrientation
160 : Qt.InvertedPortraitOrientation;
162 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
163 return orientations.primary;
169 objectName: "rotationStates"
172 shellCover: shellCover
173 windowScreenshot: windowScreenshot
181 orientation: root.angleToOrientation(orientationAngle)
182 orientations: root.orientations
183 nativeWidth: root.width
184 nativeHeight: root.height
185 mode: applicationArguments.mode
186 hasMouse: miceModel.count > deviceConfiguration.ignoredMice
188 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
189 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
191 if (root.unity8Settings.usageMode === "Windowed") {
193 } else if (root.unity8Settings.usageMode === "Staged") {
194 if (deviceConfiguration.category === "phone") {
199 } else { // automatic
200 if (miceModel.count > deviceConfiguration.ignoredMice) {
203 return deviceConfiguration.category;
208 property real transformRotationAngle
209 property real transformOriginX
210 property real transformOriginY
212 transform: Rotation {
213 origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
214 angle: shell.transformRotationAngle
231 property real transformRotationAngle
232 property real transformOriginX
233 property real transformOriginY
235 transform: Rotation {
236 origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
237 axis { x: 0; y: 0; z: 1 }
238 angle: windowScreenshot.transformRotationAngle
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list