on fec22fa help sign in
unity8/Dash/Apps/RunningApplicationsGrid.qml
103 lines 3.3 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"
20ResponsiveFlowView {
21 id: root
22 clip: true
24 signal updateScreenshots
25 property alias enableHeightBehavior: heightBehaviour.enabled
26 property bool enableHeightBehaviorOnNextCreation: firstModel.count + secondModel.count == 0
28 Connections {
29 target: shell
30 onDashShownChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
31 onStageScreenshotsReadyChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
32 }
34 Behavior on height {
35 id: heightBehaviour
36 enabled: false
37 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
38 }
40 Connections {
41 target: root.firstModel
42 onCountChanged: {
43 heightBehaviour.enabled = true;
44 }
45 }
46 Connections {
47 target: root.secondModel
48 onCountChanged: {
49 heightBehaviour.enabled = true;
50 }
51 }
53 property bool canEnableTerminationMode: true
55 onCanEnableTerminationModeChanged: {
56 if (!canEnableTerminationMode)
57 terminationModeEnabled = false
58 }
60 // when false, it means it's on activation mode
61 property bool terminationModeEnabled: false
63 maximumNumberOfColumns: 10
64 minimumHorizontalSpacing: units.gu(2)
65 referenceDelegateWidth: units.gu(11)
66 verticalSpacing: units.gu(2)
68 delegate: Item {
69 width: runningAppTile.width + root.horizontalSpacing
70 height: runningAppTile.height + root.verticalSpacing
72 RunningApplicationTile {
73 id: runningAppTile
74 objectName: "runningAppTile " + model.name
75 anchors {
76 top: parent.top
77 horizontalCenter: parent.horizontalCenter
78 }
79 application: model
80 onRequestedActivationMode: { root.terminationModeEnabled = false }
81 onRequestedTerminationMode: {
82 if (canEnableTerminationMode)
83 root.terminationModeEnabled = true
84 }
85 onRequestedApplicationTermination: {
86 shell.applicationManager.stopApplication(model.appId)
87 }
88 onRequestedApplicationActivation: {
89 shell.activateApplication(model.appId)
90 }
92 terminationModeEnabled: root.terminationModeEnabled
94 Component.onCompleted: {
95 root.updateScreenshots.connect(updateScreenshotFromCache);
96 }
97 }
98 }
100 move: Transition {
101 NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutCubic }
102 }