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
42 Component.onCompleted: {
43 // We need to manually update this on startup as the binding
44 // below doesn't seem to have any effect at that stage
45 oskSettings.stayHidden = keyboards > 0
46 oskSettings.disableHeight = shell.usageScenario == "desktop"
52 schema.id: "com.canonical.keyboard.maliit"
57 property: "stayHidden"
58 value: inputInfo.keyboards > 0
63 property: "disableHeight"
64 value: shell.usageScenario == "desktop"
67 // to be overwritten by tests
68 property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
69 property int physicalOrientation: Screen.orientation
70 property bool orientationLocked: OrientationLock.enabled
71 property var orientationLock: OrientationLock
73 property int orientation
74 onPhysicalOrientationChanged: {
75 if (!orientationLocked) {
76 orientation = physicalOrientation;
79 onOrientationLockedChanged: {
80 if (orientationLocked) {
81 orientationLock.savedOrientation = physicalOrientation;
83 orientation = physicalOrientation;
86 Component.onCompleted: {
87 if (orientationLocked) {
88 orientation = orientationLock.savedOrientation;
92 readonly property int supportedOrientations: shell.supportedOrientations
93 & deviceConfiguration.supportedOrientations
94 property int acceptedOrientationAngle: {
95 if (orientation & supportedOrientations) {
96 return Screen.angleBetween(nativeOrientation, orientation);
97 } else if (shell.orientation & supportedOrientations) {
99 return shell.orientationAngle;
100 } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
101 return shell.mainAppWindowOrientationAngle;
103 // rotate to some supported orientation as we can't stay where we currently are
104 // TODO: Choose the closest to the current one
105 if (supportedOrientations & Qt.PortraitOrientation) {
106 return Screen.angleBetween(nativeOrientation, Qt.PortraitOrientation);
107 } else if (supportedOrientations & Qt.LandcscapeOrientation) {
108 return Screen.angleBetween(nativeOrientation, Qt.LandscapeOrientation);
109 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
110 return Screen.angleBetween(nativeOrientation, Qt.InvertedPortraitOrientation);
111 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
112 return Screen.angleBetween(nativeOrientation, Qt.InvertedLandscapeOrientation);
114 // if all fails, fallback to primary orientation
115 return Screen.angleBetween(nativeOrientation, primaryOrientation);
120 function angleToOrientation(angle) {
123 return nativeOrientation;
126 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
127 : Qt.PortraitOrientation;
130 return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
131 : Qt.InvertedLandscapeOrientation;
134 return nativeOrientation === Qt.PortraitOrientation ? Qt.LandscapeOrientation
135 : Qt.InvertedPortraitOrientation;
138 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
139 return primaryOrientation;
145 objectName: "rotationStates"
148 shellCover: shellCover
149 windowScreenshot: windowScreenshot
157 orientation: root.angleToOrientation(orientationAngle)
158 primaryOrientation: root.primaryOrientation
159 nativeOrientation: root.nativeOrientation
160 nativeWidth: root.width
161 nativeHeight: root.height
163 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
164 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
166 if (root.usageModeSettings.usageMode === "Windowed") {
168 } else if (root.usageModeSettings.usageMode === "Staged") {
169 if (deviceConfiguration.category === "phone") {
174 } else { // automatic
175 if (inputInfo.mice > 0) {
178 return deviceConfiguration.category;
183 property real transformRotationAngle
184 property real transformOriginX
185 property real transformOriginY
187 transform: Rotation {
188 origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
189 angle: shell.transformRotationAngle
206 property real transformRotationAngle
207 property real transformOriginX
208 property real transformOriginY
210 transform: Rotation {
211 origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
212 axis { x: 0; y: 0; z: 1 }
213 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