Browse Source

Update CustomOnOffSwitch.qml

Custon On / Off  switch updated to show label when off. Now works more like a toggle
QGC4.4
Yasen 6 years ago
parent
commit
052c5c9142
  1. 15
      custom-example/res/Custom/Widgets/CustomOnOffSwitch.qml

15
custom-example/res/Custom/Widgets/CustomOnOffSwitch.qml

@ -20,8 +20,8 @@ Rectangle {
height: Math.round(ScreenTools.defaultFontPixelHeight * 2) height: Math.round(ScreenTools.defaultFontPixelHeight * 2)
width: ScreenTools.defaultFontPixelWidth * 10 width: ScreenTools.defaultFontPixelWidth * 10
color: qgcPal.button color: qgcPal.button
border.color: qgcPal.text border.color: qgcPal.windowShade
border.width: 1 border.width: 0
property bool checked: true property bool checked: true
@ -32,24 +32,23 @@ Rectangle {
Rectangle { Rectangle {
width: parent.width * 0.5 width: parent.width * 0.5
height: parent.height height: parent.height
color: qgcPal.windowShade color: checked ? qgcPal.button : qgcPal.buttonHighlight
visible: !checked
border.color: qgcPal.text border.color: qgcPal.text
border.width: 1 border.width: 0
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
QGCLabel { QGCLabel {
text: qsTr("Off") text: qsTr("Off")
anchors.centerIn: parent anchors.centerIn: parent
color: qgcPal.text
} }
} }
Rectangle { Rectangle {
width: parent.width * 0.5 width: parent.width * 0.5
height: parent.height * 0.95 height: parent.height * 0.95
color: qgcPal.buttonHighlight color: checked ? qgcPal.buttonHighlight : qgcPal.button
visible: checked
border.color: qgcPal.text border.color: qgcPal.text
border.width: 1 border.width: 0
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
QGCLabel { QGCLabel {

Loading…
Cancel
Save