Skip to content
QGCRadioButton.qml 2.42 KiB
Newer Older
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
Don Gagne's avatar
Don Gagne committed

import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
Don Gagne's avatar
Don Gagne committed

RadioButton {
Don Gagne's avatar
Don Gagne committed
    property var    color:          qgcPal.text    ///< Text color
    property int    textStyle:      Text.Normal
    property color  textStyleColor: qgcPal.text
    property var    qgcPal:         QGCPalette { colorGroupEnabled: enabled }
Don Gagne's avatar
Don Gagne committed

    style: RadioButtonStyle {
        label: Item {
dogmaphobic's avatar
dogmaphobic committed
            implicitWidth:          text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
            implicitHeight:         ScreenTools.implicitRadioButtonHeight
dogmaphobic's avatar
dogmaphobic committed
            baselineOffset:         text.y + text.baselineOffset
Don Gagne's avatar
Don Gagne committed
            Rectangle {
dogmaphobic's avatar
dogmaphobic committed
                anchors.fill:       text
                anchors.margins:    -1
Don Gagne's avatar
Don Gagne committed
                anchors.leftMargin: -3
dogmaphobic's avatar
dogmaphobic committed
                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
            }
Don Gagne's avatar
Don Gagne committed
            Text {
dogmaphobic's avatar
dogmaphobic committed
                id:                 text
                text:               control.text
                font.pointSize:     ScreenTools.defaultFontPointSize
                font.family:        ScreenTools.normalFontFamily
                antialiasing:       true
Don Gagne's avatar
Don Gagne committed
                color:              control.color
                style:              control.textStyle
                styleColor:         control.textStyleColor
dogmaphobic's avatar
dogmaphobic committed
                anchors.centerIn:   parent
Don Gagne's avatar
Don Gagne committed
            }
        }

        indicator: Rectangle {
            width:          ScreenTools.radioButtonIndicatorSize
            height:         width
Don Gagne's avatar
Don Gagne committed
            color:          "white"
            border.color:   control.qgcPal.text
            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
                radius:             height / 2
                color:              "black"
                opacity:            control.checked ? (control.enabled ? 1 : 0.5) : 0
            }
        }
Don Gagne's avatar
Don Gagne committed
    }
}