QGCRadioButton.qml 1.93 KB
Newer Older
1 2
import QtQuick                  2.3
import QtQuick.Controls         1.2
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 10 11 12 13 14 15 16 17
    property color  textColor:          _qgcPal.text
    property bool   textBold:           false
    property real   textFontPointSize:  ScreenTools.defaultFontPointSize

    property var    _qgcPal:             QGCPalette { colorGroupEnabled: enabled }

    property bool _noText: text === ""

    activeFocusOnPress: true
Don Gagne's avatar
Don Gagne committed
18 19

    style: RadioButtonStyle {
20 21
        spacing: _noText ? 0 : ScreenTools.defaultFontPixelWidth / 2

Don Gagne's avatar
Don Gagne committed
22
        label: Item {
23 24
            implicitWidth:          _noText ? 0 : text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
            implicitHeight:         _noText ? 0 : Math.max(text.implicitHeight, ScreenTools.radioButtonIndicatorSize)
dogmaphobic's avatar
dogmaphobic committed
25
            baselineOffset:         text.y + text.baselineOffset
26

Don Gagne's avatar
Don Gagne committed
27
            Text {
dogmaphobic's avatar
dogmaphobic committed
28 29
                id:                 text
                text:               control.text
30
                font.pointSize:     textFontPointSize
31
                font.bold:          control.textBold
32
                color:              control.textColor
dogmaphobic's avatar
dogmaphobic committed
33
                anchors.centerIn:   parent
Don Gagne's avatar
Don Gagne committed
34 35
            }
        }
36 37 38 39

        indicator: Rectangle {
            width:          ScreenTools.radioButtonIndicatorSize
            height:         width
Don Gagne's avatar
Don Gagne committed
40
            color:          "white"
41
            border.color:   "black"
42
            radius:         height / 2
43
            opacity:        control.enabled ? 1 : 0.5
44 45 46 47 48 49

            Rectangle {
                anchors.centerIn:   parent
                width:              Math.round(parent.width * 0.5)
                height:             width
                antialiasing:       true
Don Gagne's avatar
Don Gagne committed
50 51
                radius:             height / 2
                color:              "black"
52
                visible:            control.checked
53 54
            }
        }
Don Gagne's avatar
Don Gagne committed
55 56
    }
}