Licensing GPLv3
[quicknewsreader] / qml / QuickNewsReader / content / view / FancyButton.qml
1 /* This file is part of MeeGoFrames Component Library
2  * Copyright (C) 2011 Martin Grimme  <martin.grimme _AT_ gmail.com>
3  * Copyright (C) 2012 Christophe CHAPUIS <chris.chapuis _at_ gmail _dot_ com>
4  *
5  * This program is free software; you can redistribute it, even commercially, 
6  * as long as this copyright notice remains in place.
7  *
8  * This library 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.
11  */
12 import QtQuick 1.0
13
14 Rectangle {
15
16     property alias icon: imageLabel.source
17
18     signal clicked()
19
20     id: button
21     width: 70
22     height: 70
23
24     radius: 3
25     color: "#a0000000"
26
27
28     states: [
29         State {
30             name: "pressed"
31             when: mouseArea.pressed
32             PropertyChanges {
33                 target: button
34                 color: "#606060"
35                 scale: 0.9
36             }
37         }
38     ]
39
40     Behavior on color {
41         ColorAnimation { duration: 100 }
42     }
43
44     Behavior on scale {
45         NumberAnimation { duration: 100 }
46     }
47
48     Image {
49         anchors.centerIn: parent
50         id: imageLabel
51         visible: source != ""
52         anchors.horizontalCenter: parent.horizontalCenter
53     }
54
55     MouseArea {
56         id: mouseArea
57         anchors.fill: parent
58         onClicked: parent.clicked()
59     }
60 }