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.4
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  property bool infoNoteDisplayed: true
28 
29  // For testing
30  property var screen: Screen
31  property var orientationLock: OrientationLock
32 
33  DeviceConfiguration {
34  id: deviceConfiguration
35  name: applicationArguments.deviceName
36  }
37 
38  Item {
39  id: contentContainer
40  objectName: "contentContainer"
41  anchors.centerIn: parent
42  height: rotation == 90 || rotation == 270 ? parent.width : parent.height
43  width: rotation == 90 || rotation == 270 ? parent.height : parent.width
44 
45  property int savedOrientation: deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
46  ? (root.width > root.height ? Qt.LandscapeOrientation : Qt.PortraitOrientation)
47  : deviceConfiguration.primaryOrientation
48 
49  rotation: {
50  var usedOrientation = root.screen.orientation;
51 
52  if (root.orientationLock.enabled) {
53  usedOrientation = savedOrientation;
54  }
55 
56  savedOrientation = usedOrientation;
57 
58  switch (usedOrientation) {
59  case Qt.PortraitOrientation:
60  return 0;
61  case Qt.LandscapeOrientation:
62  return 270;
63  case Qt.InvertedPortraitOrientation:
64  return 180;
65  case Qt.InvertedLandscapeOrientation:
66  return 90;
67  }
68 
69  return 0;
70  }
71  transformOrigin: Item.Center
72 
73  VirtualTouchPad {
74  anchors.fill: parent
75 
76  onPressedChanged: {
77  if (pressed && infoNoteDisplayed) {
78  infoNoteDisplayed = false;
79  }
80  }
81  }
82 
83  Rectangle {
84  anchors.fill: parent
85  color: "#3b3b3b"
86  }
87 
88  Item {
89  objectName: "infoNoticeArea"
90  anchors.fill: parent
91  opacity: infoNoteDisplayed ? 1 : 0
92  visible: opacity > 0
93  Behavior on opacity {
94  UbuntuNumberAnimation { }
95  }
96 
97  Column {
98  anchors.centerIn: parent
99  width: parent.width - units.gu(8)
100  spacing: units.gu(4)
101 
102  Label {
103  id: text
104  text: i18n.tr("Your device is now connected to an external display. Use this screen as a touch pad to interact with the pointer.")
105  color: "white"
106  width: parent.width
107  fontSize: "large"
108  wrapMode: Text.Wrap
109  }
110  Icon {
111  height: units.gu(8)
112  width: height
113  name: "input-touchpad-symbolic"
114  color: "white"
115  anchors.horizontalCenter: parent.horizontalCenter
116  }
117  }
118  }
119 
120  InputMethod {
121  id: inputMethod
122  objectName: "inputMethod"
123  anchors.fill: parent
124  }
125  }
126 }