blob: 1642d4441f28e69378075fc1edeba77dd17b71f2 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
import Qt 4.6
Item {
id: Container
property string label
property string text
width: Math.max(94,Label.width + Editor.width + 20)
height: Image.height
states: [
State {
name: "Edit"
SetProperties {
target: Label
text: Container.label + ": "
}
SetProperties {
target: Label
x: 10
}
SetProperties {
target: Editor
cursorVisible: true
width: 100
}
SetProperties {
target: Proxy
focus: true
}
RunScript {
script:"Editor.selectAll()"
}
},
State {
// When returning to default state, typed text is propagated
RunScript {
script: "Container.text = Editor.text"
}
}
]
transitions: [
Transition {
NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" }
}
]
BorderImage {
id: Image
source: "pics/button.sci"
anchors.left: Container.left
anchors.right: Container.right
}
BorderImage {
id: Pressed
source: "pics/button-pressed.sci"
opacity: 0
anchors.left: Container.left
anchors.right: Container.right
}
MouseRegion {
id: MouseRegion
anchors.fill: Image
onClicked: { Container.state = Container.state=="Edit" ? "" : "Edit" }
states: [
State {
when: MouseRegion.pressed == true
SetProperties {
target: Pressed
opacity: 1
}
}
]
}
Text {
id: Label
font.bold: true
color: "white"
anchors.verticalCenter: Container.verticalCenter
x: (Container.width - width)/2
text: Container.label + "..."
}
TextInput {
id: Editor
font.bold: true
color: "white"
highlightColor: "green"
width: 0
clip: true
anchors.left: Label.right
anchors.verticalCenter: Container.verticalCenter
}
KeyProxy {
id: Proxy
anchors.left: Container.left
anchors.fill: Container
targets: [(ReturnKey), (Editor)]
}
Item {
id: ReturnKey
Keys.onReturnPressed: "Container.state = ''"
}
}
|