Unity 8
AbstractStage.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 Ubuntu.Components 1.3
19 import GlobalShortcut 1.0
20 import GSettings 1.0
21 
22 FocusScope {
23  id: root
24 
25  // Controls to be set from outside
26  property QtObject applicationManager
27  property QtObject topLevelSurfaceList
28  property bool altTabPressed
29  property url background
30  property bool beingResized
31  property int dragAreaWidth
32  property real dragProgress // How far left the stage has been dragged, used externally by tutorial code
33  property bool interactive
34  property real inverseProgress // This is the progress for left edge drags, in pixels.
35  property bool keepDashRunning: true
36  property real maximizedAppTopMargin
37  property real nativeHeight
38  property real nativeWidth
39  property QtObject orientations
40  property int shellOrientation
41  property int shellOrientationAngle
42  property bool spreadEnabled: true // If false, animations and right edge will be disabled
43  property bool suspended
44  // A Stage should paint a wallpaper etc over its full size but not use the margins for window placement
45  property int leftMargin: 0
46  property alias paintBackground: background.visible
47  property bool oskEnabled: false
48 
49  // To be read from outside
50  property var mainApp: null
51  property int mainAppWindowOrientationAngle: 0
52  property bool orientationChangesEnabled
53  property int supportedOrientations: Qt.PortraitOrientation
54  | Qt.LandscapeOrientation
55  | Qt.InvertedPortraitOrientation
56  | Qt.InvertedLandscapeOrientation
57 
58  property Item itemConfiningMouseCursor: null
59 
60 
61  signal stageAboutToBeUnloaded
62  signal itemSnapshotRequested(Item item)
63 
64  // Shared code for use in stage implementations
65  GSettings {
66  id: lifecycleExceptions
67  schema.id: "com.canonical.qtmir"
68  }
69 
70  function isExemptFromLifecycle(appId) {
71  var shortAppId = appId.split('_')[0];
72  for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
73  if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
74  return true;
75  }
76  }
77  return false;
78  }
79 
80  Rectangle {
81  id: background
82  color: "#060606"
83  anchors.fill: parent
84  }
85 
86  // shared Alt+F4 functionality
87  function closeFocusedDelegate() {} // to be implemented by stages
88 
89  GlobalShortcut {
90  shortcut: Qt.AltModifier|Qt.Key_F4
91  onTriggered: closeFocusedDelegate()
92  }
93 }