SetupButton.qml 2.56 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
5 6

import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
7 8 9

Button {
    checkable: true
10
    height: 60
Don Gagne's avatar
Don Gagne committed
11 12 13 14

    text: "Button"
    property bool setupComplete: true
    property bool setupIndicator: true
15
    property string imageResource: "setupButtonImage.png"
Don Gagne's avatar
Don Gagne committed
16 17 18 19

    style: ButtonStyle {
        id: buttonStyle

20
        property var __qgcPal: QGCPalette {
Don Gagne's avatar
Don Gagne committed
21 22 23 24 25
            colorGroup: control.enabled ? QGCPalette.Active : QGCPalette.Disabled
        }

        background: Rectangle {
            id: innerRect
26
            readonly property real titleHeight: 20
Don Gagne's avatar
Don Gagne committed
27

28
            color: control.pressed ? __qgcPal.buttonHighlight : (control.checked ? __qgcPal.buttonHighlight : __qgcPal.button)
Don Gagne's avatar
Don Gagne committed
29 30 31 32 33 34 35 36 37 38 39 40

            Text {
                id: titleBar

                width: parent.width
                height: parent.titleHeight

                verticalAlignment: TextEdit.AlignVCenter
                horizontalAlignment: TextEdit.AlignHCenter

                text: control.text
                font.pixelSize: 12
41
                color: __qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
42 43 44 45

                Rectangle {
                    id: setupIndicator

46
                    readonly property real indicatorRadius: 4
Don Gagne's avatar
Don Gagne committed
47 48 49 50 51 52 53

                    x: parent.width - (indicatorRadius * 2) - 5
                    y: (parent.height - (indicatorRadius * 2)) / 2
                    width: indicatorRadius * 2
                    height: indicatorRadius * 2

                    radius: indicatorRadius
54
                    color: control.setupIndicator ? (control.setupComplete ? "#00d932" : "red") : innerRect.color
Don Gagne's avatar
Don Gagne committed
55 56 57 58 59 60 61 62 63
                }
            }

            Rectangle {
                width: parent.width
                height: parent.height - parent.titleHeight

                y: parent.titleHeight

64
                color: __qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
65 66 67

                Image {
                    id: buttonImage
68
                    source: control.imageResource
Don Gagne's avatar
Don Gagne committed
69 70 71 72 73 74 75 76 77 78
                    sourceSize: Qt.size(parent.width - 20, parent.height - 20)
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
                    smooth: true
                    visible: false
                }

                ColorOverlay {
                    anchors.fill: buttonImage
                    source: buttonImage
79
                    color: control.pressed ? __qgcPal.buttonHighlight : (control.checked ? __qgcPal.buttonHighlight : __qgcPal.button)
Don Gagne's avatar
Don Gagne committed
80 81 82 83 84 85 86
                }
            }
        }

    label: Item {}
    }
}