Unity 8
 All Classes Functions Properties
RunningApplicationTile.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 Ubuntu.Components 0.1
19 import Unity.Application 0.1
20 import "../../Components/"
21 import "../../Components/ListItems"
22 
23 AbstractButton {
24  id: root
25  property var application
26 
27  signal requestedApplicationActivation(var application)
28  signal requestedApplicationTermination(var application)
29  signal requestedActivationMode()
30  signal requestedTerminationMode()
31 
32  // Was: childrenRect.height
33  // To avoid "binding loop" warning
34  height: shapedApplicationImage.height + labelContainer.height
35 
36  width: shapedApplicationImage.width <= units.gu(11) ? units.gu(11) : height
37 
38  property bool terminationModeEnabled: false
39 
40  onClicked: {
41  if (!terminationModeEnabled)
42  requestedApplicationActivation(application)
43  }
44 
45  onPressAndHold: {
46  if (terminationModeEnabled) {
47  requestedActivationMode()
48  } else {
49  requestedTerminationMode()
50  }
51  }
52 
53  UbuntuShape {
54  id: shapedApplicationImage
55  anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
56 
57  height: units.gu(17)
58  width: applicationImage.width
59  radius: "medium"
60 
61  image: Image {
62  id: applicationImage
63  source: application.screenshot
64  // height : width = ss.height : ss.width
65  height: shapedApplicationImage.height
66  fillMode: Image.PreserveAspectCrop
67  width: Math.min(height, height * sourceSize.width / sourceSize.height)
68  }
69 
70  }
71 
72  UbuntuShape {
73  id: borderPressed
74 
75  anchors.fill: shapedApplicationImage
76  radius: "medium"
77  borderSource: "radius_pressed.sci"
78  opacity: root.pressed ? 1.0 : 0.0
79  Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
80  }
81 
82  // FIXME: label code duplicated with Tile
83  Item {
84  id: labelContainer
85  anchors {
86  left: parent.left
87  right: parent.right
88  top: shapedApplicationImage.bottom
89  }
90  height: units.gu(2)
91 
92  Label {
93  id: label
94  anchors {
95  baseline: parent.bottom
96  left: parent.left
97  right: parent.right
98  }
99  text: (application) ? application.name : ""
100 
101  // TODO karni: Update Ubuntu.Components.Themes.Palette and use theme color instead
102  color: "grey"
103  opacity: 0.9
104  fontSize: "small"
105  elide: Text.ElideMiddle
106  horizontalAlignment: Text.AlignHCenter
107  }
108  }
109 
110  CloseIcon {
111  objectName: "closeIcon " + model.name
112  anchors {
113  left: shapedApplicationImage.left
114  leftMargin: -units.gu(1)
115  top: parent.top
116  topMargin: -units.gu(1)
117  }
118  height: units.gu(6)
119  width: units.gu(6)
120  id: closeIcon
121  enabled: root.terminationModeEnabled
122 
123  MouseArea {
124  anchors { fill: parent; margins: -units.gu(1) }
125  onClicked: requestedApplicationTermination(application)
126  }
127  }
128 }