plugins/battery: add battery charge info to the update signal

This commit is contained in:
Jason Nader 2020-12-13 21:28:23 +09:00
parent 38afb807bf
commit b5ac96ce5b
No known key found for this signature in database
GPG key ID: EE220FCAA09AF23D
3 changed files with 3 additions and 3 deletions

View file

@ -88,7 +88,7 @@ public:
~BatteryDbusInterface() override; ~BatteryDbusInterface() override;
Q_SIGNALS: Q_SIGNALS:
void refreshedProxy(); void refreshedProxy(bool isCharging, int charge);
}; };
class KDECONNECTINTERFACES_EXPORT DeviceNotificationsDbusInterface class KDECONNECTINTERFACES_EXPORT DeviceNotificationsDbusInterface

View file

@ -123,7 +123,7 @@ bool BatteryPlugin::receivePacket(const NetworkPacket& np)
m_charge = np.get<int>(QStringLiteral("currentCharge"), -1); m_charge = np.get<int>(QStringLiteral("currentCharge"), -1);
const int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone); const int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone);
Q_EMIT refreshed(); Q_EMIT refreshed(m_isCharging, m_charge);
if (thresholdEvent == ThresholdBatteryLow && !m_isCharging) { if (thresholdEvent == ThresholdBatteryLow && !m_isCharging) {
Daemon::instance()->sendSimpleNotification(QStringLiteral("batteryLow"), i18nc("device name: low battery", "%1: Low Battery", device()->name()), i18n("Battery at %1%", m_charge), QStringLiteral("battery-040")); Daemon::instance()->sendSimpleNotification(QStringLiteral("batteryLow"), i18nc("device name: low battery", "%1: Low Battery", device()->name()), i18n("Battery at %1%", m_charge), QStringLiteral("battery-040"));

View file

@ -31,7 +31,7 @@ public:
bool isCharging() const; bool isCharging() const;
Q_SIGNALS: Q_SIGNALS:
Q_SCRIPTABLE void refreshed(); Q_SCRIPTABLE void refreshed(bool isCharging, int charge);
private: private:
void slotChargeChanged(); void slotChargeChanged();