From 1c7769f4da24e595be3812b71e29086fd86c111e Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 22 Mar 2012 11:00:42 -0700 Subject: [PATCH] Fixed canceling the Logging function through the button on the main toolbar. --- src/ui/QGCToolBar.cc | 24 ++++++++++++++++++------ src/ui/QGCToolBar.h | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 106725ec0..d80cfdbf6 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -49,7 +49,6 @@ QGCToolBar::QGCToolBar(QWidget *parent) : addAction(toggleLoggingAction); addAction(logReplayAction); -// addSeparator(); // CREATE TOOLBAR ITEMS // Add internal actions @@ -123,7 +122,7 @@ void QGCToolBar::setLogPlayer(QGCMAVLinkLogPlayer* player) connect(logReplayAction, SIGNAL(triggered(bool)), this, SLOT(playLogFile(bool))); } -void QGCToolBar::playLogFile(bool enabled) +void QGCToolBar::playLogFile(bool checked) { // Check if player exists if (player) @@ -133,7 +132,7 @@ void QGCToolBar::playLogFile(bool enabled) if (player->isPlayingLogFile()) { player->playPause(false); - if (enabled) + if (checked) { if (!player->selectLogFile()) return; } @@ -143,23 +142,35 @@ void QGCToolBar::playLogFile(bool enabled) { if (!player->selectLogFile()) return; } - player->playPause(enabled); + player->playPause(checked); } } -void QGCToolBar::logging(bool enabled) +void QGCToolBar::logging(bool checked) { // Stop logging in any case MainWindow::instance()->getMAVLink()->enableLogging(false); - if (enabled) + + // If the user is enabling logging + if (checked) { + // Prompt the user for a filename/location to save to QString fileName = QFileDialog::getSaveFileName(this, tr("Specify MAVLink log file to save to"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("MAVLink Logfile (*.mavlink *.log *.bin);;")); + // Check that they didn't cancel out + if (fileName.isNull()) + { + toggleLoggingAction->setChecked(false); + return; + } + + // Make sure the file's named properly if (!fileName.endsWith(".mavlink")) { fileName.append(".mavlink"); } + // Check that we can save the logfile QFileInfo file(fileName); if ((file.exists() && !file.isWritable())) { @@ -171,6 +182,7 @@ void QGCToolBar::logging(bool enabled) msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); } + // Otherwise we're off and logging else { MainWindow::instance()->getMAVLink()->setLogfileName(fileName); diff --git a/src/ui/QGCToolBar.h b/src/ui/QGCToolBar.h index e02eca683..86f658df1 100644 --- a/src/ui/QGCToolBar.h +++ b/src/ui/QGCToolBar.h @@ -55,9 +55,9 @@ public slots: /** @brief Received system text message */ void receiveTextMessage(int uasid, int componentid, int severity, QString text); /** @brief Start / stop logging */ - void logging(bool enabled); + void logging(bool checked); /** @brief Start playing logfile */ - void playLogFile(bool enabled); + void playLogFile(bool checked); /** @brief Set log playing component */ void setLogPlayer(QGCMAVLinkLogPlayer* player); /** @brief Update battery charge state */ -- 2.22.0