Unity 8
WindowInfoItem.qml
1 /*
2  * Copyright (C) 2017 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.12
18 import Ubuntu.Components 1.3
19 
20 Item {
21  id: root
22  implicitWidth: Math.max(iconShape.width, titleLabel.width)
23  implicitHeight: iconShape.height + titleLabel.height + labelMargin + iconMargin
24  property alias title: titleLabel.text
25  property alias iconSource: icon.source
26 
27  property real iconHeight: (height - titleLabel.height) * 0.65
28  property real iconMargin: (height - titleLabel.height) * 0.25
29  property real labelMargin: (height - titleLabel.height) * 0.1
30  property int maxWidth: units.gu(10)
31 
32  signal clicked()
33 
34  ProportionalShape {
35  id: iconShape
36  anchors {
37  top: parent.top
38  topMargin: iconMargin
39  left: parent.left
40  }
41  height: iconHeight
42  borderSource: "undefined"
43  aspect: UbuntuShape.Flat
44  source: Image {
45  id: icon
46  sourceSize.width: iconShape.width
47  sourceSize.height: iconShape.height
48  cache: false // see lpbug#1543290 why no cache
49  }
50  }
51 
52  MouseArea {
53  anchors.fill: iconShape
54  onClicked: root.clicked()
55  }
56 
57  Label {
58  id: titleLabel
59  anchors {
60  left: iconShape.left
61  top: iconShape.bottom
62  topMargin: labelMargin
63  }
64  width: root.maxWidth
65  fontSize: 'small'
66  color: 'white'
67  elide: Label.ElideRight
68  }
69 }