SubMenuButton.qml 2.55 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: "subMenuButtonImage.png"
Don Gagne's avatar
Don Gagne committed
16 17 18 19

    style: ButtonStyle {
        id: buttonStyle

20
        property var __qgcPal: QGCPalette {
21
            colorGroupEnabled: control.enabled
Don Gagne's avatar
Don Gagne committed
22 23
        }

24 25
        property bool __showHighlight: control.pressed | control.checked

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

30
            color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
Don Gagne's avatar
Don Gagne committed
31 32 33 34 35 36 37 38 39 40 41 42

            Text {
                id: titleBar

                width: parent.width
                height: parent.titleHeight

                verticalAlignment: TextEdit.AlignVCenter
                horizontalAlignment: TextEdit.AlignHCenter

                text: control.text
                font.pixelSize: 12
43
                color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
44 45 46 47

                Rectangle {
                    id: setupIndicator

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

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

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

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

                y: parent.titleHeight

66
                color: __qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
67 68 69

                Image {
                    id: buttonImage
70
                    source: control.imageResource
Don Gagne's avatar
Don Gagne committed
71 72 73 74 75 76 77 78 79 80
                    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
81
                    color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
Don Gagne's avatar
Don Gagne committed
82 83 84 85 86 87 88
                }
            }
        }

    label: Item {}
    }
}