Lomiri
Loading...
Searching...
No Matches
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
17import QtQuick 2.15
18import QtQml 2.15
19import Utils 0.1
20
21QtObject {
22 id: root
23
24 // This allows to override device name, used for convergence
25 // to set screens to desktop "mode"
26 property var overrideName: false
27
28 readonly property int useNativeOrientation: -1
29
30 readonly property alias name: priv.name;
31
32 readonly property alias primaryOrientation: priv.primaryOrientation
33 readonly property alias supportedOrientations: priv.supportedOrientations
34 readonly property alias landscapeOrientation: priv.landscapeOrientation
35 readonly property alias invertedLandscapeOrientation: priv.invertedLandscapeOrientation
36 readonly property alias portraitOrientation: priv.portraitOrientation
37 readonly property alias invertedPortraitOrientation: priv.invertedPortraitOrientation
38
39 readonly property alias category: priv.category
40
41 readonly property var deviceConfig: DeviceConfig {}
42
43 readonly property var binding: Binding {
44 target: priv
45 property: "state"
46 value: root.overrideName ? overrideName : deviceConfig.name
47 restoreMode: Binding.RestoreBinding
48 }
49
50 readonly property var priv: StateGroup {
51 id: priv
52
53 property int primaryOrientation: deviceConfig.primaryOrientation == Qt.PrimaryOrientation ?
54 root.useNativeOrientation : deviceConfig.primaryOrientation
55
56 property int supportedOrientations: deviceConfig.supportedOrientations
57
58 property int landscapeOrientation: deviceConfig.landscapeOrientation
59 property int invertedLandscapeOrientation: deviceConfig.invertedLandscapeOrientation
60 property int portraitOrientation: deviceConfig.portraitOrientation
61 property int invertedPortraitOrientation: deviceConfig.invertedPortraitOrientation
62 property string category: deviceConfig.category
63 property string name: deviceConfig.name
64 property bool supportsMultiColorLed: deviceConfig.supportsMultiColorLed
65
66 states: [
67 State {
68 name: "mako"
69 PropertyChanges {
70 target: priv
71 primaryOrientation: root.useNativeOrientation
72 supportedOrientations: Qt.PortraitOrientation
73 | Qt.LandscapeOrientation
74 | Qt.InvertedLandscapeOrientation
75 landscapeOrientation: Qt.LandscapeOrientation
76 invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
77 portraitOrientation: Qt.PortraitOrientation
78 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
79 category: "phone"
80 name: "mako"
81 }
82 },
83 State {
84 name: "krillin"
85 PropertyChanges {
86 target: priv
87 primaryOrientation: root.useNativeOrientation
88 supportedOrientations: Qt.PortraitOrientation
89 | Qt.LandscapeOrientation
90 | Qt.InvertedLandscapeOrientation
91 landscapeOrientation: Qt.LandscapeOrientation
92 invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
93 portraitOrientation: Qt.PortraitOrientation
94 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
95 category: "phone"
96 name: "krillin"
97 }
98 },
99 State {
100 name: "arale"
101 PropertyChanges {
102 target: priv
103 primaryOrientation: root.useNativeOrientation
104 supportedOrientations: Qt.PortraitOrientation
105 | Qt.InvertedPortraitOrientation
106 | Qt.LandscapeOrientation
107 | Qt.InvertedLandscapeOrientation
108 landscapeOrientation: Qt.LandscapeOrientation
109 invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
110 portraitOrientation: Qt.PortraitOrientation
111 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
112 supportsMultiColorLed: false
113 category: "phone"
114 name: "arale"
115 }
116 },
117 State {
118 name: "manta"
119 PropertyChanges {
120 target: priv
121 primaryOrientation: root.useNativeOrientation
122 supportedOrientations: Qt.PortraitOrientation
123 | Qt.InvertedPortraitOrientation
124 | Qt.LandscapeOrientation
125 | Qt.InvertedLandscapeOrientation
126 landscapeOrientation: Qt.LandscapeOrientation
127 invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
128 portraitOrientation: Qt.PortraitOrientation
129 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
130 category: "tablet"
131 name: "manta"
132 }
133 },
134 State {
135 name: "flo"
136 PropertyChanges {
137 target: priv
138 primaryOrientation: Qt.InvertedLandscapeOrientation
139 supportedOrientations: Qt.PortraitOrientation
140 | Qt.InvertedPortraitOrientation
141 | Qt.LandscapeOrientation
142 | Qt.InvertedLandscapeOrientation
143 landscapeOrientation: Qt.InvertedLandscapeOrientation
144 invertedLandscapeOrientation: Qt.LandscapeOrientation
145 portraitOrientation: Qt.PortraitOrientation
146 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
147 category: "tablet"
148 name: "flo"
149 }
150 },
151 State {
152 name: "desktop"
153 PropertyChanges {
154 target: priv
155 primaryOrientation: root.useNativeOrientation
156 supportedOrientations: root.useNativeOrientation
157 landscapeOrientation: Qt.LandscapeOrientation
158 invertedLandscapeOrientation: Qt.InvertedLandscapeOrientation
159 portraitOrientation: Qt.PortraitOrientation
160 invertedPortraitOrientation: Qt.InvertedPortraitOrientation
161 category: "desktop"
162 name: "desktop"
163 }
164 },
165 State {
166 name: "turbo"
167 PropertyChanges {
168 target: priv
169 supportsMultiColorLed: false
170 }
171 }
172 ]
173 }
174}