Return success writing new charger state

This commit is contained in:
Matti Viljanen 2020-06-12 14:26:00 +03:00
parent 87e72bed0b
commit 0cb9551c3a
No known key found for this signature in database
GPG key ID: CF32A1495158F888

View file

@ -174,12 +174,14 @@ QString Battery::getState() { return state; }
bool Battery::getChargingEnabled() { return chargingEnabled; }
void Battery::setChargingEnabled(bool isEnabled) {
bool Battery::setChargingEnabled(bool isEnabled) {
bool success = false;
if(chargingEnabledFile) {
if(chargingEnabledFile->open(QIODevice::WriteOnly)) {
if(chargingEnabledFile->write(QString("%1").arg(isEnabled ? enableChargingValue : disableChargingValue).toLatin1())) {
chargingEnabled = isEnabled;
emit chargingEnabledChanged(chargingEnabled);
success = true;
if(isEnabled) {
qInfo() << "Charging resumed";
@ -197,6 +199,7 @@ void Battery::setChargingEnabled(bool isEnabled) {
qWarning() << "Could not open charger control file";
}
}
return success;
}
bool Battery::getChargerConnected() {