~aacid/unity8/add_override_warning

« back to all changes in this revision

Viewing changes to qml/Notifications/NotificationButton.qml

  • Committer: Albert Astals Cid
  • Date: 2016-05-05 07:30:08 UTC
  • mfrom: (2341.1.42 unity8)
  • Revision ID: albert.astals@canonical.com-20160505073008-d8u2rkkh0sg1te0l
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
16
 
 
17
import QtQuick 2.4
 
18
import Ubuntu.Components 1.3
 
19
 
 
20
Rectangle {
 
21
    id: root
 
22
    height: units.gu(4)
 
23
    radius: units.gu(0.6)
 
24
 
 
25
    // to be read from outside
 
26
    readonly property alias containsMouse: mouseArea.containsMouse
 
27
 
 
28
    // to be set from outside
 
29
    property bool outline: true
 
30
    property alias text: label.text
 
31
    property alias iconName: icon.name
 
32
    property bool hoverEnabled: false
 
33
 
 
34
    signal clicked()
 
35
 
 
36
    Label {
 
37
        id: label
 
38
        fontSize: "medium"
 
39
        font.weight: Font.Light
 
40
        anchors.centerIn: root
 
41
        color: outline ? theme.palette.normal.backgroundSecondaryText : "white"
 
42
        visible: text !== ""
 
43
    }
 
44
 
 
45
    Icon {
 
46
        id: icon
 
47
        height: root.height * 2 / 3
 
48
        width: height
 
49
        anchors.centerIn: root
 
50
        color: "white"
 
51
        visible: !label.visible
 
52
    }
 
53
 
 
54
    MouseArea {
 
55
        id: mouseArea
 
56
        anchors.fill: root
 
57
        hoverEnabled: root.hoverEnabled
 
58
        onClicked: {
 
59
            Haptics.play();
 
60
            root.clicked();
 
61
        }
 
62
    }
 
63
 
 
64
    transformOrigin: Item.Top
 
65
    scale: mouseArea.pressed ? 0.98 : 1.0
 
66
    Behavior on scale {
 
67
        ScaleAnimator {
 
68
            duration: UbuntuAnimation.SnapDuration
 
69
            easing.type: Easing.Linear
 
70
        }
 
71
    }
 
72
}