Actually emit the signal changes

This commit is contained in:
Matti Viljanen 2020-03-28 10:11:23 +02:00
parent 3b93b28967
commit 01e06c8192
No known key found for this signature in database
GPG key ID: CF32A1495158F888
4 changed files with 25 additions and 25 deletions

View file

@ -105,7 +105,7 @@ void Battery::updateData()
nextCharge = chargeFile->readLine().trimmed().toInt(); nextCharge = chargeFile->readLine().trimmed().toInt();
if(nextCharge != charge) { if(nextCharge != charge) {
charge = nextCharge; charge = nextCharge;
emit chargeChanged(); emit chargeChanged(charge);
qDebug() << "Battery:" << charge; qDebug() << "Battery:" << charge;
} }
chargeFile->close(); chargeFile->close();
@ -114,7 +114,7 @@ void Battery::updateData()
nextChargerConnected = chargerConnectedFile->readLine().trimmed().toInt(); nextChargerConnected = chargerConnectedFile->readLine().trimmed().toInt();
if(nextChargerConnected != chargerConnected) { if(nextChargerConnected != chargerConnected) {
chargerConnected = nextChargerConnected; chargerConnected = nextChargerConnected;
emit chargerConnectedChanged(); emit chargerConnectedChanged(chargerConnected);
qDebug() << "Charger is connected:" << chargerConnected; qDebug() << "Charger is connected:" << chargerConnected;
} }
chargerConnectedFile->close(); chargerConnectedFile->close();
@ -123,7 +123,7 @@ void Battery::updateData()
nextState = (QString(stateFile->readLine().trimmed().toLower())); nextState = (QString(stateFile->readLine().trimmed().toLower()));
if(nextState != state) { if(nextState != state) {
state = nextState; state = nextState;
emit stateChanged(); emit stateChanged(state);
qDebug() << "Charging status:" << state; qDebug() << "Charging status:" << state;
} }
stateFile->close(); stateFile->close();
@ -135,7 +135,7 @@ void Battery::updateData()
// nextChargingEnabled = chargingEnabledFile->readLine().trimmed().toInt() == enableChargingValue; // nextChargingEnabled = chargingEnabledFile->readLine().trimmed().toInt() == enableChargingValue;
// if(nextChargingEnabled != chargingEnabled) { // if(nextChargingEnabled != chargingEnabled) {
// chargingEnabled = nextChargingEnabled; // chargingEnabled = nextChargingEnabled;
// emit chargingEnabledChanged(); // emit chargingEnabledChanged(chargingEnabled);
// } // }
// chargingEnabledFile->close(); // chargingEnabledFile->close();
// } // }
@ -160,7 +160,7 @@ void Battery::setChargingEnabled(bool isEnabled) {
if(chargingEnabledFile && chargingEnabledFile->open(QIODevice::WriteOnly)) { if(chargingEnabledFile && chargingEnabledFile->open(QIODevice::WriteOnly)) {
if(chargingEnabledFile->write(QString("%1").arg(isEnabled ? enableChargingValue : disableChargingValue).toLatin1())) { if(chargingEnabledFile->write(QString("%1").arg(isEnabled ? enableChargingValue : disableChargingValue).toLatin1())) {
chargingEnabled = isEnabled; chargingEnabled = isEnabled;
emit chargingEnabledChanged(); emit chargingEnabledChanged(chargingEnabled);
if(isEnabled) { if(isEnabled) {
qInfo() << "Charging resumed"; qInfo() << "Charging resumed";

View file

@ -72,10 +72,10 @@ private:
bool nextChargingEnabled = chargingEnabled; bool nextChargingEnabled = chargingEnabled;
signals: signals:
int chargeChanged(); void chargeChanged(int);
QString stateChanged(); void stateChanged(QString);
bool chargingEnabledChanged(); void chargingEnabledChanged(bool);
bool chargerConnectedChanged(); void chargerConnectedChanged(bool);
}; };
#endif // BATTERY_H #endif // BATTERY_H

View file

@ -94,43 +94,43 @@ QString Settings::getHighAlertFile() {
void Settings::setLowAlert(int newLimit) { void Settings::setLowAlert(int newLimit) {
lowAlert = newLimit; lowAlert = newLimit;
emit lowAlertChanged(); emit lowAlertChanged(lowAlert);
qDebug() << "Change" << sLowAlert << newLimit; qDebug() << "Change" << sLowAlert << newLimit;
} }
void Settings::setHighAlert(int newLimit) { void Settings::setHighAlert(int newLimit) {
highAlert = newLimit; highAlert = newLimit;
emit highAlertChanged(); emit highAlertChanged(highAlert);
qDebug() << "Change" << sHighAlert << newLimit; qDebug() << "Change" << sHighAlert << newLimit;
} }
void Settings::setInterval(int newInterval) { void Settings::setInterval(int newInterval) {
interval = newInterval; interval = newInterval;
emit intervalChanged(); emit intervalChanged(interval);
qDebug() << "Change" << sInterval << newInterval; qDebug() << "Change" << sInterval << newInterval;
} }
void Settings::setLowLimit(int newLimit) { void Settings::setLowLimit(int newLimit) {
lowLimit = newLimit; lowLimit = newLimit;
emit lowLimitChanged(); emit lowLimitChanged(lowLimit);
qDebug() << "Change" << sLowLimit << newLimit; qDebug() << "Change" << sLowLimit << newLimit;
} }
void Settings::setHighLimit(int newLimit) { void Settings::setHighLimit(int newLimit) {
highLimit = newLimit; highLimit = newLimit;
emit highLimitChanged(); emit highLimitChanged(highLimit);
qDebug() << "Change" << sHighLimit << newLimit; qDebug() << "Change" << sHighLimit << newLimit;
} }
void Settings::setLimitEnabled(bool newEnabled) { void Settings::setLimitEnabled(bool newEnabled) {
limitEnabled = (newEnabled ? 1 : 0); limitEnabled = (newEnabled ? 1 : 0);
emit limitEnabledChanged(); emit limitEnabledChanged(limitEnabled);
qDebug() << "Change" << sLimitEnabled << newEnabled; qDebug() << "Change" << sLimitEnabled << newEnabled;
} }
void Settings::setNotificationsEnabled(bool newEnabled) { void Settings::setNotificationsEnabled(bool newEnabled) {
notificationsEnabled = (newEnabled ? 1 : 0); notificationsEnabled = (newEnabled ? 1 : 0);
emit notificationsEnabledChanged(); emit notificationsEnabledChanged(notificationsEnabled);
qDebug() << "Change" << sNotificationsEnabled << newEnabled; qDebug() << "Change" << sNotificationsEnabled << newEnabled;
} }

View file

@ -88,15 +88,15 @@ private:
void saveInteger(const char *key, int *value); void saveInteger(const char *key, int *value);
signals: signals:
int lowAlertChanged(); void lowAlertChanged(int);
int highAlertChanged(); void highAlertChanged(int);
int intervalChanged(); void intervalChanged(int);
bool limitEnabledChanged(); void limitEnabledChanged(bool);
bool notificationsEnabledChanged(); void notificationsEnabledChanged(bool);
int lowLimitChanged(); void lowLimitChanged(int);
int highLimitChanged(); void highLimitChanged(int);
QString lowAlertFileChanged(); void lowAlertFileChanged(QString);
QString highAlertFileChanged(); void highAlertFileChanged(QString);
}; };
#endif // SETTINGS_H #endif // SETTINGS_H