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 var deviceConfigParser: DeviceConfigParser {
39  name: root.name
40  }
41 
42  readonly property var priv: StateGroup {
43  id: priv
44 
45  property int primaryOrientation: deviceConfigParser.primaryOrientation == Qt.PrimaryOrientation ?
46  root.useNativeOrientation : deviceConfigParser.primaryOrientation
47 
48  property int supportedOrientations: deviceConfigParser.supportedOrientations
49 
50  property int landscapeOrientation: deviceConfigParser.landscapeOrientation
51  property int invertedLandscapeOrientation: deviceConfigParser.invertedLandscapeOrientation
52  property int portraitOrientation: deviceConfigParser.portraitOrientation
53  property int invertedPortraitOrientation: deviceConfigParser.invertedPortraitOrientation
54  property string category: deviceConfigParser.category
55 
56  states: [
57  State {
58  name: "mako"
59  PropertyChanges {
60  target: priv
61  primaryOrientation: root.useNativeOrientation
62  supportedOrientations: Qt.PortraitOrientation
63  | Qt.LandscapeOrientation
64  | Qt.InvertedLandscapeOrientation
65  landscapeOrientation: Qt.LandscapeOrientation
66  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
67  portraitOrientation: Qt.PortraitOrientation
68  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
69  category: "phone"
70  }
71  },
72  State {
73  name: "krillin"
74  PropertyChanges {
75  target: priv
76  primaryOrientation: root.useNativeOrientation
77  supportedOrientations: Qt.PortraitOrientation
78  | Qt.LandscapeOrientation
79  | Qt.InvertedLandscapeOrientation
80  landscapeOrientation: Qt.LandscapeOrientation
81  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
82  portraitOrientation: Qt.PortraitOrientation
83  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
84  category: "phone"
85  }
86  },
87  State {
88  name: "arale"
89  PropertyChanges {
90  target: priv
91  primaryOrientation: root.useNativeOrientation
92  supportedOrientations: Qt.PortraitOrientation
93  | Qt.LandscapeOrientation
94  | Qt.InvertedLandscapeOrientation
95  landscapeOrientation: Qt.LandscapeOrientation
96  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
97  portraitOrientation: Qt.PortraitOrientation
98  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
99  category: "phone"
100  }
101  },
102  State {
103  name: "manta"
104  PropertyChanges {
105  target: priv
106  primaryOrientation: root.useNativeOrientation
107  supportedOrientations: Qt.PortraitOrientation
108  | Qt.InvertedPortraitOrientation
109  | Qt.LandscapeOrientation
110  | Qt.InvertedLandscapeOrientation
111  landscapeOrientation: Qt.LandscapeOrientation
112  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
113  portraitOrientation: Qt.PortraitOrientation
114  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
115  category: "tablet"
116  }
117  },
118  State {
119  name: "flo"
120  PropertyChanges {
121  target: priv
122  primaryOrientation: Qt.InvertedLandscapeOrientation
123  supportedOrientations: Qt.PortraitOrientation
124  | Qt.InvertedPortraitOrientation
125  | Qt.LandscapeOrientation
126  | Qt.InvertedLandscapeOrientation
127  landscapeOrientation: Qt.InvertedLandscapeOrientation
128  invertedLandscapeOrientation: Qt.LandscapeOrientation
129  portraitOrientation: Qt.PortraitOrientation
130  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
131  category: "tablet"
132  }
133  },
134  State {
135  name: "desktop"
136  PropertyChanges {
137  target: priv
138  primaryOrientation: root.useNativeOrientation
139  supportedOrientations: root.useNativeOrientation
140  landscapeOrientation: Qt.LandscapeOrientation
141  invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
142  portraitOrientation: Qt.PortraitOrientation
143  invertedPortraitOrientation: Qt.InvertedPortraitOrientation
144  category: "desktop"
145  }
146  }
147  ]
148  }
149 }