From cbe4eea01e8a6115fc4fd22956c509e2de46a479 Mon Sep 17 00:00:00 2001 From: m_thread Date: Sat, 8 Mar 2014 13:47:41 +0100 Subject: [PATCH] OP-1245 Added buttons and combobox to the logging settings panel. --- .../src/plugins/flightlog/FlightLogDialog.qml | 53 +++++++++++++++++-- .../src/plugins/flightlog/flightlogdialog.cpp | 2 + .../plugins/flightlog/flightlogmanager.cpp | 10 +++- .../src/plugins/flightlog/flightlogmanager.h | 25 ++++++++- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 533974393..aeabd5e24 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -175,7 +175,21 @@ Rectangle { anchors.fill: parent Text { Layout.fillWidth: true - text: "" + qsTr("Log settings") + "" + text: "" + qsTr("Settings") + "" + } + + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + Text { + text: qsTr("When to log: ") + } + ComboBox { + enabled: !logManager.disableControls && logManager.boardConnected + model: logManager.logStatuses + currentIndex: logSettings.getLoggingEnabled() + } + } Component { @@ -246,6 +260,39 @@ Rectangle { delegate: comboEditableDelegate } } + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + + Button { + enabled: !logManager.disableControls && logManager.boardConnected + text: qsTr("Load...") + activeFocusOnPress: true + } + Button { + enabled: !logManager.disableControls && logManager.boardConnected + text: qsTr("Save...") + activeFocusOnPress: true + } + Button { + enabled: !logManager.disableControls && logManager.boardConnected + text: qsTr("Reset") + activeFocusOnPress: true + } + Rectangle { + Layout.fillWidth: true + } + Button { + enabled: !logManager.disableControls && logManager.boardConnected + text: qsTr("Apply to board") + activeFocusOnPress: true + } + Button { + enabled: !logManager.disableControls && logManager.boardConnected + text: qsTr("Save to board") + activeFocusOnPress: true + } + } } } @@ -255,14 +302,14 @@ Rectangle { Button { id: settingsButton enabled: !logManager.disableControls - text: qsTr("Log settings...") + text: qsTr("Settings...") activeFocusOnPress: true property bool showSettings: false onClicked: { showSettings = !showSettings; settingsTab.visible = showSettings; exportTab.visible = !showSettings; - text = (showSettings ? qsTr("View logs...") : qsTr("Log settings...")); + text = (showSettings ? qsTr("Logs...") : qsTr("Settings...")); } } Rectangle { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index d3b36029a..3c87d624c 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -51,6 +51,8 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan QQuickView *view = new QQuickView(); view->rootContext()->setContextProperty("dialog", this); view->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus()); + view->rootContext()->setContextProperty("logControl", flightLogManager->flightLogControl()); + view->rootContext()->setContextProperty("logSettings", flightLogManager->flightLogSettings()); view->rootContext()->setContextProperty("logManager", flightLogManager); view->setResizeMode(QQuickView::SizeRootObjectToView); view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml")); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index a8ff55a83..0823f4f94 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -65,11 +65,14 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); Q_ASSERT(m_flightLogEntry); + m_flightLogSettings = DebugLogSettings::GetInstance(m_objectManager); + Q_ASSERT(m_flightLogSettings); + updateFlightEntries(m_flightLogStatus->getFlight()); setupUAVOWrappers(); - setupLogSettings(); + setupLogStatuses(); } FlightLogManager::~FlightLogManager() @@ -409,6 +412,11 @@ void FlightLogManager::setupLogSettings() << tr("Every 500ms") << tr("Every second") << tr("Every 5s") << tr("Every 10s") << tr("Every 30s") << tr("Every minute"); } +void FlightLogManager::setupLogStatuses() +{ + m_logStatuses << tr("Never") << tr("Only when Armed") << tr("Always"); +} + void FlightLogManager::connectionStatusChanged() { if (m_telemtryManager->isConnected()) { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index b31271dc4..9589341d8 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -38,6 +38,7 @@ #include "uavobjectmanager.h" #include "debuglogentry.h" #include "debuglogstatus.h" +#include "debuglogsettings.h" #include "debuglogcontrol.h" #include "uavtalk/telemetrymanager.h" @@ -116,6 +117,8 @@ private: class FlightLogManager : public QObject { Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) + Q_PROPERTY(DebugLogControl *flightLogControl READ flightLogControl) + Q_PROPERTY(DebugLogSettings *flightLogSettings READ flightLogSettings) Q_PROPERTY(QQmlListProperty logEntries READ logEntries NOTIFY logEntriesChanged) Q_PROPERTY(QStringList flightEntries READ flightEntries NOTIFY flightEntriesChanged) Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged) @@ -125,6 +128,7 @@ class FlightLogManager : public QObject { Q_PROPERTY(QQmlListProperty uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged) Q_PROPERTY(QStringList logSettings READ logSettings NOTIFY logSettingsChanged) + Q_PROPERTY(QStringList logStatuses READ logStatuses NOTIFY logStatusesChanged) public: @@ -167,6 +171,21 @@ public: return m_boardConnected; } + QStringList logStatuses() const + { + return m_logStatuses; + } + + DebugLogControl * flightLogControl() const + { + return m_flightLogControl; + } + + DebugLogSettings * flightLogSettings() const + { + return m_flightLogSettings; + } + signals: void logEntriesChanged(); void flightEntriesChanged(); @@ -177,6 +196,8 @@ signals: void adjustExportedTimestampsChanged(bool arg); void boardConnectedChanged(bool arg); + void logStatusesChanged(QStringList arg); + public slots: void clearAllLogs(); void retrieveLogs(int flightToRetrieve = -1); @@ -219,6 +240,7 @@ private slots: void updateFlightEntries(quint16 currentFlight); void setupUAVOWrappers(); void setupLogSettings(); + void setupLogStatuses(); void connectionStatusChanged(); private: @@ -227,10 +249,12 @@ private: DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; DebugLogEntry *m_flightLogEntry; + DebugLogSettings * m_flightLogSettings; QList m_logEntries; QStringList m_flightEntries; QStringList m_logSettings; + QStringList m_logStatuses; QList m_uavoEntries; @@ -244,7 +268,6 @@ private: bool m_cancelDownload; bool m_adjustExportedTimestamps; bool m_boardConnected; - }; #endif // FLIGHTLOGMANAGER_H