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.
This commit is contained in:
parent
d72ebc4cf7
commit
3147067fbf
5 changed files with 15 additions and 6 deletions
|
@ -20,10 +20,11 @@
|
||||||
|
|
||||||
#include "batterydbusinterface.h"
|
#include "batterydbusinterface.h"
|
||||||
|
|
||||||
|
#include <core/device.h>
|
||||||
#include <core/kdebugnamespace.h>
|
#include <core/kdebugnamespace.h>
|
||||||
|
|
||||||
BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
|
BatteryDbusInterface::BatteryDbusInterface(const Device *device)
|
||||||
: QDBusAbstractAdaptor(parent)
|
: QDBusAbstractAdaptor(const_cast<Device*>(device))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include <QDBusAbstractAdaptor>
|
#include <QDBusAbstractAdaptor>
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
class BatteryDbusInterface
|
class BatteryDbusInterface
|
||||||
: public QDBusAbstractAdaptor
|
: public QDBusAbstractAdaptor
|
||||||
{
|
{
|
||||||
|
@ -30,7 +32,7 @@ class BatteryDbusInterface
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery")
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BatteryDbusInterface(QObject *parent);
|
explicit BatteryDbusInterface(const Device *device);
|
||||||
virtual ~BatteryDbusInterface();
|
virtual ~BatteryDbusInterface();
|
||||||
|
|
||||||
Q_SCRIPTABLE int charge() const { return mCharge; }
|
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)
|
BatteryPlugin::BatteryPlugin(QObject *parent, const QVariantList &args)
|
||||||
: KdeConnectPlugin(parent, args)
|
: KdeConnectPlugin(parent, args)
|
||||||
, batteryDbusInterface(new BatteryDbusInterface(parent))
|
, batteryDbusInterface(new BatteryDbusInterface(device()))
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Add battery reporting, could be based on:
|
//TODO: Add battery reporting, could be based on:
|
||||||
|
|
|
@ -26,18 +26,22 @@
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
#include <KMD5>
|
#include <KMD5>
|
||||||
|
|
||||||
|
#include <core/device.h>
|
||||||
|
#include <core/kdeconnectplugin.h>
|
||||||
#include <core/kdebugnamespace.h>
|
#include <core/kdebugnamespace.h>
|
||||||
#include <core/filetransferjob.h>
|
#include <core/filetransferjob.h>
|
||||||
|
|
||||||
#include "notificationsplugin.h"
|
#include "notificationsplugin.h"
|
||||||
|
|
||||||
NotificationsDbusInterface::NotificationsDbusInterface(KdeConnectPlugin* plugin)
|
NotificationsDbusInterface::NotificationsDbusInterface(KdeConnectPlugin* plugin)
|
||||||
: QDBusAbstractAdaptor(plugin)
|
: QDBusAbstractAdaptor(const_cast<Device*>(plugin->device()))
|
||||||
, mDevice(plugin->device())
|
, mDevice(plugin->device())
|
||||||
, mPlugin(plugin)
|
, mPlugin(plugin)
|
||||||
, mLastId(0)
|
, mLastId(0)
|
||||||
, imagesDir(QDir::temp().absoluteFilePath("kdeconnect"))
|
, imagesDir(QDir::temp().absoluteFilePath("kdeconnect"))
|
||||||
{
|
{
|
||||||
imagesDir.mkpath(imagesDir.absolutePath());
|
imagesDir.mkpath(imagesDir.absolutePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationsDbusInterface::~NotificationsDbusInterface()
|
NotificationsDbusInterface::~NotificationsDbusInterface()
|
||||||
|
|
|
@ -27,9 +27,11 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
#include <core/device.h>
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
|
||||||
|
class KdeConnectPlugin;
|
||||||
|
class Device;
|
||||||
|
|
||||||
class NotificationsDbusInterface
|
class NotificationsDbusInterface
|
||||||
: public QDBusAbstractAdaptor
|
: public QDBusAbstractAdaptor
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue