QGCRadioButton.qml 2.51 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 {
Don Gagne's avatar
Don Gagne committed
9 10 11
    property var    color:          qgcPal.text    ///< Text color
    property int    textStyle:      Text.Normal
    property color  textStyleColor: qgcPal.text
12
    property bool   textBold:       false
Don Gagne's avatar
Don Gagne committed
13
    property var    qgcPal:         QGCPalette { colorGroupEnabled: enabled }
Don Gagne's avatar
Don Gagne committed
14 15 16

    style: RadioButtonStyle {
        label: Item {
dogmaphobic's avatar
dogmaphobic committed
17
            implicitWidth:          text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
18
            implicitHeight:         ScreenTools.implicitRadioButtonHeight
dogmaphobic's avatar
dogmaphobic committed
19
            baselineOffset:         text.y + text.baselineOffset
20

Don Gagne's avatar
Don Gagne committed
21
            Rectangle {
dogmaphobic's avatar
dogmaphobic committed
22 23
                anchors.fill:       text
                anchors.margins:    -1
Don Gagne's avatar
Don Gagne committed
24
                anchors.leftMargin: -3
dogmaphobic's avatar
dogmaphobic committed
25 26 27 28 29 30 31
                anchors.rightMargin:-3
                visible:            control.activeFocus
                height:             ScreenTools.defaultFontPixelWidth * 0.25
                radius:             height * 0.5
                color:              "#224f9fef"
                border.color:       "#47b"
                opacity:            0.6
Don Gagne's avatar
Don Gagne committed
32
            }
33

Don Gagne's avatar
Don Gagne committed
34
            Text {
dogmaphobic's avatar
dogmaphobic committed
35 36 37 38
                id:                 text
                text:               control.text
                font.pointSize:     ScreenTools.defaultFontPointSize
                font.family:        ScreenTools.normalFontFamily
39
                font.bold:          control.textBold
dogmaphobic's avatar
dogmaphobic committed
40
                antialiasing:       true
Don Gagne's avatar
Don Gagne committed
41
                color:              control.color
42 43
                style:              control.textStyle
                styleColor:         control.textStyleColor
dogmaphobic's avatar
dogmaphobic committed
44
                anchors.centerIn:   parent
Don Gagne's avatar
Don Gagne committed
45 46
            }
        }
47 48 49 50

        indicator: Rectangle {
            width:          ScreenTools.radioButtonIndicatorSize
            height:         width
Don Gagne's avatar
Don Gagne committed
51 52
            color:          "white"
            border.color:   control.qgcPal.text
53 54 55 56 57 58 59 60
            antialiasing:   true
            radius:         height / 2

            Rectangle {
                anchors.centerIn:   parent
                width:              Math.round(parent.width * 0.5)
                height:             width
                antialiasing:       true
Don Gagne's avatar
Don Gagne committed
61 62
                radius:             height / 2
                color:              "black"
63 64 65
                opacity:            control.checked ? (control.enabled ? 1 : 0.5) : 0
            }
        }
Don Gagne's avatar
Don Gagne committed
66 67
    }
}