| 1 |
import QtQuick 2.4 |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
Item { |
| 5 |
id: root |
| 6 |
property bool selected |
| 7 |
property RadioButtonGroup group // nil by default |
| 8 |
|
| 9 |
signal clicked() |
| 10 |
|
| 11 |
implicitHeight: outerRing.height + Style.margin |
| 12 |
implicitWidth: outerRing.width + Style.margin |
| 13 |
|
| 14 |
function select() |
| 15 |
{ |
| 16 |
if (root.group) { |
| 17 |
root.group.selected = root; |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
Binding { |
| 22 |
when: root.group != null |
| 23 |
target: root |
| 24 |
property: "selected" |
| 25 |
value: (root.group.selected === root) |
| 26 |
} |
| 27 |
|
| 28 |
Rectangle { |
| 29 |
id: innerRing |
| 30 |
anchors.centerIn: parent |
| 31 |
width: radius * 2 |
| 32 |
height: radius * 2 |
| 33 |
radius: Style.roundRadius |
| 34 |
color: Style.themeColor |
| 35 |
visible: selected || mouse.containsMouse |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
Rectangle { |
| 40 |
id: outerRing |
| 41 |
anchors.centerIn: parent |
| 42 |
border.color: Style.themeColor |
| 43 |
border.width: 2 |
| 44 |
color: "transparent" |
| 45 |
radius: Style.roundRadius + 4 |
| 46 |
width: radius * 2 |
| 47 |
height: radius * 2 |
| 48 |
} |
| 49 |
|
| 50 |
Rectangle { |
| 51 |
id: pressRing |
| 52 |
opacity: 0.3 |
| 53 |
width: outerRing.width * 2 |
| 54 |
height: outerRing.height * 2 |
| 55 |
visible: mouse.pressed |
| 56 |
radius: width / 2 |
| 57 |
color: "#7f7f7f" |
| 58 |
anchors.centerIn: parent |
| 59 |
} |
| 60 |
|
| 61 |
MouseArea { |
| 62 |
id: mouse |
| 63 |
anchors.fill: parent |
| 64 |
hoverEnabled: true |
| 65 |
onClicked: { |
| 66 |
root.select(); |
| 67 |
root.clicked() |
| 68 |
} |
| 69 |
} |
| 70 |
} |