on 656b044 help sign in
unity8/Components/PinPadButton.qml
75 lines 2.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
20Item {
21 id: root
23 property alias text: label.text
24 property alias subText: subTextLabel.text
25 property string iconName
27 signal clicked()
29 Column {
30 anchors.centerIn: parent
31 width: parent.width
32 height: childrenRect.height
34 Item {
35 anchors {
36 left: parent.left
37 right: parent.right
38 }
39 height: label.visible || icon.visible ? Math.max(label.height, icon.height) : 0
41 Label {
42 id: label
43 anchors.centerIn: parent
44 width: parent.width
45 horizontalAlignment: Text.AlignHCenter
46 color: "#f3f3e7"
47 fontSize: "large"
48 font.weight: Font.DemiBold
49 visible: text.length > 0
50 }
52 Icon {
53 id: icon
54 height: units.gu(3)
55 width: height
56 anchors.centerIn: parent
57 name: root.iconName
58 color: "#f3f3e7"
59 visible: name.length > 0
60 }
61 }
62 Label {
63 id: subTextLabel
64 fontSize: "small"
65 color: "grey"
66 anchors.horizontalCenter: parent.horizontalCenter
67 visible: text.length > 0
68 }
69 }
71 MouseArea {
72 anchors.fill: parent
73 onClicked: root.clicked()
74 }