From 01e06c81921ceeb6cd297dd888bd834ef504c5f7 Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Sat, 28 Mar 2020 10:11:23 +0200 Subject: [PATCH] Actually emit the signal changes --- src/battery.cpp | 10 +++++----- src/battery.h | 8 ++++---- src/settings.cpp | 14 +++++++------- src/settings.h | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/battery.cpp b/src/battery.cpp index 81f20a6..7e26c42 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -105,7 +105,7 @@ void Battery::updateData() nextCharge = chargeFile->readLine().trimmed().toInt(); if(nextCharge != charge) { charge = nextCharge; - emit chargeChanged(); + emit chargeChanged(charge); qDebug() << "Battery:" << charge; } chargeFile->close(); @@ -114,7 +114,7 @@ void Battery::updateData() nextChargerConnected = chargerConnectedFile->readLine().trimmed().toInt(); if(nextChargerConnected != chargerConnected) { chargerConnected = nextChargerConnected; - emit chargerConnectedChanged(); + emit chargerConnectedChanged(chargerConnected); qDebug() << "Charger is connected:" << chargerConnected; } chargerConnectedFile->close(); @@ -123,7 +123,7 @@ void Battery::updateData() nextState = (QString(stateFile->readLine().trimmed().toLower())); if(nextState != state) { state = nextState; - emit stateChanged(); + emit stateChanged(state); qDebug() << "Charging status:" << state; } stateFile->close(); @@ -135,7 +135,7 @@ void Battery::updateData() // nextChargingEnabled = chargingEnabledFile->readLine().trimmed().toInt() == enableChargingValue; // if(nextChargingEnabled != chargingEnabled) { // chargingEnabled = nextChargingEnabled; - // emit chargingEnabledChanged(); + // emit chargingEnabledChanged(chargingEnabled); // } // chargingEnabledFile->close(); // } @@ -160,7 +160,7 @@ void Battery::setChargingEnabled(bool isEnabled) { if(chargingEnabledFile && chargingEnabledFile->open(QIODevice::WriteOnly)) { if(chargingEnabledFile->write(QString("%1").arg(isEnabled ? enableChargingValue : disableChargingValue).toLatin1())) { chargingEnabled = isEnabled; - emit chargingEnabledChanged(); + emit chargingEnabledChanged(chargingEnabled); if(isEnabled) { qInfo() << "Charging resumed"; diff --git a/src/battery.h b/src/battery.h index c676d59..d8981ae 100644 --- a/src/battery.h +++ b/src/battery.h @@ -72,10 +72,10 @@ private: bool nextChargingEnabled = chargingEnabled; signals: - int chargeChanged(); - QString stateChanged(); - bool chargingEnabledChanged(); - bool chargerConnectedChanged(); + void chargeChanged(int); + void stateChanged(QString); + void chargingEnabledChanged(bool); + void chargerConnectedChanged(bool); }; #endif // BATTERY_H diff --git a/src/settings.cpp b/src/settings.cpp index 9cd90fa..d3f2c49 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -94,43 +94,43 @@ QString Settings::getHighAlertFile() { void Settings::setLowAlert(int newLimit) { lowAlert = newLimit; - emit lowAlertChanged(); + emit lowAlertChanged(lowAlert); qDebug() << "Change" << sLowAlert << newLimit; } void Settings::setHighAlert(int newLimit) { highAlert = newLimit; - emit highAlertChanged(); + emit highAlertChanged(highAlert); qDebug() << "Change" << sHighAlert << newLimit; } void Settings::setInterval(int newInterval) { interval = newInterval; - emit intervalChanged(); + emit intervalChanged(interval); qDebug() << "Change" << sInterval << newInterval; } void Settings::setLowLimit(int newLimit) { lowLimit = newLimit; - emit lowLimitChanged(); + emit lowLimitChanged(lowLimit); qDebug() << "Change" << sLowLimit << newLimit; } void Settings::setHighLimit(int newLimit) { highLimit = newLimit; - emit highLimitChanged(); + emit highLimitChanged(highLimit); qDebug() << "Change" << sHighLimit << newLimit; } void Settings::setLimitEnabled(bool newEnabled) { limitEnabled = (newEnabled ? 1 : 0); - emit limitEnabledChanged(); + emit limitEnabledChanged(limitEnabled); qDebug() << "Change" << sLimitEnabled << newEnabled; } void Settings::setNotificationsEnabled(bool newEnabled) { notificationsEnabled = (newEnabled ? 1 : 0); - emit notificationsEnabledChanged(); + emit notificationsEnabledChanged(notificationsEnabled); qDebug() << "Change" << sNotificationsEnabled << newEnabled; } diff --git a/src/settings.h b/src/settings.h index d490d1b..59c788f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -88,15 +88,15 @@ private: void saveInteger(const char *key, int *value); signals: - int lowAlertChanged(); - int highAlertChanged(); - int intervalChanged(); - bool limitEnabledChanged(); - bool notificationsEnabledChanged(); - int lowLimitChanged(); - int highLimitChanged(); - QString lowAlertFileChanged(); - QString highAlertFileChanged(); + void lowAlertChanged(int); + void highAlertChanged(int); + void intervalChanged(int); + void limitEnabledChanged(bool); + void notificationsEnabledChanged(bool); + void lowLimitChanged(int); + void highLimitChanged(int); + void lowAlertFileChanged(QString); + void highAlertFileChanged(QString); }; #endif // SETTINGS_H