Lomiri
Loading...
Searching...
No Matches
Orientations.qml
1/*
2 * Copyright 2015 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.12
18
19QtObject {
20 id: root
21
22 // Just because "native" is a reserved keyword :(
23 property int native_: Qt.PortraitOrientation
24
25 property int primary: Qt.PortraitOrientation
26
27 property int landscape: Qt.LandscapeOrientation
28 property int invertedLandscape: Qt.InvertedLandscapeOrientation
29 property int portrait: Qt.PortraitOrientation
30 property int invertedPortrait: Qt.InvertedPortraitOrientation
31
32 function map(orientations) {
33 var result = 0;
34
35 if (orientations & Qt.PortraitOrientation) {
36 result |= root.portrait;
37 }
38
39 if (orientations & Qt.InvertedPortraitOrientation) {
40 result |= root.invertedPortrait;
41 }
42
43 if (orientations & Qt.LandscapeOrientation) {
44 result |= root.landscape;
45 }
46
47 if (orientations & Qt.InvertedLandscapeOrientation) {
48 result |= root.invertedLandscape;
49 }
50
51 if (result == 0) {
52 result = root.primary;
53 }
54
55 return result;
56 }
57}