Commit 3147067f authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Fixed notifications not being appearing in the model nor in the plasmoid

The parent of the QDbusAdaptor has to be a Device, and now it was a
KdeConnectPlugin for the Notifications plugin.

Instead of passing the parent (that is actually a Device) to the
QDbusAdaptor as we were doing in the Battery plugin, I preferred to get the
actual Device from the KdeConnectPlugin, even though it needs a const_cast.
parent d72ebc4c
......@@ -20,10 +20,11 @@
#include "batterydbusinterface.h"
#include <core/device.h>
#include <core/kdebugnamespace.h>
BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
: QDBusAbstractAdaptor(parent)
BatteryDbusInterface::BatteryDbusInterface(const Device *device)
: QDBusAbstractAdaptor(const_cast<Device*>(device))
{
}
......
......@@ -23,6 +23,8 @@
#include <QDBusAbstractAdaptor>
class Device;
class BatteryDbusInterface
: public QDBusAbstractAdaptor
{
......@@ -30,7 +32,7 @@ class BatteryDbusInterface
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery")
public:
explicit BatteryDbusInterface(QObject *parent);
explicit BatteryDbusInterface(const Device *device);
virtual ~BatteryDbusInterface();
Q_SCRIPTABLE int charge() const { return mCharge; }
......
......@@ -32,7 +32,7 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_battery", "kdeconnect-plugi
BatteryPlugin::BatteryPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
, batteryDbusInterface(new BatteryDbusInterface(parent))
, batteryDbusInterface(new BatteryDbusInterface(device()))
{
//TODO: Add battery reporting, could be based on:
......
......@@ -26,18 +26,22 @@
#include <KIcon>
#include <KMD5>
#include <core/device.h>
#include <core/kdeconnectplugin.h>
#include <core/kdebugnamespace.h>
#include <core/filetransferjob.h>
#include "notificationsplugin.h"
NotificationsDbusInterface::NotificationsDbusInterface(KdeConnectPlugin* plugin)
: QDBusAbstractAdaptor(plugin)
: QDBusAbstractAdaptor(const_cast<Device*>(plugin->device()))
, mDevice(plugin->device())
, mPlugin(plugin)
, mLastId(0)
, imagesDir(QDir::temp().absoluteFilePath("kdeconnect"))
{
imagesDir.mkpath(imagesDir.absolutePath());
}
NotificationsDbusInterface::~NotificationsDbusInterface()
......
......@@ -27,9 +27,11 @@
#include <QStringList>
#include <QDir>
#include <core/device.h>
#include "notification.h"
class KdeConnectPlugin;
class Device;
class NotificationsDbusInterface
: public QDBusAbstractAdaptor
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment