QGCRadioButton.qml 1.83 KB
Newer Older
1 2
import QtQuick                  2.11
import QtQuick.Controls         2.4
3
import QtQuick.Controls.Styles  1.4
Don Gagne's avatar
Don Gagne committed
4

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

RadioButton {
9
    id: control
10 11 12
    property color  textColor:          _qgcPal.text
    property bool   textBold:           false
    property real   textFontPointSize:  ScreenTools.defaultFontPointSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26
    property var    _qgcPal:            QGCPalette { colorGroupEnabled: enabled }
    property bool   _noText:            text === ""

    indicator: Rectangle {
        implicitWidth:          ScreenTools.radioButtonIndicatorSize
        implicitHeight:         width
        color:                  "white"
        border.color:           "black"
        radius:                 height / 2
        opacity:                control.enabled ? 1 : 0.5
        x:                      control.leftPadding
        y:                      parent.height / 2 - height / 2
        Rectangle {
            anchors.centerIn:   parent
27 28
            // Width should be an odd number to be centralized by the parent properly
            width:              2 * Math.floor(parent.width / 4) + 1
29 30 31 32 33
            height:             width
            antialiasing:       true
            radius:             height * 0.5
            color:              "black"
            visible:            control.checked
Don Gagne's avatar
Don Gagne committed
34
        }
35
    }
36

37
    contentItem: Text {
Gus Grubba's avatar
Gus Grubba committed
38 39
        text:               control.text
        font.family:        ScreenTools.normalFontFamily
40 41 42 43 44 45
        font.pointSize:     textFontPointSize
        font.bold:          control.textBold
        color:              control.textColor
        opacity:            enabled ? 1.0 : 0.3
        verticalAlignment:  Text.AlignVCenter
        leftPadding:        control.indicator.width + (_noText ? 0 : ScreenTools.defaultFontPixelWidth * 0.25)
Don Gagne's avatar
Don Gagne committed
46
    }
47

Don Gagne's avatar
Don Gagne committed
48
}