Unity 8
DisabledScreenNotice.qml
1 /*
2  * Copyright (C) 2016 Canonical, Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  */
16 
17 import QtQuick 2.12
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
20 import Unity.Session 0.1
21 import QtQuick.Window 2.2
22 import "Components"
23 
24 Item {
25  id: root
26 
27  // For testing
28  property var screen: Screen
29  property var orientationLock: OrientationLock
30 
31  DeviceConfiguration {
32  id: deviceConfiguration
33  name: applicationArguments.deviceName
34  }
35 
36  Item {
37  id: contentContainer
38  objectName: "contentContainer"
39  anchors.centerIn: parent
40  height: rotation == 90 || rotation == 270 ? parent.width : parent.height
41  width: rotation == 90 || rotation == 270 ? parent.height : parent.width
42 
43  property int savedOrientation: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
44  ? (root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation)
45  : deviceConfiguration.primaryOrientation
46 
47  rotation: {
48  var usedOrientation = root.screen.orientation;
49 
50  if (root.orientationLock.enabled) {
51  usedOrientation = savedOrientation;
52  }
53 
54  savedOrientation = usedOrientation;
55 
56  switch (usedOrientation) {
57  case Qt.PortraitOrientation:
58  return 0;
59  case Qt.LandscapeOrientation:
60  return 270;
61  case Qt.InvertedPortraitOrientation:
62  return 180;
63  case Qt.InvertedLandscapeOrientation:
64  return 90;
65  }
66 
67  return 0;
68  }
69  transformOrigin: Item.Center
70 
71  Rectangle {
72  anchors.fill: parent
73  color: UbuntuColors.jet
74  }
75 
76  VirtualTouchPad {
77  objectName: "virtualTouchPad"
78  anchors.fill: parent
79  }
80  }
81 }