on fac1153 help sign in
unity8/Dash/Apps/RunningApplicationTile.qml
139 lines 4.1 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 Ubuntu.Components 0.1
19import Unity.Application 0.1
20import "../../Components/"
21import "../../Components/ListItems"
23AbstractButton {
24 id: root
25 property var application
26 property bool __sideStageEnabled: shell.applicationManager.sideStageEnabled
28 signal requestedApplicationActivation(var application)
29 signal requestedApplicationTermination(var application)
30 signal requestedActivationMode()
31 signal requestedTerminationMode()
33 // Was: childrenRect.height
34 // To avoid "binding loop" warning
35 height: shapedApplicationImage.height + labelContainer.height
37 width: shapedApplicationImage.width
39 property bool terminationModeEnabled: false
41 onClicked: {
42 if (!terminationModeEnabled)
43 requestedApplicationActivation(application)
44 }
46 onPressAndHold: {
47 if (terminationModeEnabled) {
48 requestedActivationMode()
49 } else {
50 requestedTerminationMode()
51 }
52 }
54 function updateScreenshotFromCache() {
55 applicationImage.updateFromCache();
56 }
58 // FIXME: should use UbuntuShape from SDK
59 UbuntuShapeForItem {
60 id: shapedApplicationImage
61 anchors {
62 top: parent.top
63 horizontalCenter: parent.horizontalCenter
64 }
66 // FIXME: width and height should be defined according to the
67 // application window's aspect ratio.
68 width: (application.stage === ApplicationInfo.MainStage && __sideStageEnabled) ?
69 units.gu(22) : units.gu(11)
70 height: (__sideStageEnabled) ? units.gu(22) : units.gu(19)
71 radius: "medium"
72 image: applicationImage
73 }
75 ApplicationImage {
76 id: applicationImage
77 source: ApplicationManager.findApplication((application) ? application.appId : "")
78 width: shapedApplicationImage.width
79 height: shapedApplicationImage.height
80 }
82 UbuntuShape {
83 id: borderPressed
85 anchors.fill: shapedApplicationImage
86 radius: "medium"
87 borderSource: "radius_pressed.sci"
88 opacity: root.pressed ? 1.0 : 0.0
89 Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
90 }
92 // FIXME: label code duplicated with Tile
93 Item {
94 id: labelContainer
95 anchors {
96 left: parent.left
97 right: parent.right
98 top: shapedApplicationImage.bottom
99 }
100 height: units.gu(2)
102 Label {
103 id: label
104 anchors {
105 baseline: parent.bottom
106 left: parent.left
107 right: parent.right
108 }
109 text: (application) ? application.name : ""
111 color: Theme.palette.selected.backgroundText
112 opacity: 0.9
113 style: Text.Raised
114 styleColor: "black"
115 fontSize: "small"
116 elide: Text.ElideMiddle
117 horizontalAlignment: Text.AlignHCenter
118 }
119 }
121 CloseIcon {
122 objectName: "closeIcon " + model.name
123 anchors {
124 left: shapedApplicationImage.left
125 leftMargin: -units.gu(1)
126 top: parent.top
127 topMargin: -units.gu(1)
128 }
129 height: units.gu(6)
130 width: units.gu(6)
131 id: closeIcon
132 enabled: root.terminationModeEnabled
134 MouseArea {
135 anchors { fill: parent; margins: -units.gu(1) }
136 onClicked: requestedApplicationTermination(application)
137 }
138 }