Skip to content
SubMenuButton.qml 2.7 KiB
Newer Older
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtGraphicalEffects       1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
Don Gagne's avatar
Don Gagne committed

Button {
DonLakeFlyer's avatar
DonLakeFlyer committed
    id:             _rootButton
    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
    property size   sourceSize:     Qt.size(ScreenTools.defaultFontPixelHeight * 2, ScreenTools.defaultFontPixelHeight * 2)
    text: "Button"  ///< Pass in your own button text

    checkable:      true
dogmaphobic's avatar
dogmaphobic committed
    implicitHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3.5 : ScreenTools.defaultFontPixelHeight * 2.5
DonLakeFlyer's avatar
DonLakeFlyer committed
    implicitWidth:  __panel.implicitWidth
Don Gagne's avatar
Don Gagne committed

    style: ButtonStyle {
        id: buttonStyle

        QGCPalette {
            id:                 qgcPal
            colorGroupEnabled:  control.enabled
        property bool showHighlight: control.pressed | control.checked
Don Gagne's avatar
Don Gagne committed
        background: Rectangle {
            color:  showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade
            implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth

            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
                color:                  control.setupComplete ? qgcPal.button : "red"
                source:                 control.imageResource
                sourceSize:             _rootButton.sourceSize
            QGCLabel {
                id:                     titleBar
                anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                anchors.left:           image.right
                anchors.verticalCenter: parent.verticalCenter
                verticalAlignment:      TextEdit.AlignVCenter
                color:                  showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
                text:                   control.text
Don Gagne's avatar
Don Gagne committed
    }
}