Unity 8
DeviceConfiguration.qml
1 /*
2  * Copyright (C) 2015-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 Utils 0.1
19 
20 QtObject {
21  id: root
22 
23  readonly property int useNativeOrientation: -1
24 
25  // The only writable property in the API
26  // all other properties are set according to the device name
27  property alias name: priv.state
28 
29  readonly property alias primaryOrientation: priv.primaryOrientation
30  readonly property alias supportedOrientations: priv.supportedOrientations
31  readonly property alias landscapeOrientation: priv.landscapeOrientation
32  readonly property alias invertedLandscapeOrientation: priv.invertedLandscapeOrientation
33  readonly property alias portraitOrientation: priv.portraitOrientation
34  readonly property alias invertedPortraitOrientation: priv.invertedPortraitOrientation
35 
36  readonly property alias category: priv.category
37 
38  readonly property alias supportsMultiColorLed: priv.supportsMultiColorLed
39 
40  readonly property var deviceConfigParser: DeviceConfigParser {
41  name: root.name
42  }
43 
44  readonly property var priv: StateGroup {
45  id: priv
46 
47  property int primaryOrientation: deviceConfigParser.primaryOrientation == Qt.PrimaryOrientation ?
48  root.useNativeOrientation : deviceConfigParser.primaryOrientation
49 
50  property int supportedOrientations: deviceConfigParser.supportedOrientations
51 
52  property int landscapeOrientation: deviceConfigParser.landscapeOrientation
53  property int invertedLandscapeOrientation: deviceConfigParser.invertedLandscapeOrientation
54  property int portraitOrientation: deviceConfigParser.portraitOrientation
55  property int invertedPortraitOrientation: deviceConfigParser.invertedPortraitOrientation
56  property string category: deviceConfigParser.category
57  property bool supportsMultiColorLed: deviceConfigParser.supportsMultiColorLed
58 
59  states: [
60  State {
61  name: "mako"
62  PropertyChanges {
63  target: priv
64  primaryOrientation: root.useNativeOrientation
65  supportedOrientations: Qt.PortraitOrientation
66  | Qt.LandscapeOrientation
67  | Qt.InvertedLandscapeOrientation
68  landscapeOrientation: Qt.LandscapeOrientation
69  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
70  portraitOrientation: Qt.PortraitOrientation
71  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
72  category: "phone"
73  }
74  },
75  State {
76  name: "krillin"
77  PropertyChanges {
78  target: priv
79  primaryOrientation: root.useNativeOrientation
80  supportedOrientations: Qt.PortraitOrientation
81  | Qt.LandscapeOrientation
82  | Qt.InvertedLandscapeOrientation
83  landscapeOrientation: Qt.LandscapeOrientation
84  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
85  portraitOrientation: Qt.PortraitOrientation
86  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
87  category: "phone"
88  }
89  },
90  State {
91  name: "arale"
92  PropertyChanges {
93  target: priv
94  primaryOrientation: root.useNativeOrientation
95  supportedOrientations: Qt.PortraitOrientation
96  | Qt.InvertedPortraitOrientation
97  | Qt.LandscapeOrientation
98  | Qt.InvertedLandscapeOrientation
99  landscapeOrientation: Qt.LandscapeOrientation
100  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
101  portraitOrientation: Qt.PortraitOrientation
102  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
103  supportsMultiColorLed: false
104  category: "phone"
105  }
106  },
107  State {
108  name: "manta"
109  PropertyChanges {
110  target: priv
111  primaryOrientation: root.useNativeOrientation
112  supportedOrientations: Qt.PortraitOrientation
113  | Qt.InvertedPortraitOrientation
114  | Qt.LandscapeOrientation
115  | Qt.InvertedLandscapeOrientation
116  landscapeOrientation: Qt.LandscapeOrientation
117  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
118  portraitOrientation: Qt.PortraitOrientation
119  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
120  category: "tablet"
121  }
122  },
123  State {
124  name: "flo"
125  PropertyChanges {
126  target: priv
127  primaryOrientation: Qt.InvertedLandscapeOrientation
128  supportedOrientations: Qt.PortraitOrientation
129  | Qt.InvertedPortraitOrientation
130  | Qt.LandscapeOrientation
131  | Qt.InvertedLandscapeOrientation
132  landscapeOrientation: Qt.InvertedLandscapeOrientation
133  invertedLandscapeOrientation: Qt.LandscapeOrientation
134  portraitOrientation: Qt.PortraitOrientation
135  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
136  category: "tablet"
137  }
138  },
139  State {
140  name: "desktop"
141  PropertyChanges {
142  target: priv
143  primaryOrientation: root.useNativeOrientation
144  supportedOrientations: root.useNativeOrientation
145  landscapeOrientation: Qt.LandscapeOrientation
146  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
147  portraitOrientation: Qt.PortraitOrientation
148  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
149  category: "desktop"
150  }
151  },
152  State {
153  name: "turbo"
154  PropertyChanges {
155  target: priv
156  supportsMultiColorLed: false
157  }
158  }
159  ]
160  }
161 }