* Know bugs fixed
[lichviet-widget] / qml / lichvietwidget / Button.qml
1 /*
2 Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
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, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>
16 */
17
18 import QtQuick 1.0
19
20 Item {
21     id:menubutton
22     property string  text
23     property string  tip
24     property bool  selected
25
26     signal clicked
27
28     Rectangle{
29         id:menurectangle
30         color: selected ? "#000000":"#a7bfe8"
31         anchors.fill:parent
32         radius: 8
33         border.color: "#ca8282"
34
35         Text {
36             id: text1
37             x: 20
38             y: 8
39             text:menubutton.text
40             font.bold: true
41             horizontalAlignment: Text.AlignHCenter
42             font.pixelSize: 22
43             color:"#404040"
44         }
45
46         Text {
47             id: text2
48             x: 20
49             y: 33
50             text:menubutton.tip
51             font.bold: true
52             horizontalAlignment: Text.AlignHCenter
53             font.pixelSize: 18
54             color:"black"
55         }
56     }
57
58     MouseArea {
59         id: mouseRegion
60         anchors.fill: menurectangle
61         onClicked: { menubutton.clicked(); }
62     }
63
64     states: [
65         State {
66             name: "Pressed"
67             when: mouseRegion.pressed == true
68             PropertyChanges { target: menurectangle; color:"white" }
69         }
70     ]
71 }