SubMenuButton.qml 2.7 KB
Newer Older
1 2
import QtQuick                  2.3
import QtQuick.Controls         1.2
3
import QtQuick.Controls.Styles  1.4
4
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 {
DonLakeFlyer's avatar
DonLakeFlyer committed
10
    id:             _rootButton
11 12 13
    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
14
    property size   sourceSize:     Qt.size(ScreenTools.defaultFontPixelHeight * 2, ScreenTools.defaultFontPixelHeight * 2)
Don Gagne's avatar
Don Gagne committed
15

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

18
    checkable:      true
dogmaphobic's avatar
dogmaphobic committed
19
    implicitHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3.5 : ScreenTools.defaultFontPixelHeight * 2.5
DonLakeFlyer's avatar
DonLakeFlyer committed
20
    implicitWidth:  __panel.implicitWidth
Don Gagne's avatar
Don Gagne committed
21 22 23 24

    style: ButtonStyle {
        id: buttonStyle

25 26 27
        QGCPalette {
            id:                 qgcPal
            colorGroupEnabled:  control.enabled
Don Gagne's avatar
Don Gagne committed
28 29
        }

30
        property bool showHighlight: control.pressed | control.checked
31

Don Gagne's avatar
Don Gagne committed
32
        background: Rectangle {
33
            id:     innerRect
34
            color:  showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
35

36 37
            implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth

38 39 40 41 42 43 44 45
            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
46
                mipmap:                 true
47 48
                color:                  control.setupComplete ? qgcPal.button : "red"
                source:                 control.imageResource
49
                sourceSize:             _rootButton.sourceSize
50
            }
Don Gagne's avatar
Don Gagne committed
51

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

63
        label: Item {}
Don Gagne's avatar
Don Gagne committed
64 65
    }
}