SubMenuButton.qml 2.37 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
    text: "Button"  ///< Pass in your own button text

16 17
    checkable:      true
    implicitHeight: ScreenTools.defaultFontPixelHeight * 2.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 34
            implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth

35 36 37 38 39 40 41 42 43 44 45 46
            QGCColoredImage {
                id:                     image
                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.verticalCenter: parent.verticalCenter
                width:                  ScreenTools.defaultFontPixelHeight * 2
                height:                 ScreenTools.defaultFontPixelHeight * 2
                fillMode:               Image.PreserveAspectFit
                smooth:                 true
                color:                  control.setupComplete ? qgcPal.button : "red"
                source:                 control.imageResource
            }
Don Gagne's avatar
Don Gagne committed
47

48 49
            QGCLabel {
                id:                     titleBar
50 51 52
                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                anchors.left:           image.right
                anchors.verticalCenter: parent.verticalCenter
53 54 55
                verticalAlignment:      TextEdit.AlignVCenter
                color:                  showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
                text:                   control.text
Don Gagne's avatar
Don Gagne committed
56 57 58
            }
        }

59
        label: Item {}
Don Gagne's avatar
Don Gagne committed
60 61
    }
}