C

Qt Quick Ultralite Thermostat Demo

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial

import QtQuick 2.15
import QtQuick.Templates 2.15
import Thermo 1.0

RadioButton {
    id: control

    implicitWidth: background.implicitWidth
    implicitHeight:  background.implicitHeight
    spacing: 10

    property alias flag: flagIndicator.source

    indicator: Image {
        y: control.topPadding + (control.availableHeight - height) / 2
        source: control.checked
               ? (control.down ? "radiobutton-checked-pressed.png" : "radiobutton-checked.png")
               : (control.down ? "radiobutton-pressed.png" : "radiobutton.png")
    }

    background: Item {
        implicitWidth: control.contentItem.implicitWidth
        implicitHeight: Theme.dialogButtonHeight
    }

    // Text has no padding properties in UL, so we use Row with an Item for the spacing.
    contentItem: Row {
        anchors.verticalCenter: background.verticalCenter
        Item {
            implicitWidth: control.indicator.width + control.spacing
        }

        Image {
            id: flagIndicator
            anchors.verticalCenter: parent.verticalCenter
        }

        Item {
            implicitWidth: control.spacing
        }

        Text {
            text: control.text
            color: ColorStyle.greyDark4
            anchors.verticalCenter: parent.verticalCenter
            font.pixelSize: Theme.bottomBarFontSize
        }
    }
}