diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-29 16:30:31 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-29 18:06:51 +0100 |
commit | fd718937e22c22e716a951e2bb58ac1bc624f70e (patch) | |
tree | 88b7ebd962c1224dbfb4daacf578084a79fd17cc /qmlplugin | |
parent | 66e8fe3ba76cf72a71a8fece1532fb9597813e0a (diff) |
Add a method for daemon recordings to be triggered from qml
This allows the app to always show an up-to-date value
Diffstat (limited to '')
-rw-r--r-- | qmlplugin/stepsDataLoader.cpp | 12 | ||||
-rw-r--r-- | qmlplugin/stepsDataLoader.h | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/qmlplugin/stepsDataLoader.cpp b/qmlplugin/stepsDataLoader.cpp index 0c084ea..199b324 100644 --- a/qmlplugin/stepsDataLoader.cpp +++ b/qmlplugin/stepsDataLoader.cpp @@ -14,11 +14,18 @@ #include <QDate> #include <QSettings> #include <QStandardPaths> +#include <QDBusInterface> #include "stepsDataLoader.h" StepsDataLoader::StepsDataLoader() : QObject() { + m_iface = new QDBusInterface("org.asteroid.sensorlogd.logger","/org/asteroid/sensorlogd/logger","", QDBusConnection::sessionBus(), this); + if (!m_iface->isValid()) { + qDebug()<<"interface is not valid"; + } else { + qDebug()<<"interface is valid"; + } } int StepsDataLoader::getTodayData() { @@ -45,6 +52,11 @@ int StepsDataLoader::getDataForDate(QDate date) { // This is obvious garbage. Th return line.split(":")[1].toInt(); } +void StepsDataLoader::triggerDaemonRecording() { + m_iface->call("triggerRecording"); +} + + QString fileNameForDate(QDate date, QString prefix) { QSettings settings("asteroid","sensorlogd"); //this should be moved out of here at some point TODO return settings.value("loggerRootPath",QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.asteroid-sensorlogd/").toString() + prefix + "/" + date.toString("yyyy-MM-dd.log"); diff --git a/qmlplugin/stepsDataLoader.h b/qmlplugin/stepsDataLoader.h index 4937ee9..869b434 100644 --- a/qmlplugin/stepsDataLoader.h +++ b/qmlplugin/stepsDataLoader.h @@ -12,6 +12,7 @@ #define STEPSDATALOADER_H #include <QObject> +#include <QDBusInterface> class StepsDataLoader : public QObject { @@ -21,6 +22,9 @@ public: explicit StepsDataLoader(); Q_INVOKABLE int getDataForDate(QDate date); Q_INVOKABLE int getTodayData(); + Q_INVOKABLE void triggerDaemonRecording(); +private: + QDBusInterface *m_iface; }; QString fileNameForDate(QDate date, QString prefix); |