SubMenuButton.qml 3.04 KB
Newer Older
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 7
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
Don Gagne's avatar
Don Gagne committed
8 9

Button {
10 11 12
    property bool   setupComplete:  true                                    ///< true: setup complete indicator shows as completed
    property bool   setupIndicator: true                                    ///< true: show setup complete indicator
    property string imageResource:  "/qmlimages/subMenuButtonImage.png"     ///< Button image
Don Gagne's avatar
Don Gagne committed
13

14 15 16 17
    text: "Button"  ///< Pass in your own button text

    checkable:  true
    height:     ScreenTools.defaultFontPixelHeight * 5
Don Gagne's avatar
Don Gagne committed
18 19 20 21

    style: ButtonStyle {
        id: buttonStyle

22 23 24
        QGCPalette {
            id:                 qgcPal
            colorGroupEnabled:  control.enabled
Don Gagne's avatar
Don Gagne committed
25 26
        }

27
        property bool showHighlight: control.pressed | control.checked
28

Don Gagne's avatar
Don Gagne committed
29
        background: Rectangle {
30
            id:     innerRect
31
            color:  showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
32

33
            readonly property real titleHeight: ScreenTools.defaultFontPixelHeight * 1.5
Don Gagne's avatar
Don Gagne committed
34

35 36 37 38 39 40 41
            QGCLabel {
                id:                     titleBar
                width:                  parent.width
                height:                 parent.titleHeight
                verticalAlignment:      TextEdit.AlignVCenter
                horizontalAlignment:    TextEdit.AlignHCenter
                color:                  showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
dogmaphobic's avatar
dogmaphobic committed
42
                font.pixelSize:         ScreenTools.isMobile ? ScreenTools.defaultFontPixelSize * 0.65 : ScreenTools.defaultFontPixelSize
43
                text:                   control.text
Don Gagne's avatar
Don Gagne committed
44 45

                Rectangle {
46 47 48
                    anchors.rightMargin:    ScreenTools.defaultFontPixelWidth / 3
                    anchors.right:          parent.right
                    anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
49
                    width:                  ScreenTools.defaultFontPixelWidth
50
                    height:                 width
dogmaphobic's avatar
dogmaphobic committed
51
                    radius:                 width / 2
52 53
                    color:                  control.setupComplete ? "#00d932" : "red"
                    visible:                control.setupIndicator
Don Gagne's avatar
Don Gagne committed
54 55 56 57
                }
            }

            Rectangle {
58 59 60
                anchors.top:    titleBar.bottom
                anchors.bottom: parent.bottom
                width:          parent.width
61
                color:          qgcPal.windowShadeDark
Don Gagne's avatar
Don Gagne committed
62

63
                QGCColoredImage {
64 65 66 67 68 69
                    anchors.margins:    ScreenTools.defaultFontPixelHeight * .75
                    anchors.fill:       parent
                    fillMode:           Image.PreserveAspectFit
                    smooth:             true
                    color:              showHighlight ? qgcPal.buttonHighlight : qgcPal.button
                    source:             control.imageResource
Don Gagne's avatar
Don Gagne committed
70 71 72 73
                }
            }
        }

74
        label: Item {}
Don Gagne's avatar
Don Gagne committed
75 76
    }
}