From c355dfff4410d495d781ead783fbff3197af1f53 Mon Sep 17 00:00:00 2001 From: edouard Date: Sun, 13 Mar 2011 21:23:26 +0000 Subject: [PATCH] OP-250 Update menu entry for logging so that it reads "Stop logging" when logging is going on. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3038 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/logging/loggingplugin.cpp | 20 +++++++++---------- .../src/plugins/logging/loggingplugin.h | 7 ++++++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp index 18f48c1c1..92f1593cf 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp @@ -40,9 +40,6 @@ #include #include -#include -#include -#include #include #include "uavobjectmanager.h" @@ -71,6 +68,8 @@ QStringList LoggingConnection::availableDevices() QIODevice* LoggingConnection::openDevice(const QString &deviceName) { + Q_UNUSED(deviceName) + if (logFile.isOpen()){ logFile.close(); } @@ -329,7 +328,7 @@ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg) Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to start logging - Core::Command* cmd = am->registerAction(new QAction(this), + cmd = am->registerAction(new QAction(this), "LoggingPlugin.Logging", QList() << Core::Constants::C_GLOBAL_ID); @@ -360,22 +359,21 @@ void LoggingPlugin::toggleLogging() { if(state == IDLE) { - /*QFileDialog * fd = new QFileDialog(); - fd->setAcceptMode(QFileDialog::AcceptSave); - fd->setNameFilter("OpenPilot Log (*.opl)"); - connect(fd, SIGNAL(fileSelected(QString)), this, SLOT(startLogging(QString))); - fd->exec();*/ QString fileName = QFileDialog::getSaveFileName(NULL, tr("Start Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), tr("OpenPilot Log (*.opl)")); - if(!fileName.isEmpty()) - startLogging(fileName); + if (fileName.isEmpty()) + return; + + startLogging(fileName); + cmd->action()->setText(tr("Stop logging")); } else if(state == LOGGING) { stopLogging(); + cmd->action()->setText(tr("Start logging...")); } } diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h index ca1933eae..5bc8059b4 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h @@ -27,6 +27,9 @@ #ifndef LOGGINGPLUGIN_H_ #define LOGGINGPLUGIN_H_ +#include +#include +#include #include #include #include "uavobjectmanager.h" @@ -120,6 +123,7 @@ public: LoggingConnection* getLogConnection() { return logConnection; }; LogFile* getLogfile() { return logConnection->getLogfile();} + void setLogMenuTitle(QString str); signals: @@ -134,7 +138,7 @@ protected: // These are used for replay, logging in its own thread UAVTalk * uavTalk; - LoggingConnection* logConnection; + LoggingConnection* logConnection; private slots: void toggleLogging(); @@ -145,6 +149,7 @@ private slots: private: LoggingGadgetFactory *mf; + Core::Command* cmd; }; #endif /* LoggingPLUGIN_H_ */