-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadioButton.qml
More file actions
executable file
·53 lines (52 loc) · 1.81 KB
/
RadioButton.qml
File metadata and controls
executable file
·53 lines (52 loc) · 1.81 KB
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
import QtQuick 2.5
import "qrc:/components/functions.js" as JS
Item {
id:root
signal toggled()
function getStatus() { return checked }
property alias text : label.text
property alias pixelSize : label.font.pixelSize
property alias textColor: label.color
property var color : "#242424"
property var checked : false
height: JS.hpercent(5,parent); width: JS.wpercent(15,parent)
Row {
id:row
anchors { fill: parent; margins: JS.hpercent(3,parent) }
spacing: JS.wpercent(10,this)
Rectangle {
id:circle
function toggle() { checked = (checked ? false : true); toggled(); }
state: checked? "toggled" : "untoggled"
anchors.verticalCenter: parent.verticalCenter
height: JS.hpercent(90,parent); width: height
radius: width/2; color:root.color
border { width:JS.hpercent(5,parent); color: root.color }
states: [
State {
name: "toggled"
PropertyChanges { target: circle; color:root.color }
},
State {
name: "untoggled"
PropertyChanges { target: circle; color:"transparent" }
}
]
Behavior on color { ColorAnimation { duration: 200 } }
MouseArea {
anchors.fill: parent
onClicked: circle.toggle()
}
}
Item {
height: JS.hpercent(100,parent); width: JS.wpercent(100,parent)
Text {
id:label
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
font { pixelSize: JS.hpercent(100,parent); weight: Font.Light }
text:"Label"
}
}
}
}