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

    style: ButtonStyle {
        id: buttonStyle

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

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

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

31
            color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
Don Gagne's avatar
Don Gagne committed
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
Don Gagne's avatar
Don Gagne committed
43
                font.pixelSize: ScreenTools.defaultFontPixelSize
44
                antialiasing: true
45
                color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
46 47 48 49

                Rectangle {
                    id: setupIndicator

50
                    readonly property real indicatorRadius: 4
Don Gagne's avatar
Don Gagne committed
51

Don Gagne's avatar
Don Gagne committed
52
                    x: parent.width - (indicatorRadius * 2) - 3
Don Gagne's avatar
Don Gagne committed
53 54 55 56 57
                    y: (parent.height - (indicatorRadius * 2)) / 2
                    width: indicatorRadius * 2
                    height: indicatorRadius * 2

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

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

                y: parent.titleHeight

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

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

    label: Item {}
    }
}