on e35a785 help sign in
unity8/qml/Notifications/NotificationButton.qml
70 lines 2.0 kB history raw
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
20Rectangle {
21 id: root
23 height: units.gu(4)
24 radius: units.dp(4)
25 border.width: outline ? units.dp(1) : 0
26 border.color: outline ? theme.palette.normal.base : "transparent"
28 // to be read from outside
29 readonly property bool containsMouse: button.__mouseArea.containsMouse
31 // to be set from outside
32 property bool outline: true
33 property alias text: label.text
34 property alias iconName: icon.name
36 signal clicked()
38 AbstractButton {
39 id: button
40 anchors.fill: root
41 onClicked: root.clicked()
43 Label {
44 id: label
45 fontSize: "medium"
46 font.weight: Font.Light
47 anchors.centerIn: parent
48 color: outline ? theme.palette.normal.backgroundSecondaryText : "white"
49 visible: text !== ""
50 }
52 Icon {
53 id: icon
54 height: root.height * 2 / 3
55 width: height
56 anchors.centerIn: parent
57 color: "white"
58 visible: !label.visible
59 }
60 }
62 transformOrigin: Item.Top
63 scale: button.pressed ? 0.98 : 1.0
64 Behavior on scale {
65 ScaleAnimator {
66 duration: UbuntuAnimation.SnapDuration
67 easing.type: Easing.Linear
68 }
69 }