on fac1153 help sign in
unity8/Dash/Apps/RunningApplicationsGrid.qml
120 lines 3.7 kB history raw
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 */
17import QtQuick 2.0
18import "../../Components"
20import Ubuntu.Gestures 0.1
22ResponsiveFlowView {
23 id: root
24 clip: true
26 signal updateScreenshots
27 property alias enableHeightBehavior: heightBehaviour.enabled
28 property bool enableHeightBehaviorOnNextCreation: firstModel.count + secondModel.count == 0
30 Connections {
31 target: shell
32 onDashShownChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
33 onStageScreenshotsReadyChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
34 }
36 Behavior on height {
37 id: heightBehaviour
38 enabled: false
39 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
40 }
42 Connections {
43 target: root.firstModel
44 onCountChanged: {
45 heightBehaviour.enabled = true;
46 }
47 }
48 Connections {
49 target: root.secondModel
50 onCountChanged: {
51 heightBehaviour.enabled = true;
52 }
53 }
55 property bool canEnableTerminationMode: true
57 onCanEnableTerminationModeChanged: {
58 if (!canEnableTerminationMode)
59 terminationModeEnabled = false
60 }
62 // when false, it means it's on activation mode
63 property bool terminationModeEnabled: false
65 maximumNumberOfColumns: 10
66 minimumHorizontalSpacing: units.gu(2)
67 referenceDelegateWidth: units.gu(11)
68 verticalSpacing: units.gu(2)
70 delegate: Item {
71 width: runningAppTile.width + root.horizontalSpacing
72 height: runningAppTile.height + root.verticalSpacing
74 RunningApplicationTile {
75 id: runningAppTile
76 objectName: "runningAppTile " + model.name
77 anchors {
78 top: parent.top
79 horizontalCenter: parent.horizontalCenter
80 }
81 application: model
82 onRequestedActivationMode: { root.terminationModeEnabled = false }
83 onRequestedTerminationMode: {
84 if (canEnableTerminationMode)
85 root.terminationModeEnabled = true
86 }
87 onRequestedApplicationTermination: {
88 shell.applicationManager.stopApplication(model.appId)
89 }
90 onRequestedApplicationActivation: {
91 shell.activateApplication(model.appId)
92 }
94 terminationModeEnabled: root.terminationModeEnabled
96 Component.onCompleted: {
97 root.updateScreenshots.connect(updateScreenshotFromCache);
98 }
99 }
100 }
102 move: Transition {
103 NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutCubic }
104 }
106 MouseArea {
107 anchors.fill: parent
108 z: -1 // behind all RunningApplicationTiles
109 enabled: root.terminationModeEnabled
110 onPressed: { root.terminationModeEnabled = false; }
111 }
113 PressedOutsideNotifier {
114 anchors.fill: parent
115 enabled: root.terminationModeEnabled
116 onPressedOutside: {
117 root.terminationModeEnabled = false;
118 }
119 }