ROIIndicator.qml 3.25 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/****************************************************************************
 *
 * (c) 2009-2019 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.
 *
 * @file
 *   @author Gus Grubba <gus@auterion.com>
 */

import QtQuick          2.11
import QtQuick.Controls 1.4
import QtQuick.Layouts  1.11

import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0

//-------------------------------------------------------------------------
//-- ROI Indicator
Item {
    id:                     _root
    width:                  showIndicator ? roiIcon.width : 0
    visible:                showIndicator
    anchors.top:            parent.top
    anchors.bottom:         parent.bottom

31 32 33
    property bool showIndicator: _activeVehicle && _activeVehicle.roiModeSupported

    property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
Gus Grubba's avatar
Gus Grubba committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

    Component {
        id: roiInfo

        Rectangle {
            width:                  roiCol.width   + ScreenTools.defaultFontPixelWidth  * 6
            height:                 roiCol.height  + ScreenTools.defaultFontPixelHeight * 2
            radius:                 ScreenTools.defaultFontPixelHeight * 0.5
            color:                  qgcPal.window

            Column {
                id:                 roiCol
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(roiButton.width, roiLabel.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent

                QGCLabel {
                    id:             roiLabel
                    text:           qsTr("ROI Disabled")
                    font.family:    ScreenTools.demiboldFontFamily
                    visible:        !roiButton.visible
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                QGCButton {
                    id:             roiButton
61
                    visible:        _activeVehicle && _activeVehicle.isROIEnabled
Gus Grubba's avatar
Gus Grubba committed
62 63
                    text:           qsTr("Disable ROI")
                    onClicked: {
64 65
                        if(_activeVehicle)
                            _activeVehicle.stopGuidedModeROI()
66
                        mainWindow.hideIndicatorPopup()
Gus Grubba's avatar
Gus Grubba committed
67 68 69 70 71 72 73 74 75 76 77 78 79
                    }
                }
            }
        }
    }

    QGCColoredImage {
        id:                 roiIcon
        width:              height
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
        sourceSize.height:  height
        source:             "/qmlimages/roi.svg"
80
        color:              _activeVehicle && _activeVehicle.isROIEnabled ? qgcPal.colorGreen : qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
81
        fillMode:           Image.PreserveAspectFit
82
        opacity:            _activeVehicle && _activeVehicle.isROIEnabled ? 1 : 0.5
Gus Grubba's avatar
Gus Grubba committed
83 84 85 86 87
    }

    MouseArea {
        anchors.fill:   parent
        onClicked: {
88
            mainWindow.showIndicatorPopup(_root, roiInfo)
Gus Grubba's avatar
Gus Grubba committed
89 90 91
        }
    }
}