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

10
import QtQuick          2.3
11
import QtQuick.Controls 2.4
dogmaphobic's avatar
dogmaphobic committed
12 13 14 15

import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0

16 17 18 19 20 21 22 23 24 25 26
Button {
    id:                 mapButton
    height:             ScreenTools.defaultFontPixelHeight * 4
    autoExclusive:      true

    background: Rectangle {
        anchors.fill:   parent
        color:          _showHighlight ? qgcPal.buttonHighlight : qgcPal.button
        border.width:   _showBorder ? 1: 0
        border.color:   qgcPal.buttonText
    }
dogmaphobic's avatar
dogmaphobic committed
27

28 29
    property var    tileSet:    null
    property var    currentSet: null
dogmaphobic's avatar
dogmaphobic committed
30
    property bool   complete:   false
dogmaphobic's avatar
dogmaphobic committed
31 32
    property int    tiles:      0
    property string size:       ""
dogmaphobic's avatar
dogmaphobic committed
33

34 35 36 37 38 39 40 41 42
    property bool   _showHighlight: (_pressed | _hovered | checked) && !_forceHoverOff
    property bool   _showBorder:    qgcPal.globalTheme === QGCPalette.Light

    property bool   _forceHoverOff:    false
    property int    _lastGlobalMouseX: 0
    property int    _lastGlobalMouseY: 0
    property bool   _pressed:          false
    property bool   _hovered:          false

43 44 45
    contentItem: Row {
        anchors.centerIn:   parent
        anchors.margins:    ScreenTools.defaultFontPixelWidth
dogmaphobic's avatar
dogmaphobic committed
46
        QGCLabel {
47
            text:   mapButton.text
48 49
            width:  mapButton.width * 0.4
            color:  _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
dogmaphobic's avatar
dogmaphobic committed
50 51 52 53
            anchors.verticalCenter: parent.verticalCenter
        }
        QGCLabel {
            id:     sizeLabel
54
            width:  mapButton.width * 0.4
dogmaphobic's avatar
dogmaphobic committed
55 56
            horizontalAlignment: Text.AlignRight
            anchors.verticalCenter: parent.verticalCenter
57 58
            color:  _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
            text:   mapButton.size + (tiles > 0 ? " (" + tiles + " tiles)" : "")
dogmaphobic's avatar
dogmaphobic committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
        }
        Item {
            width:  ScreenTools.defaultFontPixelWidth * 2
            height: 1
        }
        Rectangle {
            width:   sizeLabel.height * 0.5
            height:  sizeLabel.height * 0.5
            radius:  width / 2
            color:   complete ? "#31f55b" : "#fc5656"
            opacity: sizeLabel.text.length > 0 ? 1 : 0
            anchors.verticalCenter: parent.verticalCenter
        }
        Item {
            width:  ScreenTools.defaultFontPixelWidth * 2
            height: 1
        }
        QGCColoredImage {
            width:      sizeLabel.height * 0.8
            height:     sizeLabel.height * 0.8
dogmaphobic's avatar
dogmaphobic committed
79
            sourceSize.height:  height
dogmaphobic's avatar
dogmaphobic committed
80 81 82
            source:     "/res/buttonRight.svg"
            mipmap:     true
            fillMode:   Image.PreserveAspectFit
83
            color:      _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
dogmaphobic's avatar
dogmaphobic committed
84 85 86 87
            anchors.verticalCenter: parent.verticalCenter
        }
    }
}