qwp Initial release
[qwp] / qml / qwp / content / Button.qml
1 import QtQuick 1.0
2
3 Item {
4     id: container
5
6     signal clicked
7
8     property string text
9     property bool keyUsing: false
10
11     BorderImage {
12         id: buttonImage
13         source: "images/toolbutton.sci"
14         width: container.width; height: container.height
15     }
16     BorderImage {
17         id: pressed
18         opacity: 0
19         source: "images/toolbutton.sci"
20         width: container.width; height: container.height
21     }
22     MouseArea {
23         id: mouseRegion
24         anchors.fill: buttonImage
25         onClicked: { container.clicked(); }
26     }
27     Text {
28         id: btnText
29         color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
30         anchors.centerIn: buttonImage; font.bold: true
31         text: container.text; style: Text.Raised; styleColor: "black"
32         //font.pixelSize: 12
33     }
34     states: [
35         State {
36             name: "Pressed"
37             when: mouseRegion.pressed == true
38             PropertyChanges { target: pressed; opacity: 1 }
39         },
40         State {
41             name: "Focused"
42             when: container.activeFocus == true
43             PropertyChanges { target: btnText; color: "#FFFFFF" }
44         }
45     ]
46     transitions: Transition {
47         ColorAnimation { target: btnText; }
48     }
49 }