on 2139c25 help sign in
unity8/Dash/Apps/RunningApplicationTile.qml
138 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 Ubuntu.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 requestedApplicationTermination(application)
44 else
45 requestedApplicationActivation(application)
46 }
48 onPressAndHold: {
49 if (terminationModeEnabled) {
50 requestedActivationMode()
51 } else {
52 requestedTerminationMode()
53 }
54 }
56 function updateScreenshotFromCache() {
57 applicationImage.updateFromCache();
58 }
60 // FIXME: should use UbuntuShape from SDK
61 UbuntuShapeForItem {
62 id: shapedApplicationImage
63 anchors {
64 top: parent.top
65 horizontalCenter: parent.horizontalCenter
66 }
68 // FIXME: width and height should be defined according to the
69 // application window's aspect ratio.
70 width: (application.stage === ApplicationInfo.MainStage && __sideStageEnabled) ?
71 units.gu(22) : units.gu(11)
72 height: (__sideStageEnabled) ? units.gu(22) : units.gu(19)
73 radius: "medium"
74 image: applicationImage
75 }
77 ApplicationImage {
78 id: applicationImage
79 source: application
80 width: shapedApplicationImage.width
81 height: shapedApplicationImage.height
82 fillMode: ApplicationImage.PreserveAspectCrop
83 }
85 UbuntuShape {
86 id: borderPressed
88 anchors.fill: shapedApplicationImage
89 radius: "medium"
90 borderSource: "radius_pressed.sci"
91 opacity: root.pressed ? 1.0 : 0.0
92 Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
93 }
95 // FIXME: label code duplicated with Tile
96 Item {
97 id: labelContainer
98 anchors {
99 left: parent.left
100 right: parent.right
101 top: shapedApplicationImage.bottom
102 }
103 height: units.gu(2)
105 Label {
106 id: label
107 anchors {
108 baseline: parent.bottom
109 left: parent.left
110 right: parent.right
111 leftMargin: units.gu(1)
112 rightMargin: units.gu(1)
113 }
114 text: (application) ? application.name : ""
116 color: Theme.palette.selected.backgroundText
117 opacity: 0.9
118 style: Text.Raised
119 styleColor: "black"
120 fontSize: "small"
121 elide: Text.ElideMiddle
122 horizontalAlignment: Text.AlignHCenter
123 }
124 }
126 CloseIcon {
127 anchors {
128 right: shapedApplicationImage.right
129 rightMargin: -units.gu(1)
130 top: parent.top
131 topMargin: -units.gu(1)
132 }
133 height: units.gu(6)
134 width: units.gu(6)
135 id: closeIcon
136 enabled: root.terminationModeEnabled
137 }