QGCToolBarButton.qml 1.99 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10


11
import QtQuick          2.3
Gus Grubba's avatar
Gus Grubba committed
12
import QtQuick.Controls 2.4
13

14 15 16
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0
17

Gus Grubba's avatar
Gus Grubba committed
18 19 20 21
Button {
    id:                 button
    height:             ScreenTools.defaultFontPixelHeight * 3
    autoExclusive:      true
dogmaphobic's avatar
dogmaphobic committed
22

23 24
    property bool logo: false

25 26
    QGCPalette { id: qgcPal }

Gus Grubba's avatar
Gus Grubba committed
27 28
    background: Rectangle {
        anchors.fill: parent
29
        color:  logo ? qgcPal.brandingPurple : (checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0))
dogmaphobic's avatar
dogmaphobic committed
30 31
    }

Gus Grubba's avatar
Gus Grubba committed
32 33 34 35 36 37 38 39 40 41 42
    contentItem: Row {
        spacing:                    ScreenTools.defaultFontPixelWidth
        anchors.left:               button.left
        anchors.leftMargin:         ScreenTools.defaultFontPixelWidth
        anchors.verticalCenter:     button.verticalCenter
        QGCColoredImage {
            id:                     _icon
            height:                 ScreenTools.defaultFontPixelHeight * 2
            width:                  height
            sourceSize.height:      parent.height
            fillMode:               Image.PreserveAspectFit
43
            color:                  logo ? "white" : (button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText)
Gus Grubba's avatar
Gus Grubba committed
44 45 46 47 48
            source:                 button.icon.source
            anchors.verticalCenter: parent.verticalCenter
        }
        Label {
            id:                     _label
49
            visible:                text !== ""
Gus Grubba's avatar
Gus Grubba committed
50 51 52
            text:                   button.text
            color:                  button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
            anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
53 54
        }
    }
Gus Grubba's avatar
Gus Grubba committed
55

dogmaphobic's avatar
dogmaphobic committed
56
}