blob: 820371026a2b0defef248a6725c8dbda05b18fcc (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
Item {
property string operation
property bool toggable : false
property bool toggled : false
id: Button; width: 50; height: 30
Script {
function buttonClicked(operation) {
if (Button.toggable == true) {
if (Button.toggled == true) {
Button.toggled = false;
Button.state = 'Toggled';
} else {
Button.toggled = true;
Button.state = '';
}
}
else
doOp(operation);
}
}
Image {
id: Image
source: "pics/button.sci"
width: Button.width; height: Button.height
}
Image {
id: ImagePressed
source: "pics/button-pressed.sci"
width: Button.width; height: Button.height
opacity: 0
}
Text {
anchors.centeredIn: Image
text: Button.operation
color: "white"
font.bold: true
}
MouseRegion {
id: MouseRegion
anchors.fill: Button
onClicked: { buttonClicked(Button.operation) }
}
states: [
State {
name: "Pressed"; when: MouseRegion.pressed == true
SetProperties { target: ImagePressed; opacity: 1 }
},
State {
name: "Toggled"; when: Button.toggled == true
SetProperties { target: ImagePressed; opacity: 1 }
}
]
}
|