Commit 1c7769f4 authored by Bryant Mairs's avatar Bryant Mairs

Fixed canceling the Logging function through the button on the main toolbar.

parent ebfb5edb
...@@ -49,7 +49,6 @@ QGCToolBar::QGCToolBar(QWidget *parent) : ...@@ -49,7 +49,6 @@ QGCToolBar::QGCToolBar(QWidget *parent) :
addAction(toggleLoggingAction); addAction(toggleLoggingAction);
addAction(logReplayAction); addAction(logReplayAction);
// addSeparator();
// CREATE TOOLBAR ITEMS // CREATE TOOLBAR ITEMS
// Add internal actions // Add internal actions
...@@ -123,7 +122,7 @@ void QGCToolBar::setLogPlayer(QGCMAVLinkLogPlayer* player) ...@@ -123,7 +122,7 @@ void QGCToolBar::setLogPlayer(QGCMAVLinkLogPlayer* player)
connect(logReplayAction, SIGNAL(triggered(bool)), this, SLOT(playLogFile(bool))); connect(logReplayAction, SIGNAL(triggered(bool)), this, SLOT(playLogFile(bool)));
} }
void QGCToolBar::playLogFile(bool enabled) void QGCToolBar::playLogFile(bool checked)
{ {
// Check if player exists // Check if player exists
if (player) if (player)
...@@ -133,7 +132,7 @@ void QGCToolBar::playLogFile(bool enabled) ...@@ -133,7 +132,7 @@ void QGCToolBar::playLogFile(bool enabled)
if (player->isPlayingLogFile()) if (player->isPlayingLogFile())
{ {
player->playPause(false); player->playPause(false);
if (enabled) if (checked)
{ {
if (!player->selectLogFile()) return; if (!player->selectLogFile()) return;
} }
...@@ -143,23 +142,35 @@ void QGCToolBar::playLogFile(bool enabled) ...@@ -143,23 +142,35 @@ void QGCToolBar::playLogFile(bool enabled)
{ {
if (!player->selectLogFile()) return; 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 // Stop logging in any case
MainWindow::instance()->getMAVLink()->enableLogging(false); 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);;")); 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")) if (!fileName.endsWith(".mavlink"))
{ {
fileName.append(".mavlink"); fileName.append(".mavlink");
} }
// Check that we can save the logfile
QFileInfo file(fileName); QFileInfo file(fileName);
if ((file.exists() && !file.isWritable())) if ((file.exists() && !file.isWritable()))
{ {
...@@ -171,6 +182,7 @@ void QGCToolBar::logging(bool enabled) ...@@ -171,6 +182,7 @@ void QGCToolBar::logging(bool enabled)
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
} }
// Otherwise we're off and logging
else else
{ {
MainWindow::instance()->getMAVLink()->setLogfileName(fileName); MainWindow::instance()->getMAVLink()->setLogfileName(fileName);
......
...@@ -55,9 +55,9 @@ public slots: ...@@ -55,9 +55,9 @@ public slots:
/** @brief Received system text message */ /** @brief Received system text message */
void receiveTextMessage(int uasid, int componentid, int severity, QString text); void receiveTextMessage(int uasid, int componentid, int severity, QString text);
/** @brief Start / stop logging */ /** @brief Start / stop logging */
void logging(bool enabled); void logging(bool checked);
/** @brief Start playing logfile */ /** @brief Start playing logfile */
void playLogFile(bool enabled); void playLogFile(bool checked);
/** @brief Set log playing component */ /** @brief Set log playing component */
void setLogPlayer(QGCMAVLinkLogPlayer* player); void setLogPlayer(QGCMAVLinkLogPlayer* player);
/** @brief Update battery charge state */ /** @brief Update battery charge state */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment