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 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
29 readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
31 readonly property int primaryOrientation:
32 deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
33 ? nativeOrientation : deviceConfiguration.primaryOrientation
36 id: deviceConfiguration
37 name: applicationArguments.deviceName
40 // to be overwritten by tests
41 property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
42 property int physicalOrientation: Screen.orientation
43 property bool orientationLocked: OrientationLock.enabled
44 property var orientationLock: OrientationLock
46 property int orientation
47 onPhysicalOrientationChanged: {
48 if (!orientationLocked) {
49 orientation = physicalOrientation;
52 onOrientationLockedChanged: {
53 if (orientationLocked) {
54 orientationLock.savedOrientation = physicalOrientation;
56 orientation = physicalOrientation;
59 Component.onCompleted: {
60 if (orientationLocked) {
61 orientation = orientationLock.savedOrientation;
65 readonly property int supportedOrientations: shell.supportedOrientations
66 & deviceConfiguration.supportedOrientations
67 property int acceptedOrientationAngle: {
68 if (orientation & supportedOrientations) {
69 return Screen.angleBetween(nativeOrientation, orientation);
70 } else if (shell.orientation & supportedOrientations) {
72 return shell.orientationAngle;
73 } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
74 return shell.mainAppWindowOrientationAngle;
76 // rotate to some supported orientation as we can't stay where we currently are
77 // TODO: Choose the closest to the current one
78 if (supportedOrientations & Qt.PortraitOrientation) {
79 return Screen.angleBetween(nativeOrientation, Qt.PortraitOrientation);
80 } else if (supportedOrientations & Qt.LandcscapeOrientation) {
81 return Screen.angleBetween(nativeOrientation, Qt.LandscapeOrientation);
82 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
83 return Screen.angleBetween(nativeOrientation, Qt.InvertedPortraitOrientation);
84 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
85 return Screen.angleBetween(nativeOrientation, Qt.InvertedLandscapeOrientation);
87 // if all fails, fallback to primary orientation
88 return Screen.angleBetween(nativeOrientation, primaryOrientation);
93 function angleToOrientation(angle) {
96 return nativeOrientation;
99 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
100 : Qt.PortraitOrientation;
103 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
104 : Qt.InvertedLandscapeOrientation;
107 return nativeOrientation === Qt.PortraitOrientation ? Qt.LandscapeOrientation
108 : Qt.InvertedPortraitOrientation;
111 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
112 return primaryOrientation;
118 objectName: "rotationStates"
121 shellCover: shellCover
122 windowScreenshot: windowScreenshot
130 orientation: root.angleToOrientation(orientationAngle)
131 primaryOrientation: root.primaryOrientation
132 nativeOrientation: root.nativeOrientation
133 nativeWidth: root.width
134 nativeHeight: root.height
136 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
137 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
139 if (root.usageModeSettings.usageMode === "Windowed") {
141 } else if (root.usageModeSettings.usageMode === "Staged"
142 && deviceConfiguration.category === "desktop") {
145 return deviceConfiguration.category;
149 property real transformRotationAngle
150 property real transformOriginX
151 property real transformOriginY
153 transform: Rotation {
154 origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
155 angle: shell.transformRotationAngle
172 property real transformRotationAngle
173 property real transformOriginX
174 property real transformOriginY
176 transform: Rotation {
177 origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
178 axis { x: 0; y: 0; z: 1 }
179 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