SubMenuButton.qml 2.58 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
7
import QGroundControl.ScreenTools 1.0
Don Gagne's avatar
Don Gagne committed
8 9 10

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

    text: "Button"
    property bool setupComplete: true
    property bool setupIndicator: true
16
    property string imageResource: "subMenuButtonImage.png"
17
    property ScreenTools __screenTools: ScreenTools { }
Don Gagne's avatar
Don Gagne committed
18 19 20 21

    style: ButtonStyle {
        id: buttonStyle

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

26 27
        property bool __showHighlight: control.pressed | control.checked

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

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

            Text {
                id: titleBar

                width: parent.width
                height: parent.titleHeight

                verticalAlignment: TextEdit.AlignVCenter
                horizontalAlignment: TextEdit.AlignHCenter

                text: control.text
44 45
                font.pointSize: __screenTools.defaultFontPointSize
                antialiasing: true
46
                color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
47 48 49 50

                Rectangle {
                    id: setupIndicator

51
                    readonly property real indicatorRadius: 4
Don Gagne's avatar
Don Gagne committed
52 53 54 55 56 57 58

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

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

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

                y: parent.titleHeight

69
                color: __qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
70

71
                QGCColoredImage {
72
                    source: control.imageResource
73 74 75
                    fillMode: Image.PreserveAspectFit
                    width: parent.width - 20
                    height: parent.height - 20
Don Gagne's avatar
Don Gagne committed
76 77 78
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
                    smooth: true
79
                    color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
Don Gagne's avatar
Don Gagne committed
80 81 82 83 84 85 86
                }
            }
        }

    label: Item {}
    }
}