blob: 966c8e485f11852690fa17c83e4ba28234a5d3d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import Qt 4.6
Rectangle {
property string operation
property bool toggable : false
property bool toggled : false
signal clicked
id: Button; width: 50; height: 30
border.color: Palette.mid; radius: 6
gradient: Gradient {
GradientStop { id: G1; position: 0.0; color: Palette.lighter(Palette.button) }
GradientStop { id: G2; position: 1.0; color: Palette.button }
}
Text { anchors.centerIn: parent; text: operation; color: Palette.buttonText }
MouseRegion {
id: ClickRegion
anchors.fill: parent
onClicked: {
doOp(operation);
Button.clicked();
if (!Button.toggable) return;
Button.toggled ? Button.toggled = false : Button.toggled = true
}
}
states: [
State {
name: "Pressed"; when: ClickRegion.pressed == true
PropertyChanges { target: G1; color: Palette.dark }
PropertyChanges { target: G2; color: Palette.button }
},
State {
name: "Toggled"; when: Button.toggled == true
PropertyChanges { target: G1; color: Palette.dark }
PropertyChanges { target: G2; color: Palette.button }
}
]
}
|