Unity 8
DashSectionHeader.qml
1 /*
2  * Copyright (C) 2013,2014 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.4
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
20 
21 Item {
22  property alias text: label.text
23  property alias color: label.color
24  property alias iconName: icon.name
25 
26  signal clicked(variant mouse)
27 
28  height: units.gu(5)
29 
30  Label {
31  id: label
32 
33  anchors {
34  left: parent.left
35  leftMargin: units.gu(2)
36  verticalCenter: parent.verticalCenter
37  }
38 
39  font.family: "Ubuntu"
40  fontSize: "medium"
41  elide: Text.ElideRight
42  maximumLineCount: 1
43  textFormat: Text.PlainText
44  width: Math.min(parent.width - units.gu(4), implicitWidth)
45  }
46 
47  Icon {
48  id: icon
49  visible: name != ""
50  height: units.gu(1.25)
51  width: height
52  color: label.color
53  anchors {
54  left: label.right
55  leftMargin: units.gu(0.25)
56  verticalCenter: parent.verticalCenter
57  }
58  }
59 
60  MouseArea {
61  anchors.fill: parent
62  onClicked: parent.clicked(mouse)
63  }
64 }