LogReplayStatusBar.qml 3.71 KB
Newer Older
1
import QtQuick          2.3
2
import QtQuick.Controls 2.4
3 4 5 6 7 8 9 10 11 12 13
import QtQuick.Layouts  1.11
import QtQuick.Dialogs  1.2

import QGroundControl               1.0
import QGroundControl.Palette       1.0
import QGroundControl.ScreenTools   1.0

Rectangle {
    height:             visible ? (rowLayout.height + (_margins * 2)) : 0
    color:              qgcPal.window

14 15
    property real   _margins:       ScreenTools.defaultFontPixelHeight / 4
    property var    _logReplayLink: null
16 17

    function pickLogFile() {
18
        if (globals.activeVehicle) {
19
            mainWindow.showMessageDialog(qsTr("Log Replay"), qsTr("You must close all connections prior to replaying a log."))
20 21 22 23 24 25 26 27 28 29 30
            return
        }

        filePicker.openForLoad()
    }

    QGCPalette { id: qgcPal }

    QGCFileDialog {
        id:                 filePicker
        title:              qsTr("Select Telemetery Log")
31
        nameFilters:        [ qsTr("Telemetry Logs (*.%1)").arg(_logFileExtension), qsTr("All Files (*)") ]
32 33 34 35 36 37
        selectExisting:     true
        folder:             QGroundControl.settingsManager.appSettings.telemetrySavePath
        onAcceptedForLoad: {
            controller.link = QGroundControl.linkManager.startLogReplay(file)
            close()
        }
38 39

        property string _logFileExtension: QGroundControl.settingsManager.appSettings.telemetryFileExtension
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    }

    LogReplayLinkController {
        id: controller

        onPercentCompleteChanged: slider.updatePercentComplete(percentComplete)
    }

    RowLayout {
        id:                 rowLayout
        anchors.margins:    _margins
        anchors.top:        parent.top
        anchors.left:       parent.left
        anchors.right:      parent.right

        QGCButton {
            text:       controller.isPlaying ? qsTr("Pause") : qsTr("Play")
            enabled:    controller.link
            onClicked:  controller.isPlaying = !controller.isPlaying
        }

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        QGCComboBox {
            textRole:       "text"
            currentIndex:   3

            model: ListModel {
                ListElement { text: "0.1";  value: 0.1 }
                ListElement { text: "0.25"; value: 0.25 }
                ListElement { text: "0.5";  value: 0.5 }
                ListElement { text: "1x";   value: 1 }
                ListElement { text: "2x";   value: 2 }
                ListElement { text: "5x";   value: 5 }
            }

            onActivated: controller.playbackSpeed = model.get(currentIndex).value
        }

77 78 79 80 81
        QGCLabel { text: controller.playheadTime }

        Slider {
            id:                 slider
            Layout.fillWidth:   true
82 83
            from:               0
            to:                 100
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
            enabled:            controller.link

            property bool manualUpdate: false

            function updatePercentComplete(percentComplete) {
                manualUpdate = true
                value = percentComplete
                manualUpdate = false
            }

            onValueChanged: {
                if (!manualUpdate) {
                    controller.percentComplete = value
                }
            }
        }

        QGCLabel { text: controller.totalTime }

        QGCButton {
            text:       qsTr("Load Telemetry Log")
            onClicked:  pickLogFile()
            visible:    !controller.link
        }
DonLakeFlyer's avatar
DonLakeFlyer committed
108 109 110 111 112 113 114 115 116 117 118

        QGCButton {
            text:       qsTr("Close")
            onClicked: {
                var activeVehicle = QGroundControl.multiVehicleManager.activeVehicle
                if (activeVehicle) {
                    activeVehicle.disconnectInactiveVehicle()
                }
                QGroundControl.settingsManager.flyViewSettings.showLogReplayStatusBar.rawValue = false
            }
        }
119 120
    }
}