diff --git a/ground/gcs/src/libs/utils/logfile.cpp b/ground/gcs/src/libs/utils/logfile.cpp
index 35eb93ff2..70a1060f1 100644
--- a/ground/gcs/src/libs/utils/logfile.cpp
+++ b/ground/gcs/src/libs/utils/logfile.cpp
@@ -305,11 +305,14 @@ bool LogFile::startReplay()
*/
bool LogFile::stopReplay()
{
- if (!m_file.isOpen() || !m_timer.isActive()) {
+ if (!m_file.isOpen()) {
return false;
}
+ if (m_timer.isActive()) {
+ m_timer.stop();
+ }
+
qDebug() << "LogFile - stopReplay";
- m_timer.stop();
m_replayState = STOPPED;
emit replayFinished();
@@ -386,9 +389,6 @@ bool LogFile::pauseReplay()
qDebug() << "LogFile - pauseReplay";
m_timer.stop();
m_replayState = PAUSED;
-
- // hack to notify UI that replay paused
- emit replayStarted();
return true;
}
@@ -527,7 +527,7 @@ bool LogFile::buildIndex()
}
}
- emit updateBeginAndEndTimes(m_beginTimeStamp, m_endTimeStamp);
+ emit setBeginAndEndTimes(m_beginTimeStamp, m_endTimeStamp);
// reset the read pointer to the start of the file
m_file.seek(0);
diff --git a/ground/gcs/src/libs/utils/logfile.h b/ground/gcs/src/libs/utils/logfile.h
index ef1672267..7e19c02a0 100644
--- a/ground/gcs/src/libs/utils/logfile.h
+++ b/ground/gcs/src/libs/utils/logfile.h
@@ -99,7 +99,7 @@ signals:
void replayStarted();
void replayFinished();
void setPlaybackPosition(quint32);
- void updateBeginAndEndTimes(quint32, quint32);
+ void setBeginAndEndTimes(quint32, quint32);
protected:
QByteArray m_dataBuffer;
diff --git a/ground/gcs/src/plugins/logging/logging.ui b/ground/gcs/src/plugins/logging/logging.ui
index 421ecb2cd..e9537c935 100644
--- a/ground/gcs/src/plugins/logging/logging.ui
+++ b/ground/gcs/src/plugins/logging/logging.ui
@@ -7,7 +7,7 @@
0
0
439
- 118
+ 120
@@ -27,34 +27,43 @@
-
-
+
+
+ 3
+
-
-
+
QLayout::SetNoConstraint
-
-
+
+
+ true
+
-
- 80
+
+ 0
0
- 30
- 0
+ 39
+ 38
-
+
- 80
- 16777215
+ 39
+ 38
-
- Play
+
+ Qt::NoFocus
+
+
+ false
@@ -69,27 +78,44 @@
-
-
+
-
- 80
+
+ 0
0
- 30
- 0
+ 39
+ 38
-
+
+
+ :/logging/images/pause.png:/logging/images/pause.png
+
+
- 80
- 16777215
+ 16
+ 16
-
- Stop
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 39
+ 38
+
@@ -121,12 +147,15 @@
Playback speed:
+
+ true
+
-
-
+
0
0
@@ -170,6 +199,12 @@
-
+
+
+ 65
+ 0
+
+
75
@@ -184,29 +219,20 @@
-
-
+
true
Qt::Horizontal
-
- false
-
-
- false
-
-
- QSlider::TicksBothSides
-
-
- 5
-
-
+
+ 0
+
0
@@ -230,6 +256,9 @@
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
-
@@ -262,6 +291,9 @@
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
-
@@ -295,7 +327,7 @@
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+ Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing
diff --git a/ground/gcs/src/plugins/logging/logginggadgetwidget.cpp b/ground/gcs/src/plugins/logging/logginggadgetwidget.cpp
index eebe3118e..6a84b1179 100644
--- a/ground/gcs/src/plugins/logging/logginggadgetwidget.cpp
+++ b/ground/gcs/src/plugins/logging/logginggadgetwidget.cpp
@@ -42,10 +42,7 @@ LoggingGadgetWidget::LoggingGadgetWidget(QWidget *parent) : QWidget(parent), log
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
scpPlugin = pm->getObject();
- // Store preferred button width before manipulating the button appearance
- m_preferredButtonWidth = m_logging->playPauseButton->sizeHint().width();
-
- disableButtons();
+ disableWidgets();
// Configure timer to delay application of slider position action for 200ms
sliderActionDelay.setSingleShot(true);
@@ -65,7 +62,8 @@ void LoggingGadgetWidget::setPlugin(LoggingPlugin *p)
LogFile *logFile = loggingPlugin->getLogfile();
// GUI elements to gadgetwidget functions
- connect(m_logging->playPauseButton, &QPushButton::clicked, this, &LoggingGadgetWidget::playPauseButtonAction);
+ connect(m_logging->playButton, &QPushButton::clicked, this, &LoggingGadgetWidget::playButtonAction);
+ connect(m_logging->pauseButton, &QPushButton::clicked, this, &LoggingGadgetWidget::pauseButtonAction);
connect(m_logging->stopButton, &QPushButton::clicked, this, &LoggingGadgetWidget::stopButtonAction);
connect(m_logging->playbackPosition, &QSlider::valueChanged, this, &LoggingGadgetWidget::sliderMoved);
@@ -83,10 +81,10 @@ void LoggingGadgetWidget::setPlugin(LoggingPlugin *p)
// Feedback from logfile to GUI
connect(loggingPlugin, &LoggingPlugin::stateChanged, this, &LoggingGadgetWidget::stateChanged);
- connect(logFile, &LogFile::updateBeginAndEndTimes, this, &LoggingGadgetWidget::updateBeginAndEndTimes);
+ connect(logFile, &LogFile::setBeginAndEndTimes, this, &LoggingGadgetWidget::setBeginAndEndTimes);
connect(logFile, &LogFile::setPlaybackPosition, this, &LoggingGadgetWidget::setPlaybackPosition);
- connect(logFile, &LogFile::replayStarted, this, &LoggingGadgetWidget::enableButtons);
- connect(logFile, &LogFile::replayFinished, this, &LoggingGadgetWidget::disableButtons);
+ connect(logFile, &LogFile::replayStarted, this, &LoggingGadgetWidget::enableWidgets);
+ connect(logFile, &LogFile::replayFinished, this, &LoggingGadgetWidget::disableWidgets);
// Feedback from logfile to scope
connect(logFile, &LogFile::replayFinished, scpPlugin, &ScopeGadgetFactory::stopPlotting);
@@ -95,84 +93,52 @@ void LoggingGadgetWidget::setPlugin(LoggingPlugin *p)
stateChanged(loggingPlugin->getState());
}
-/*
- resizeEvent()
-
- Determine button content policy based on button size.
-
- */
-void LoggingGadgetWidget::resizeEvent(QResizeEvent *event)
+void LoggingGadgetWidget::playButtonAction()
{
- int width = m_logging->playPauseButton->size().width();
+ ReplayState replayState = (loggingPlugin->getLogfile())->getReplayState();
- if (width < m_preferredButtonWidth) {
- m_iconOnlyButtons = true;
- } else {
- m_iconOnlyButtons = false;
+ if (replayState != PLAYING) {
+ emit resumeReplay(m_logging->playbackPosition->value());
}
- updateButtonAppearance();
- QWidget::resizeEvent(event);
+ m_logging->playButton->setVisible(false);
+ m_logging->pauseButton->setVisible(true);
+ m_logging->stopButton->setEnabled(true);
}
-/*
- setPlayPauseButtonToPlay()
-
- Changes the appearance of the playPause button to the PLAY appearance.
- */
-void LoggingGadgetWidget::setPlayPauseButtonToPlay()
+void LoggingGadgetWidget::pauseButtonAction()
{
- m_logging->playPauseButton->setIcon(QIcon(":/logging/images/play.png"));
- if (m_iconOnlyButtons) {
- m_logging->playPauseButton->setText(QString());
- } else {
- m_logging->playPauseButton->setText(tr(" Play"));
- }
-}
-
-/*
- setPlayPauseButtonToPause()
-
- Changes the appearance of the playPause button to the PAUSE appearance.
- */
-void LoggingGadgetWidget::setPlayPauseButtonToPause()
-{
- m_logging->playPauseButton->setIcon(QIcon(":/logging/images/pause.png"));
- if (m_iconOnlyButtons) {
- m_logging->playPauseButton->setText(QString());
- } else {
- m_logging->playPauseButton->setText(tr(" Pause"));
- }
-}
-
-void LoggingGadgetWidget::playPauseButtonAction()
-{
- ReplayState replayState = loggingPlugin->getLogfile()->getReplayState();
+ ReplayState replayState = (loggingPlugin->getLogfile())->getReplayState();
if (replayState == PLAYING) {
emit pauseReplay();
- setPlayPauseButtonToPlay();
- } else {
- emit resumeReplay(m_logging->playbackPosition->value());
- setPlayPauseButtonToPause();
}
+
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
m_logging->stopButton->setEnabled(true);
+
+ m_logging->statusLabel->setText(tr("Paused"));
}
void LoggingGadgetWidget::stopButtonAction()
{
- ReplayState replayState = loggingPlugin->getLogfile()->getReplayState();
+ ReplayState replayState = (loggingPlugin->getLogfile())->getReplayState();
if (replayState != STOPPED) {
emit pauseReplayAndResetPosition();
}
+
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
m_logging->stopButton->setEnabled(false);
- setPlayPauseButtonToPlay();
// Block signals while setting the slider to the start position
m_logging->playbackPosition->blockSignals(true);
m_logging->playbackPosition->setValue(m_logging->playbackPosition->minimum());
m_logging->playbackPosition->blockSignals(false);
+
+ m_logging->statusLabel->setText(tr("Paused"));
}
void LoggingGadgetWidget::stateChanged(LoggingPlugin::State state)
@@ -196,16 +162,20 @@ void LoggingGadgetWidget::stateChanged(LoggingPlugin::State state)
m_logging->statusLabel->setText(status);
bool playing = loggingPlugin->getLogfile()->isPlaying();
+ m_logging->playButton->setEnabled(enabled);
+ m_logging->pauseButton->setEnabled(enabled);
m_logging->stopButton->setEnabled(enabled && playing);
- m_logging->playPauseButton->setEnabled(enabled);
+
if (playing) {
- setPlayPauseButtonToPause();
+ m_logging->playButton->setVisible(false);
+ m_logging->pauseButton->setVisible(true);
} else {
- setPlayPauseButtonToPlay();
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
}
}
-void LoggingGadgetWidget::updateBeginAndEndTimes(quint32 startTimeStamp, quint32 endTimeStamp)
+void LoggingGadgetWidget::setBeginAndEndTimes(quint32 startTimeStamp, quint32 endTimeStamp)
{
int startSec, startMin, endSec, endMin;
@@ -225,8 +195,6 @@ void LoggingGadgetWidget::updateBeginAndEndTimes(quint32 startTimeStamp, quint32
m_logging->playbackPosition->setSingleStep((endTimeStamp - startTimeStamp) / 100);
m_logging->playbackPosition->setPageStep((endTimeStamp - startTimeStamp) / 10);
- m_logging->playbackPosition->setTickInterval((endTimeStamp - startTimeStamp) / 10);
- m_logging->playbackPosition->setTickPosition(QSlider::TicksBothSides);
}
void LoggingGadgetWidget::setPlaybackPosition(quint32 positionTimeStamp)
@@ -243,65 +211,49 @@ void LoggingGadgetWidget::setPlaybackPosition(quint32 positionTimeStamp)
}
}
-void LoggingGadgetWidget::enableButtons()
+void LoggingGadgetWidget::enableWidgets()
{
ReplayState replayState = loggingPlugin->getLogfile()->getReplayState();
+ m_logging->playButton->setEnabled(true);
+ m_logging->pauseButton->setEnabled(true);
+
switch (replayState) {
case STOPPED:
m_logging->stopButton->setEnabled(false);
- setPlayPauseButtonToPlay();
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
break;
case PLAYING:
m_logging->stopButton->setEnabled(true);
- setPlayPauseButtonToPause();
+ m_logging->playButton->setVisible(false);
+ m_logging->pauseButton->setVisible(true);
break;
case PAUSED:
m_logging->stopButton->setEnabled(true);
- setPlayPauseButtonToPlay();
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
break;
}
- m_logging->playPauseButton->setEnabled(true);
m_logging->playbackPosition->setEnabled(true);
}
-void LoggingGadgetWidget::disableButtons()
+void LoggingGadgetWidget::disableWidgets()
{
- m_logging->playPauseButton->setEnabled(false);
- setPlayPauseButtonToPlay();
+ m_logging->playButton->setVisible(true);
+ m_logging->pauseButton->setVisible(false);
+
+ m_logging->playButton->setEnabled(false);
+ m_logging->pauseButton->setEnabled(false);
m_logging->stopButton->setEnabled(false);
m_logging->playbackPosition->setEnabled(false);
-}
-void LoggingGadgetWidget::updateButtonAppearance()
-{
- ReplayState replayState;
-
- if (!loggingPlugin || !loggingPlugin->getLogfile()) {
- // loggingPlugin has not been completely initialized: set to STOPPED state
- replayState = STOPPED;
- } else {
- replayState = loggingPlugin->getLogfile()->getReplayState();
- }
-
- // Update playPause button appearance
- if (replayState == PLAYING) {
- // Playing: playPause button must appear as a pause button
- setPlayPauseButtonToPause();
- } else {
- // Stopped or Paused: playPause button must appear as a play button
- setPlayPauseButtonToPlay();
- }
-
- // Update stop button appearance
- if (m_iconOnlyButtons) {
- m_logging->stopButton->setText(QString());
- } else {
- m_logging->stopButton->setText(tr(" Stop"));
- }
+ // reset start and end labels
+ m_logging->startTimeLabel->setText("");
+ m_logging->endTimeLabel->setText("");
}
void LoggingGadgetWidget::updatePositionLabel(quint32 positionTimeStamp)
diff --git a/ground/gcs/src/plugins/logging/logginggadgetwidget.h b/ground/gcs/src/plugins/logging/logginggadgetwidget.h
index b5f778759..f07f20304 100644
--- a/ground/gcs/src/plugins/logging/logginggadgetwidget.h
+++ b/ground/gcs/src/plugins/logging/logginggadgetwidget.h
@@ -50,12 +50,13 @@ public:
protected slots:
void stateChanged(LoggingPlugin::State state);
- void updateBeginAndEndTimes(quint32 startTimeStamp, quint32 endTimeStamp);
+ void setBeginAndEndTimes(quint32 startTimeStamp, quint32 endTimeStamp);
void setPlaybackPosition(quint32 positionTimeStamp);
- void playPauseButtonAction();
+ void playButtonAction();
+ void pauseButtonAction();
void stopButtonAction();
- void enableButtons();
- void disableButtons();
+ void enableWidgets();
+ void disableWidgets();
void sliderMoved(int);
void sliderAction();
@@ -69,14 +70,8 @@ private:
LoggingPlugin *loggingPlugin;
ScopeGadgetFactory *scpPlugin;
QTimer sliderActionDelay;
- bool m_iconOnlyButtons;
- int m_preferredButtonWidth;
void updatePositionLabel(quint32 positionTimeStamp);
- void setPlayPauseButtonToPlay();
- void setPlayPauseButtonToPause();
- void updateButtonAppearance();
- void resizeEvent(QResizeEvent *event);
};
#endif /* LoggingGADGETWIDGET_H_ */