plugins: Prefer using statements with baseclass over empty constructor

Those plugins re really simple and don't need any initialization logic.
With the using statement, we do not need to add a constructor and pass the parent/args to the baseclass
This commit is contained in:
Alexander Lohnau 2023-07-28 10:36:48 +02:00
parent 867c4ab6fc
commit 6530274f75
24 changed files with 12 additions and 80 deletions

View file

@ -20,11 +20,6 @@ K_PLUGIN_CLASS_WITH_JSON(BigscreenPlugin, "kdeconnect_bigscreen.json")
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BIGSCREEN, "kdeconnect.plugin.bigscreen") Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BIGSCREEN, "kdeconnect.plugin.bigscreen")
BigscreenPlugin::BigscreenPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool BigscreenPlugin::receivePacket(const NetworkPacket &np) bool BigscreenPlugin::receivePacket(const NetworkPacket &np)
{ {
QString message = np.get<QString>(QStringLiteral("content")); QString message = np.get<QString>(QStringLiteral("content"));

View file

@ -17,8 +17,7 @@ class BigscreenPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.bigscreen") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.bigscreen")
public: public:
explicit BigscreenPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;
QString dbusPath() const override; QString dbusPath() const override;

View file

@ -15,11 +15,6 @@
K_PLUGIN_CLASS_WITH_JSON(ConnectivityReportPlugin, "kdeconnect_connectivity_report.json") K_PLUGIN_CLASS_WITH_JSON(ConnectivityReportPlugin, "kdeconnect_connectivity_report.json")
ConnectivityReportPlugin::ConnectivityReportPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
QString ConnectivityReportPlugin::cellularNetworkType() const QString ConnectivityReportPlugin::cellularNetworkType() const
{ {
return m_cellularNetworkType; return m_cellularNetworkType;

View file

@ -39,7 +39,7 @@ class ConnectivityReportPlugin : public KdeConnectPlugin
Q_PROPERTY(int cellularNetworkStrength READ cellularNetworkStrength NOTIFY refreshed) Q_PROPERTY(int cellularNetworkStrength READ cellularNetworkStrength NOTIFY refreshed)
public: public:
explicit ConnectivityReportPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;
QString dbusPath() const override; QString dbusPath() const override;

View file

@ -14,11 +14,6 @@
K_PLUGIN_CLASS_WITH_JSON(FindMyPhonePlugin, "kdeconnect_findmyphone.json") K_PLUGIN_CLASS_WITH_JSON(FindMyPhonePlugin, "kdeconnect_findmyphone.json")
FindMyPhonePlugin::FindMyPhonePlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool FindMyPhonePlugin::receivePacket(const NetworkPacket & /*np*/) bool FindMyPhonePlugin::receivePacket(const NetworkPacket & /*np*/)
{ {
return false; return false;

View file

@ -18,7 +18,7 @@ class FindMyPhonePlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findmyphone") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findmyphone")
public: public:
explicit FindMyPhonePlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
Q_SCRIPTABLE void ring(); Q_SCRIPTABLE void ring();

View file

@ -26,11 +26,6 @@
K_PLUGIN_CLASS_WITH_JSON(FindThisDevicePlugin, "kdeconnect_findthisdevice.json") K_PLUGIN_CLASS_WITH_JSON(FindThisDevicePlugin, "kdeconnect_findthisdevice.json")
FindThisDevicePlugin::FindThisDevicePlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/) bool FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
{ {
const QString soundFile = config()->getString(QStringLiteral("ringtone"), defaultSound()); const QString soundFile = config()->getString(QStringLiteral("ringtone"), defaultSound());

View file

@ -27,7 +27,7 @@ class FindThisDevicePlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findthisdevice") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findthisdevice")
public: public:
explicit FindThisDevicePlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
QString dbusPath() const override; QString dbusPath() const override;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;

View file

@ -16,11 +16,6 @@
K_PLUGIN_CLASS_WITH_JSON(MprisRemotePlugin, "kdeconnect_mprisremote.json") K_PLUGIN_CLASS_WITH_JSON(MprisRemotePlugin, "kdeconnect_mprisremote.json")
MprisRemotePlugin::MprisRemotePlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool MprisRemotePlugin::receivePacket(const NetworkPacket &np) bool MprisRemotePlugin::receivePacket(const NetworkPacket &np)
{ {
if (np.type() != PACKET_TYPE_MPRIS) if (np.type() != PACKET_TYPE_MPRIS)

View file

@ -31,7 +31,7 @@ class MprisRemotePlugin : public KdeConnectPlugin
Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged) Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged)
public: public:
explicit MprisRemotePlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
long position() const; long position() const;
int volume() const; int volume() const;

View file

@ -22,11 +22,6 @@
K_PLUGIN_CLASS_WITH_JSON(NotificationsPlugin, "kdeconnect_notifications.json") K_PLUGIN_CLASS_WITH_JSON(NotificationsPlugin, "kdeconnect_notifications.json")
NotificationsPlugin::NotificationsPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
void NotificationsPlugin::connected() void NotificationsPlugin::connected()
{ {
NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST, {{QStringLiteral("request"), true}}); NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST, {{QStringLiteral("request"), true}});

View file

@ -20,7 +20,7 @@ class NotificationsPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications")
public: public:
explicit NotificationsPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;
void connected() override; void connected() override;

View file

@ -15,11 +15,6 @@
K_PLUGIN_CLASS_WITH_JSON(PhotoPlugin, "kdeconnect_photo.json") K_PLUGIN_CLASS_WITH_JSON(PhotoPlugin, "kdeconnect_photo.json")
PhotoPlugin::PhotoPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool PhotoPlugin::receivePacket(const NetworkPacket &np) bool PhotoPlugin::receivePacket(const NetworkPacket &np)
{ {
if (np.get<bool>(QStringLiteral("cancel"))) { if (np.get<bool>(QStringLiteral("cancel"))) {

View file

@ -19,7 +19,7 @@ class PhotoPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.photo") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.photo")
public: public:
explicit PhotoPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
Q_SCRIPTABLE void requestPhoto(const QString &url); Q_SCRIPTABLE void requestPhoto(const QString &url);

View file

@ -19,17 +19,6 @@
K_PLUGIN_CLASS_WITH_JSON(PingPlugin, "kdeconnect_ping.json") K_PLUGIN_CLASS_WITH_JSON(PingPlugin, "kdeconnect_ping.json")
PingPlugin::PingPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
// qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin constructor for device" << device()->name();
}
PingPlugin::~PingPlugin()
{
// qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name();
}
bool PingPlugin::receivePacket(const NetworkPacket &np) bool PingPlugin::receivePacket(const NetworkPacket &np)
{ {
Daemon::instance()->sendSimpleNotification(QStringLiteral("pingReceived"), Daemon::instance()->sendSimpleNotification(QStringLiteral("pingReceived"),

View file

@ -18,8 +18,7 @@ class PingPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.ping") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.ping")
public: public:
explicit PingPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
~PingPlugin() override;
Q_SCRIPTABLE void sendPing(); Q_SCRIPTABLE void sendPing();
Q_SCRIPTABLE void sendPing(const QString &customMessage); Q_SCRIPTABLE void sendPing(const QString &customMessage);

View file

@ -18,11 +18,6 @@
K_PLUGIN_CLASS_WITH_JSON(RemoteControlPlugin, "kdeconnect_remotecontrol.json") K_PLUGIN_CLASS_WITH_JSON(RemoteControlPlugin, "kdeconnect_remotecontrol.json")
RemoteControlPlugin::RemoteControlPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
void RemoteControlPlugin::moveCursor(const QPoint &p) void RemoteControlPlugin::moveCursor(const QPoint &p)
{ {
NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, {{QStringLiteral("dx"), p.x()}, {QStringLiteral("dy"), p.y()}}); NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, {{QStringLiteral("dx"), p.x()}, {QStringLiteral("dy"), p.y()}});

View file

@ -18,7 +18,7 @@ class RemoteControlPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotecontrol") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotecontrol")
public: public:
explicit RemoteControlPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket & /*np*/) override bool receivePacket(const NetworkPacket & /*np*/) override
{ {

View file

@ -21,11 +21,6 @@
K_PLUGIN_CLASS_WITH_JSON(RemoteSystemVolumePlugin, "kdeconnect_remotesystemvolume.json") K_PLUGIN_CLASS_WITH_JSON(RemoteSystemVolumePlugin, "kdeconnect_remotesystemvolume.json")
RemoteSystemVolumePlugin::RemoteSystemVolumePlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
bool RemoteSystemVolumePlugin::receivePacket(const NetworkPacket &np) bool RemoteSystemVolumePlugin::receivePacket(const NetworkPacket &np)
{ {
if (np.has(QStringLiteral("sinkList"))) { if (np.has(QStringLiteral("sinkList"))) {

View file

@ -21,7 +21,7 @@ class RemoteSystemVolumePlugin : public KdeConnectPlugin
Q_PROPERTY(QString deviceId READ deviceId CONSTANT) Q_PROPERTY(QString deviceId READ deviceId CONSTANT)
public: public:
explicit RemoteSystemVolumePlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;
void connected() override; void connected() override;

View file

@ -17,11 +17,6 @@
K_PLUGIN_CLASS_WITH_JSON(TelephonyPlugin, "kdeconnect_telephony.json") K_PLUGIN_CLASS_WITH_JSON(TelephonyPlugin, "kdeconnect_telephony.json")
TelephonyPlugin::TelephonyPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
void TelephonyPlugin::createNotification(const NetworkPacket &np) void TelephonyPlugin::createNotification(const NetworkPacket &np)
{ {
const QString event = np.get<QString>(QStringLiteral("event")); const QString event = np.get<QString>(QStringLiteral("event"));

View file

@ -35,7 +35,7 @@ class TelephonyPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony")
public: public:
explicit TelephonyPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
bool receivePacket(const NetworkPacket &np) override; bool receivePacket(const NetworkPacket &np) override;
QString dbusPath() const override; QString dbusPath() const override;

View file

@ -19,11 +19,6 @@
K_PLUGIN_CLASS_WITH_JSON(VirtualMonitorPlugin, "kdeconnect_virtualmonitor.json") K_PLUGIN_CLASS_WITH_JSON(VirtualMonitorPlugin, "kdeconnect_virtualmonitor.json")
#define QS QLatin1String #define QS QLatin1String
VirtualMonitorPlugin::VirtualMonitorPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
VirtualMonitorPlugin::~VirtualMonitorPlugin() VirtualMonitorPlugin::~VirtualMonitorPlugin()
{ {
stop(); stop();

View file

@ -21,7 +21,7 @@ class VirtualMonitorPlugin : public KdeConnectPlugin
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.virtualmonitor") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.virtualmonitor")
public: public:
explicit VirtualMonitorPlugin(QObject *parent, const QVariantList &args); using KdeConnectPlugin::KdeConnectPlugin;
~VirtualMonitorPlugin() override; ~VirtualMonitorPlugin() override;
Q_SCRIPTABLE bool requestVirtualMonitor(); Q_SCRIPTABLE bool requestVirtualMonitor();