diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-28 12:35:47 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-28 15:41:14 +0100 |
commit | c212210e41487e88f62d5f8f51c57e63b534c38f (patch) | |
tree | 5b2f3e60ab1e676dedfa6dabc66d413bad5b704c /daemon | |
parent | 10693b321cc3cbeedb9262dc17282e86d9a13767 (diff) |
Fix up the settings implementation
add interval and enabled settings for all sensors
get rid of some bad duplicates
make sure that application properties are set up before settings are accessed
Diffstat (limited to '')
-rw-r--r-- | daemon/logger.cpp | 13 | ||||
-rw-r--r-- | daemon/logger.h | 7 | ||||
-rw-r--r-- | daemon/sensorlogd.cpp | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/daemon/logger.cpp b/daemon/logger.cpp index 93f764f..ff62ff6 100644 --- a/daemon/logger.cpp +++ b/daemon/logger.cpp @@ -27,16 +27,19 @@ Logger::Logger(QObject *parent) : QObject(parent){ m_iface = new QDBusInterface("com.nokia.mce","/com/nokia/mce/signal", "com.nokia.mce.signal", QDBusConnection::systemBus()); - QSettings settings; + settings = new QSettings; + + heartrateSensorEnabled = this->settings->value("heartrateSensor/enabled",true).toBool(); + stepCounterEnabled = this->settings->value("stepCounter/enabled",true).toBool(); //intialise HRM - if (heartrateSensorEnabled) { //add check for HRM - m_heartrateSensor = new HeartrateSensorPlugin(this,settings.value("stepsInterval",600000).toInt()); + if (heartrateSensorEnabled) { + m_heartrateSensor = new HeartrateSensorPlugin(this,settings->value("heartrateSensor/interval",600000).toInt()); } //initialise step counter - if (stepCounterEnabled) { //add check for step sensor - m_stepCounter = new StepCounterPlugin(this,settings.value("stepsInterval",600000).toInt()); + if (stepCounterEnabled) { + m_stepCounter = new StepCounterPlugin(this,settings->value("stepCounter/interval",600000).toInt()); } if(!m_iface->isValid()) { diff --git a/daemon/logger.h b/daemon/logger.h index 14d097f..d9b418d 100644 --- a/daemon/logger.h +++ b/daemon/logger.h @@ -17,6 +17,7 @@ #include <QDBusInterface> #include <QTimer> #include <QString> +#include <QSettings> #include "sensorPlugins/stepCounter.h" #include "sensorPlugins/heartrateSensor.h" @@ -27,16 +28,16 @@ class Logger : public QObject public: explicit Logger(QObject *parent = 0); virtual ~Logger() {}; - private slots: void displayOn(QString displayState); private: QDBusInterface *m_iface; - bool heartrateSensorEnabled = true; + bool heartrateSensorEnabled = false; HeartrateSensorPlugin *m_heartrateSensor; - bool stepCounterEnabled = true; + bool stepCounterEnabled = false; StepCounterPlugin *m_stepCounter; + QSettings *settings; }; void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime = QDateTime::currentDateTime()); //adds a record to today's log file for the given sensor diff --git a/daemon/sensorlogd.cpp b/daemon/sensorlogd.cpp index 8b7395a..095ebd9 100644 --- a/daemon/sensorlogd.cpp +++ b/daemon/sensorlogd.cpp @@ -24,10 +24,10 @@ int main(int argc, char **argv) fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"); return 2; } - Logger sensorsLogger; QCoreApplication::setOrganizationName("asteroid"); QCoreApplication::setOrganizationDomain("asteroidos.org"); QCoreApplication::setApplicationName("healthd"); + Logger sensorsLogger; qDebug() << "healthd started"; qcoreapp.exec(); return 0; |