Skip to content
QGCRadioButton.qml 1.93 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 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

    style: RadioButtonStyle {
Don Gagne's avatar
 
Don Gagne committed
        spacing: _noText ? 0 : ScreenTools.defaultFontPixelWidth * 0.25
Don Gagne's avatar
 
Don Gagne committed

Don Gagne's avatar
Don Gagne committed
        label: Item {
Don Gagne's avatar
 
Don Gagne committed
            implicitWidth:          _noText ? 0 : text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
            implicitHeight:         _noText ? 0 : Math.max(text.implicitHeight, ScreenTools.radioButtonIndicatorSize)
dogmaphobic's avatar
dogmaphobic committed
            baselineOffset:         text.y + text.baselineOffset
Don Gagne's avatar
Don Gagne committed
            Text {
dogmaphobic's avatar
dogmaphobic committed
                id:                 text
                text:               control.text
Don Gagne's avatar
 
Don Gagne committed
                font.pointSize:     textFontPointSize
                font.bold:          control.textBold
Don Gagne's avatar
 
Don Gagne committed
                color:              control.textColor
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"
Don Gagne's avatar
 
Don Gagne committed
            border.color:   "black"
            radius:         height / 2
Don Gagne's avatar
 
Don Gagne committed
            opacity:        control.enabled ? 1 : 0.5

            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"
Don Gagne's avatar
 
Don Gagne committed
                visible:            control.checked
Don Gagne's avatar
Don Gagne committed
    }
}