Lomiri
ShellScreen.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
17import QtQuick 2.12
18import Lomiri.Components 1.3
19import WindowManager 1.0
20import Cursor 1.1
21import "Components"
22
23ScreenWindow {
24 id: screenWindow
25
26 color: "black"
27 title: "Lomiri Shell"
28
29 property int screenIndex: -1
30 property bool primary: {
31 if (loader.sourceComponent == disabledScreenComponent)
32 return false;
33
34 // If this is the only screen then it's the primary one
35 if (Screens.count === 1)
36 return true;
37
38 const thisFormFactor = screenWindow.screen.formFactor;
39
40 // Tablet & phone devices can only have 2 screens at max
41 if (Screens.count === 2) {
42 const internalFormFactor = Screens.get(0).formFactor;
43
44 if (thisFormFactor === internalFormFactor === Screen.Tablet)
45 return true;
46
47 if (internalFormFactor === Screen.Phone && thisFormFactor !== Screen.Phone)
48 return true;
49
50 if (internalFormFactor === Screen.Phone && thisFormFactor === Screen.Phone)
51 return false;
52 }
53
54 return (Screens.count >= 1 && screenIndex === 0);
55 }
56
57 Loader {
58 id: loader
59 width: screenWindow.width
60 height: screenWindow.height
61
62 sourceComponent: {
63 if (Screens.count > 1 && screenWindow.screen.formFactor === Screen.Phone) {
64 return disabledScreenComponent;
65 }
66 return shellComponent;
67 }
68 }
69
70 Component {
71 id: shellComponent
72 OrientedShell {
73 implicitWidth: screenWindow.width
74 implicitHeight: screenWindow.height
75 screen: screenWindow.screen
76 visible: true
77
78 deviceConfiguration {
79 overrideName: Screens.count > 1 ? "desktop" : false
80 }
81 }
82 }
83
84 Component {
85 id: disabledScreenComponent
86 DisabledScreenNotice {
87 screen: screenWindow.screen
88 oskEnabled: Screens.count > 1
89 }
90 }
91}