From 28ebe38a402fa38eacc2c39dff6e5beebcc0ef86 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 2 Jul 2019 11:49:51 -0700 Subject: [PATCH] Cherry pick live scrubbing from master --- src/comm/LogReplayLink.cc | 19 +++++++++++++++---- src/comm/LogReplayLink.h | 1 + src/ui/QGCMAVLinkLogPlayer.cc | 2 -- src/ui/QGCMAVLinkLogPlayer.ui | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/comm/LogReplayLink.cc b/src/comm/LogReplayLink.cc index f10ca077a..c9da144f1 100644 --- a/src/comm/LogReplayLink.cc +++ b/src/comm/LogReplayLink.cc @@ -14,6 +14,7 @@ #include #include +#include const char* LogReplayLinkConfiguration::_logFilenameKey = "logFilename"; @@ -378,7 +379,7 @@ void LogReplayLink::_readNextLogEntry(void) timeToNextExecutionMSecs = desiredPacedTimeMSecs - currentTimeMSecs; } - emit currentLogTimeSecs((_logCurrentTimeUSecs - _logStartTimeUSecs) / 1000000); + _signalCurrentLogTimeSecs(); // And schedule the next execution of this function. _readTickTimer.start(timeToNextExecutionMSecs); @@ -460,8 +461,12 @@ void LogReplayLink::_resetPlaybackToBeginning(void) void LogReplayLink::movePlayhead(int percentComplete) { if (isPlaying()) { - qWarning() << "Should not move playhead while playing, pause first"; - return; + _pauseOnThread(); + QSignalSpy waitForPause(this, SIGNAL(playbackPaused)); + waitForPause.wait(); + if (_readTickTimer.isActive()) { + return; + } } if (percentComplete < 0 || percentComplete > 100) { @@ -505,7 +510,8 @@ void LogReplayLink::movePlayhead(int percentComplete) // And scan until we reach the start of a MAVLink message. We make sure to record this timestamp for // smooth jumping around the file. _logCurrentTimeUSecs = _seekToNextMavlinkMessage(&dummy); - + _signalCurrentLogTimeSecs(); + // Now update the UI with our actual final position. newRelativeTimeUSecs = (float)(_logCurrentTimeUSecs - _logStartTimeUSecs); percentComplete = (newRelativeTimeUSecs / _logDurationUSecs) * 100; @@ -571,3 +577,8 @@ void LogReplayLink::_playbackError(void) _logFile.close(); emit playbackError(); } + +void LogReplayLink::_signalCurrentLogTimeSecs(void) +{ + emit currentLogTimeSecs((_logCurrentTimeUSecs - _logStartTimeUSecs) / 1000000); +} diff --git a/src/comm/LogReplayLink.h b/src/comm/LogReplayLink.h index fecb77ac4..1b661fdf0 100644 --- a/src/comm/LogReplayLink.h +++ b/src/comm/LogReplayLink.h @@ -121,6 +121,7 @@ private: void _finishPlayback(void); void _playbackError(void); void _resetPlaybackToBeginning(void); + void _signalCurrentLogTimeSecs(void); // Virtuals from LinkInterface virtual bool _connect(void); diff --git a/src/ui/QGCMAVLinkLogPlayer.cc b/src/ui/QGCMAVLinkLogPlayer.cc index 6a7d83b6e..e28824f36 100644 --- a/src/ui/QGCMAVLinkLogPlayer.cc +++ b/src/ui/QGCMAVLinkLogPlayer.cc @@ -142,7 +142,6 @@ void QGCMAVLinkLogPlayer::_playbackStarted(void) _enablePlaybackControls(true); _ui->playButton->setChecked(true); _ui->playButton->setIcon(QIcon(":/res/Pause")); - _ui->positionSlider->setEnabled(false); } /// Signalled from LogReplayLink when replay is paused @@ -150,7 +149,6 @@ void QGCMAVLinkLogPlayer::_playbackPaused(void) { _ui->playButton->setIcon(QIcon(":/res/Play")); _ui->playButton->setChecked(false); - _ui->positionSlider->setEnabled(true); } void QGCMAVLinkLogPlayer::_playbackPercentCompleteChanged(int percentComplete) diff --git a/src/ui/QGCMAVLinkLogPlayer.ui b/src/ui/QGCMAVLinkLogPlayer.ui index f80f6ac95..2253c908d 100644 --- a/src/ui/QGCMAVLinkLogPlayer.ui +++ b/src/ui/QGCMAVLinkLogPlayer.ui @@ -75,7 +75,7 @@ 100 - false + true Qt::Horizontal -- 2.22.0