Unity 8
 All Classes Functions Properties
RunningApplicationsGrid.qml
1 /*
2  * Copyright (C) 2013 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.0
18 import "../../Components"
19 
20 import Ubuntu.Gestures 0.1
21 import Unity.Application 0.1
22 
23 ResponsiveFlowView {
24  id: root
25  clip: true
26 
27  signal updateScreenshots
28  property alias enableHeightBehavior: heightBehaviour.enabled
29  property bool enableHeightBehaviorOnNextCreation: model.count === 0
30 
31  Behavior on height {
32  id: heightBehaviour
33  enabled: false
34  NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
35  }
36 
37  Connections {
38  target: root.model
39  onCountChanged: {
40  heightBehaviour.enabled = true;
41  }
42  }
43 
44  property bool canEnableTerminationMode: true
45 
46  onCanEnableTerminationModeChanged: {
47  if (!canEnableTerminationMode)
48  terminationModeEnabled = false
49  }
50 
51  // when false, it means it's on activation mode
52  property bool terminationModeEnabled: false
53 
54  maximumNumberOfColumns: 10
55  minimumHorizontalSpacing: units.gu(2)
56  referenceDelegateWidth: units.gu(11)
57  verticalSpacing: units.gu(2)
58 
59  delegate: Item {
60  width: runningAppTile.width + root.horizontalSpacing
61  height: runningAppTile.height + root.verticalSpacing
62 
63  RunningApplicationTile {
64  id: runningAppTile
65  objectName: "runningAppTile " + model.name
66  anchors {
67  top: parent.top
68  horizontalCenter: parent.horizontalCenter
69  }
70  application: model
71  onRequestedActivationMode: { root.terminationModeEnabled = false }
72  onRequestedTerminationMode: {
73  if (canEnableTerminationMode)
74  root.terminationModeEnabled = true
75  }
76  onRequestedApplicationTermination: {
77  ApplicationManager.stopApplication(model.appId)
78  }
79  onRequestedApplicationActivation: {
80  ApplicationManager.requestFocusApplication(model.appId)
81  }
82 
83  terminationModeEnabled: root.terminationModeEnabled
84  }
85  }
86 
87  move: Transition {
88  NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutCubic }
89  }
90 
91  MouseArea {
92  anchors.fill: parent
93  z: -1 // behind all RunningApplicationTiles
94  enabled: root.terminationModeEnabled
95  onPressed: { root.terminationModeEnabled = false; }
96  }
97 
98  PressedOutsideNotifier {
99  anchors.fill: parent
100  enabled: root.terminationModeEnabled
101  onPressedOutside: {
102  root.terminationModeEnabled = false;
103  }
104  }
105 }