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
21import Unity.Screens 0.1
26// Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
27import Ubuntu.Components 1.3
33 implicitWidth: units.gu(40)
34 implicitHeight: units.gu(71)
37 id: deviceConfiguration
38 name: applicationArguments.deviceName
41 property alias orientations: d.orientations
46 property Orientations orientations: Orientations {
48 // NB: native and primary orientations here don't map exactly to their QScreen counterparts
49 native_: root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
51 primary: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
52 ? native_ : deviceConfiguration.primaryOrientation
54 landscape: deviceConfiguration.landscapeOrientation
55 invertedLandscape: deviceConfiguration.invertedLandscapeOrientation
56 portrait: deviceConfiguration.portraitOrientation
57 invertedPortrait: deviceConfiguration.invertedPortraitOrientation
63 schema.id: "com.canonical.Unity8"
68 objectName: "oskSettings"
69 schema.id: "com.canonical.keyboard.maliit"
72 property int physicalOrientation: Screen.orientation
73 property bool orientationLocked: OrientationLock.enabled
74 property var orientationLock: OrientationLock
78 deviceFilter: InputInfo.Mouse
79 property int oldCount: 0
84 deviceFilter: InputInfo.TouchPad
85 property int oldCount: 0
90 deviceFilter: InputInfo.Keyboard
91 onDeviceAdded: forceOSKEnabled = autopilotDevicePresent();
92 onDeviceRemoved: forceOSKEnabled = autopilotDevicePresent();
97 deviceFilter: InputInfo.TouchScreen
100 readonly property int pointerInputDevices: miceModel.count + touchPadModel.count
101 onPointerInputDevicesChanged: calculateUsageMode()
103 function calculateUsageMode() {
104 if (unity8Settings.usageMode === undefined)
105 return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
107 console.log("Pointer input devices changed:", pointerInputDevices, "current mode:", unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount)
108 if (unity8Settings.usageMode === "Windowed") {
109 if (pointerInputDevices === 0) {
110 // All pointer devices have been unplugged. Move to staged.
111 unity8Settings.usageMode = "Staged";
114 if (Math.min(root.width, root.height) > units.gu(60)) {
115 if (pointerInputDevices > 0 && pointerInputDevices > miceModel.oldCount + touchPadModel.oldCount) {
116 unity8Settings.usageMode = "Windowed";
119 // Make sure we initialize to something sane
120 unity8Settings.usageMode = "Staged";
123 miceModel.oldCount = miceModel.count;
124 touchPadModel.oldCount = touchPadModel.count;
127 /* FIXME: This exposes the NameRole as a work arround for lp:1542224.
128 * When QInputInfo exposes NameRole to QML, this should be removed.
130 property bool forceOSKEnabled: false
131 property var autopilotEmulatedDeviceNames: ["py-evdev-uinput"]
132 UnitySortFilterProxyModel {
134 model: keyboardsModel
137 function autopilotDevicePresent() {
138 for(var i = 0; i < autopilotDevices.count; i++) {
139 var device = autopilotDevices.get(i);
140 if (autopilotEmulatedDeviceNames.indexOf(device.name) != -1) {
141 console.warn("Forcing the OSK to be enabled as there is an autopilot eumlated device present.")
152 property int orientation
153 onPhysicalOrientationChanged: {
154 if (!orientationLocked) {
155 orientation = physicalOrientation;
158 onOrientationLockedChanged: {
159 if (orientationLocked) {
160 orientationLock.savedOrientation = physicalOrientation;
162 orientation = physicalOrientation;
165 Component.onCompleted: {
166 if (orientationLocked) {
167 orientation = orientationLock.savedOrientation;
170 calculateUsageMode();
172 // We need to manually update this on startup as the binding
173 // below doesn't seem to have any effect at that stage
174 oskSettings.disableHeight = !shell.oskEnabled || shell.usageScenario == "desktop"
177 // we must rotate to a supported orientation regardless of shell's preference
178 property bool orientationChangesEnabled:
179 (shell.orientation & supportedOrientations) === 0 ? true
180 : shell.orientationChangesEnabled
184 property: "disableHeight"
185 value: !shell.oskEnabled || shell.usageScenario == "desktop"
188 readonly property int supportedOrientations: shell.supportedOrientations
189 & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
190 ? orientations.native_
191 : deviceConfiguration.supportedOrientations)
193 property int acceptedOrientationAngle: {
194 if (orientation & supportedOrientations) {
195 return Screen.angleBetween(orientations.native_, orientation);
196 } else if (shell.orientation & supportedOrientations) {
198 return shell.orientationAngle;
199 } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
200 return shell.mainAppWindowOrientationAngle;
202 // rotate to some supported orientation as we can't stay where we currently are
203 // TODO: Choose the closest to the current one
204 if (supportedOrientations & Qt.PortraitOrientation) {
205 return Screen.angleBetween(orientations.native_, Qt.PortraitOrientation);
206 } else if (supportedOrientations & Qt.LandscapeOrientation) {
207 return Screen.angleBetween(orientations.native_, Qt.LandscapeOrientation);
208 } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
209 return Screen.angleBetween(orientations.native_, Qt.InvertedPortraitOrientation);
210 } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
211 return Screen.angleBetween(orientations.native_, Qt.InvertedLandscapeOrientation);
213 // if all fails, fallback to primary orientation
214 return Screen.angleBetween(orientations.native_, orientations.primary);
219 function angleToOrientation(angle) {
222 return orientations.native_;
224 return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
225 : Qt.PortraitOrientation;
227 return orientations.native_ === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
228 : Qt.InvertedLandscapeOrientation;
230 return orientations.native_ === Qt.PortraitOrientation ? Qt.LandscapeOrientation
231 : Qt.InvertedPortraitOrientation;
233 console.warn("angleToOrientation: Invalid orientation angle: " + angle);
234 return orientations.primary;
240 objectName: "rotationStates"
243 shellCover: shellCover
244 windowScreenshot: windowScreenshot
252 orientation: root.angleToOrientation(orientationAngle)
253 orientations: root.orientations
254 nativeWidth: root.width
255 nativeHeight: root.height
256 mode: applicationArguments.mode
257 hasMouse: miceModel.count + touchPadModel.count > 0
258 // TODO: Factor in if the current screen is a touch screen and if the user wants to
259 // have multiple keyboards around. For now we only enable one keyboard at a time
260 // thus hiding it here if there is a physical one around or if we have a second
261 // screen (the virtual touchpad & osk on the phone) attached.
262 oskEnabled: (keyboardsModel.count === 0 && screens.count === 1) ||
266 if (unity8Settings.usageMode === "Windowed") {
269 if (deviceConfiguration.category === "phone") {
277 property real transformRotationAngle
278 property real transformOriginX
279 property real transformOriginY
281 transform: Rotation {
282 origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
283 angle: shell.transformRotationAngle
300 property real transformRotationAngle
301 property real transformOriginX
302 property real transformOriginY
304 transform: Rotation {
305 origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
306 axis { x: 0; y: 0; z: 1 }
307 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