FactCheckBox.qml 704 Bytes
Newer Older
1 2
import QtQuick 2.3
import QtQuick.Controls 1.2
3
import QtQuick.Controls.Styles 1.4
4

Don Gagne's avatar
Don Gagne committed
5
import QGroundControl.FactSystem 1.0
6
import QGroundControl.Palette 1.0
7
import QGroundControl.Controls 1.0
Don Gagne's avatar
Don Gagne committed
8

9
QGCCheckBox {
10 11
    checkedState: isFactChecked()

12
    property Fact fact: Fact { }
13

14 15
    property variant checkedValue:   1
    property variant uncheckedValue: 0
16 17 18 19 20 21 22 23

    Binding on checkedState {
        value: fact ?
                   (fact.typeIsBool ?
                        (fact.value === false ? Qt.Unchecked : Qt.Checked) :
                        (fact.value === 0 ? Qt.Unchecked : Qt.Checked)) :
                   Qt.Unchecked
    }
Don Gagne's avatar
Don Gagne committed
24

25
    onClicked: fact.value = (checked ? checkedValue : uncheckedValue)
Don Gagne's avatar
Don Gagne committed
26
}