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.0
19import Unity.Session 0.1
28 implicitWidth: units.gu(40)
29 implicitHeight: units.gu(71)
31 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
32 readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
34 readonly property int primaryOrientation:
35 deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
36 ? nativeOrientation : deviceConfiguration.primaryOrientation
39 id: deviceConfiguration
40 name: applicationArguments.deviceName
43 // to be overwritten by tests
44 property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
45 property int physicalOrientation: Screen.orientation
46 property bool orientationLocked: OrientationLock.enabled
47 property var orientationLock: OrientationLock
49 property int orientation
50 onPhysicalOrientationChanged: {
51 if (!orientationLocked) {
52 orientation = physicalOrientation;
55 onOrientationLockedChanged: {
56 if (orientationLocked) {
57 orientationLock.savedOrientation = physicalOrientation;
59 orientation = physicalOrientation;
62 Component.onCompleted: {
63 if (orientationLocked) {
64 orientation = orientationLock.savedOrientation;
68 readonly property int supportedOrientations: shell.supportedOrientations
69 & deviceConfiguration.supportedOrientations
70 property int acceptedOrientationAngle: {
71 if (orientation & supportedOrientations) {
72 return Screen.angleBetween(nativeOrientation, orientation);
73 } else if (shell.orientation & supportedOrientations) {
75 return shell.orientationAngle;
76 } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
77 return shell.mainAppWindowOrientationAngle;
79 // rotate to some supported orientation as we can't stay where we currently are
80 // TODO: Choose the closest to the current one
81 if (supportedOrientations & Qt.PortraitOrientation) {
82 return Screen.angleBetween(nativeOrientation, Qt.PortraitOrientation);
83 } else if (supportedOrientations & Qt.LandcscapeOrientation) {
84 return Screen.angleBetween(nativeOrientation, Qt.LandscapeOrientation);
85 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
86 return Screen.angleBetween(nativeOrientation, Qt.InvertedPortraitOrientation);
87 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
88 return Screen.angleBetween(nativeOrientation, Qt.InvertedLandscapeOrientation);
90 // if all fails, fallback to primary orientation
91 return Screen.angleBetween(nativeOrientation, primaryOrientation);
96 function angleToOrientation(angle) {
99 return nativeOrientation;
102 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
103 : Qt.PortraitOrientation;
106 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
107 : Qt.InvertedLandscapeOrientation;
110 return nativeOrientation === Qt.PortraitOrientation ? Qt.LandscapeOrientation
111 : Qt.InvertedPortraitOrientation;
114 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
115 return primaryOrientation;
121 objectName: "rotationStates"
124 shellCover: shellCover
125 windowScreenshot: windowScreenshot
133 orientation: root.angleToOrientation(orientationAngle)
134 primaryOrientation: root.primaryOrientation
135 nativeOrientation: root.nativeOrientation
136 nativeWidth: root.width
137 nativeHeight: root.height
139 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
140 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
142 if (root.usageModeSettings.usageMode === "Windowed") {
144 } else if (root.usageModeSettings.usageMode === "Staged"
145 && deviceConfiguration.category === "desktop") {
148 return deviceConfiguration.category;
152 property real transformRotationAngle
153 property real transformOriginX
154 property real transformOriginY
156 transform: Rotation {
157 origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
158 angle: shell.transformRotationAngle
175 property real transformRotationAngle
176 property real transformOriginX
177 property real transformOriginY
179 transform: Rotation {
180 origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
181 axis { x: 0; y: 0; z: 1 }
182 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