void Battery::setChargePercent(int charge) { if (m_chargePercent != charge) { m_chargePercent = charge; emit chargePercentChanged(); } }
Battery::Battery(const QString &udi, QObject *parent) : QObject(parent) , m_device(Solid::Device(udi)) { // qCDebug(BATTERY) << "Added battery" << udi; m_battery = m_device.as<Solid::Battery>(); connect(m_battery, &Solid::Battery::chargePercentChanged, [this](int, const QString &) { Q_EMIT chargePercentChanged(); }); connect(m_battery, &Solid::Battery::capacityChanged, [this](int, const QString &) { Q_EMIT capacityChanged(); }); connect(m_battery, &Solid::Battery::powerSupplyStateChanged, [this](bool, const QString &) { Q_EMIT powerSupplyChanged(); }); connect(m_battery, &Solid::Battery::chargeStateChanged, [this](int, const QString &) { Q_EMIT chargeStateChanged(); }); connect(m_battery, &Solid::Battery::timeToEmptyChanged, [this](qlonglong, const QString &) { Q_EMIT timeToEmptyChanged(); }); connect(m_battery, &Solid::Battery::timeToFullChanged, [this](qlonglong, const QString &) { Q_EMIT timeToFullChanged(); }); connect(m_battery, &Solid::Battery::chargeStateChanged, [this](int, const QString &) { Q_EMIT chargeStateChanged(); }); connect(m_battery, &Solid::Battery::energyChanged, [this](double, const QString &) { Q_EMIT energyChanged(); }); connect(m_battery, &Solid::Battery::energyRateChanged, [this](double, const QString &) { Q_EMIT energyRateChanged(); }); connect(m_battery, &Solid::Battery::voltageChanged, [this](double, const QString &) { Q_EMIT voltageChanged(); }); connect(m_battery, &Solid::Battery::temperatureChanged, [this](double, const QString &) { Q_EMIT temperatureChanged(); }); }