Merge branch 'develop'
[lichviet] / qml / LichViet / MenuButton.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 import QtQuick 1.0
18
19 Item {
20     id:menubutton
21     property string  text
22     property string  tip
23     property bool  selected
24
25     signal clicked
26
27     Rectangle{
28         id:menurectangle
29         color: selected ? "#000000":"#a7bfe8"
30         anchors.fill:parent
31         radius: 8
32         border.color: "#ca8282"
33
34         Text {
35             id: text1
36             x: 20
37             y: 8
38             text:menubutton.text
39             font.bold: true
40             horizontalAlignment: Text.AlignHCenter
41             font.pixelSize: 22
42             color:"#404040"
43         }
44
45         Text {
46             id: text2
47             x: 20
48             y: 33
49             text:menubutton.tip
50             font.bold: true
51             horizontalAlignment: Text.AlignHCenter
52             font.pixelSize: 16
53             color:"grey"
54         }
55     }
56
57     MouseArea {
58         id: mouseRegion
59         anchors.fill: menurectangle
60         onClicked: { menubutton.clicked(); }
61     }
62
63     states: [
64         State {
65             name: "Pressed"
66             when: mouseRegion.pressed == true
67             PropertyChanges { target: menurectangle; color:"white" }
68         }
69     ]
70 }