Unity 8
WindowInfoItem.qml
1 import QtQuick 2.4
2 import Ubuntu.Components 1.3
3 
4 Item {
5  id: root
6  implicitWidth: Math.max(iconShape.width, titleLabel.width)
7  implicitHeight: iconShape.height + titleLabel.height + labelMargin + iconMargin
8  property alias title: titleLabel.text
9  property alias iconSource: icon.source
10 
11  property real iconHeight: (height - titleLabel.height) * 0.65
12  property real iconMargin: (height - titleLabel.height) * 0.25
13  property real labelMargin: (height - titleLabel.height) * 0.1
14  property int maxWidth: units.gu(10)
15 
16  signal clicked()
17 
18  ProportionalShape {
19  id: iconShape
20  anchors {
21  top: parent.top
22  topMargin: iconMargin
23  left: parent.left
24  }
25  height: iconHeight
26  borderSource: "undefined"
27  aspect: UbuntuShape.Flat
28  source: Image {
29  id: icon
30  sourceSize.width: iconShape.width
31  sourceSize.height: iconShape.height
32  cache: false // see lpbug#1543290 why no cache
33  }
34  }
35 
36  MouseArea {
37  anchors.fill: iconShape
38  onClicked: root.clicked()
39  }
40 
41  Label {
42  id: titleLabel
43  anchors {
44  left: iconShape.left
45  top: iconShape.bottom
46  topMargin: labelMargin
47  }
48  width: root.maxWidth
49  fontSize: 'small'
50  color: 'white'
51  elide: Label.ElideRight
52  }
53 }