Changeset View
Changeset View
Standalone View
Standalone View
plugins/battery/batteryplugin.cpp
Show All 15 Lines | |||||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "batteryplugin.h" | 21 | #include "batteryplugin.h" | ||
22 | 22 | | |||
23 | #include <QIcon> | 23 | #include <QIcon> | ||
24 | | ||||
24 | #include <KLocalizedString> | 25 | #include <KLocalizedString> | ||
25 | #include <KPluginFactory> | 26 | #include <KPluginFactory> | ||
26 | 27 | | |||
27 | #include <core/daemon.h> | 28 | #include <core/daemon.h> | ||
28 | 29 | | |||
29 | #include "batterydbusinterface.h" | 30 | #include "batterydbusinterface.h" | ||
30 | 31 | | |||
31 | K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_battery.json", registerPlugin< BatteryPlugin >(); ) | 32 | K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_battery.json", registerPlugin< BatteryPlugin >(); ) | ||
Show All 35 Lines | 64 | { | |||
67 | 68 | | |||
68 | if (batteryDbusInterface->charge() != currentCharge | 69 | if (batteryDbusInterface->charge() != currentCharge | ||
69 | || batteryDbusInterface->isCharging() != isCharging | 70 | || batteryDbusInterface->isCharging() != isCharging | ||
70 | ) { | 71 | ) { | ||
71 | batteryDbusInterface->updateValues(isCharging, currentCharge); | 72 | batteryDbusInterface->updateValues(isCharging, currentCharge); | ||
72 | } | 73 | } | ||
73 | 74 | | |||
74 | if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) { | 75 | if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) { | ||
75 | Daemon::instance()->sendSimpleNotification(QStringLiteral("batteryLow"), i18nc("device name: low battery", "%1: Low Battery", device()->name()), i18n("Battery at %1%", currentCharge), QStringLiteral("battery-040")); | 76 | Daemon::instance()->sendSimpleNotification(QStringLiteral("batteryLow"), i18nc("device name: low battery", "%1: Low Battery", device()->name()), i18n("Battery at %1%", currentCharge), QStringLiteral("battery-040")); | ||
apol: Could we use something like Daemon::reportError to abstract such notifications?
Something… | |||||
76 | | ||||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | return true; | 79 | return true; | ||
80 | 80 | | |||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | #include "batteryplugin.moc" | 83 | #include "batteryplugin.moc" |
Could we use something like Daemon::reportError to abstract such notifications?
Something like`Daemon::instance()->sendNotification(notificationName, icon, title, text)` could also be used in other places.
Another thing to consider is to adapt knotifications to work on sailfish would be great (solving this problem elsewhere too). Or maybe considering using snorenotify. Another possibility would be to have a proxy for xdg notifications for sailfish.