From c5e7fdb5e453d49904580f8fba8ee722468594cd Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Fri, 28 Jul 2023 10:36:48 +0200 Subject: [PATCH] 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 --- plugins/bigscreen/bigscreenplugin.cpp | 5 ----- plugins/bigscreen/bigscreenplugin.h | 3 +-- .../connectivity-report/connectivity_reportplugin.cpp | 5 ----- .../connectivity-report/connectivity_reportplugin.h | 2 +- plugins/findmyphone/findmyphoneplugin.cpp | 5 ----- plugins/findmyphone/findmyphoneplugin.h | 2 +- plugins/findthisdevice/findthisdeviceplugin.cpp | 5 ----- plugins/findthisdevice/findthisdeviceplugin.h | 2 +- plugins/mprisremote/mprisremoteplugin.cpp | 5 ----- plugins/mprisremote/mprisremoteplugin.h | 2 +- plugins/notifications/notificationsplugin.cpp | 5 ----- plugins/notifications/notificationsplugin.h | 2 +- plugins/photo/photoplugin.cpp | 5 ----- plugins/photo/photoplugin.h | 2 +- plugins/ping/pingplugin.cpp | 11 ----------- plugins/ping/pingplugin.h | 3 +-- plugins/remotecontrol/remotecontrolplugin.cpp | 5 ----- plugins/remotecontrol/remotecontrolplugin.h | 2 +- .../remotesystemvolume/remotesystemvolumeplugin.cpp | 5 ----- plugins/remotesystemvolume/remotesystemvolumeplugin.h | 2 +- plugins/telephony/telephonyplugin.cpp | 5 ----- plugins/telephony/telephonyplugin.h | 2 +- plugins/virtualmonitor/virtualmonitorplugin.cpp | 5 ----- plugins/virtualmonitor/virtualmonitorplugin.h | 2 +- 24 files changed, 12 insertions(+), 80 deletions(-) diff --git a/plugins/bigscreen/bigscreenplugin.cpp b/plugins/bigscreen/bigscreenplugin.cpp index fe4ff2eed..e34dae5c4 100644 --- a/plugins/bigscreen/bigscreenplugin.cpp +++ b/plugins/bigscreen/bigscreenplugin.cpp @@ -20,11 +20,6 @@ K_PLUGIN_CLASS_WITH_JSON(BigscreenPlugin, "kdeconnect_bigscreen.json") Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BIGSCREEN, "kdeconnect.plugin.bigscreen") -BigscreenPlugin::BigscreenPlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void BigscreenPlugin::receivePacket(const NetworkPacket &np) { QString message = np.get(QStringLiteral("content")); diff --git a/plugins/bigscreen/bigscreenplugin.h b/plugins/bigscreen/bigscreenplugin.h index 79f676bfe..647a02da5 100644 --- a/plugins/bigscreen/bigscreenplugin.h +++ b/plugins/bigscreen/bigscreenplugin.h @@ -17,8 +17,7 @@ class BigscreenPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.bigscreen") public: - explicit BigscreenPlugin(QObject *parent, const QVariantList &args); - + using KdeConnectPlugin::KdeConnectPlugin; void receivePacket(const NetworkPacket &np) override; QString dbusPath() const override; diff --git a/plugins/connectivity-report/connectivity_reportplugin.cpp b/plugins/connectivity-report/connectivity_reportplugin.cpp index 5338aaf4b..efb6fd51d 100644 --- a/plugins/connectivity-report/connectivity_reportplugin.cpp +++ b/plugins/connectivity-report/connectivity_reportplugin.cpp @@ -15,11 +15,6 @@ K_PLUGIN_CLASS_WITH_JSON(ConnectivityReportPlugin, "kdeconnect_connectivity_report.json") -ConnectivityReportPlugin::ConnectivityReportPlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - QString ConnectivityReportPlugin::cellularNetworkType() const { return m_cellularNetworkType; diff --git a/plugins/connectivity-report/connectivity_reportplugin.h b/plugins/connectivity-report/connectivity_reportplugin.h index d1dfab728..29434e9e7 100644 --- a/plugins/connectivity-report/connectivity_reportplugin.h +++ b/plugins/connectivity-report/connectivity_reportplugin.h @@ -39,7 +39,7 @@ class ConnectivityReportPlugin : public KdeConnectPlugin Q_PROPERTY(int cellularNetworkStrength READ cellularNetworkStrength NOTIFY refreshed) public: - explicit ConnectivityReportPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; void receivePacket(const NetworkPacket &np) override; QString dbusPath() const override; diff --git a/plugins/findmyphone/findmyphoneplugin.cpp b/plugins/findmyphone/findmyphoneplugin.cpp index 0a4be89f2..f3e6aa936 100644 --- a/plugins/findmyphone/findmyphoneplugin.cpp +++ b/plugins/findmyphone/findmyphoneplugin.cpp @@ -14,11 +14,6 @@ K_PLUGIN_CLASS_WITH_JSON(FindMyPhonePlugin, "kdeconnect_findmyphone.json") -FindMyPhonePlugin::FindMyPhonePlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void FindMyPhonePlugin::ring() { NetworkPacket np(PACKET_TYPE_FINDMYPHONE_REQUEST); diff --git a/plugins/findmyphone/findmyphoneplugin.h b/plugins/findmyphone/findmyphoneplugin.h index 92eb6dd95..2384f322c 100644 --- a/plugins/findmyphone/findmyphoneplugin.h +++ b/plugins/findmyphone/findmyphoneplugin.h @@ -18,7 +18,7 @@ class FindMyPhonePlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findmyphone") public: - explicit FindMyPhonePlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; Q_SCRIPTABLE void ring(); diff --git a/plugins/findthisdevice/findthisdeviceplugin.cpp b/plugins/findthisdevice/findthisdeviceplugin.cpp index 1db46f828..dfc692414 100644 --- a/plugins/findthisdevice/findthisdeviceplugin.cpp +++ b/plugins/findthisdevice/findthisdeviceplugin.cpp @@ -26,11 +26,6 @@ K_PLUGIN_CLASS_WITH_JSON(FindThisDevicePlugin, "kdeconnect_findthisdevice.json") -FindThisDevicePlugin::FindThisDevicePlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/) { const QString soundFile = config()->getString(QStringLiteral("ringtone"), defaultSound()); diff --git a/plugins/findthisdevice/findthisdeviceplugin.h b/plugins/findthisdevice/findthisdeviceplugin.h index 83e0a10f1..34149ddff 100644 --- a/plugins/findthisdevice/findthisdeviceplugin.h +++ b/plugins/findthisdevice/findthisdeviceplugin.h @@ -27,7 +27,7 @@ class FindThisDevicePlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.findthisdevice") public: - explicit FindThisDevicePlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; QString dbusPath() const override; void receivePacket(const NetworkPacket &np) override; diff --git a/plugins/mprisremote/mprisremoteplugin.cpp b/plugins/mprisremote/mprisremoteplugin.cpp index 94105fed6..bc4a0ed7f 100644 --- a/plugins/mprisremote/mprisremoteplugin.cpp +++ b/plugins/mprisremote/mprisremoteplugin.cpp @@ -16,11 +16,6 @@ K_PLUGIN_CLASS_WITH_JSON(MprisRemotePlugin, "kdeconnect_mprisremote.json") -MprisRemotePlugin::MprisRemotePlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void MprisRemotePlugin::receivePacket(const NetworkPacket &np) { if (np.type() != PACKET_TYPE_MPRIS) diff --git a/plugins/mprisremote/mprisremoteplugin.h b/plugins/mprisremote/mprisremoteplugin.h index cb52f0f7a..29922f951 100644 --- a/plugins/mprisremote/mprisremoteplugin.h +++ b/plugins/mprisremote/mprisremoteplugin.h @@ -31,7 +31,7 @@ class MprisRemotePlugin : public KdeConnectPlugin Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged) public: - explicit MprisRemotePlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; long position() const; int volume() const; diff --git a/plugins/notifications/notificationsplugin.cpp b/plugins/notifications/notificationsplugin.cpp index 785be8c4b..ee427bc22 100644 --- a/plugins/notifications/notificationsplugin.cpp +++ b/plugins/notifications/notificationsplugin.cpp @@ -22,11 +22,6 @@ K_PLUGIN_CLASS_WITH_JSON(NotificationsPlugin, "kdeconnect_notifications.json") -NotificationsPlugin::NotificationsPlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void NotificationsPlugin::connected() { NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST, {{QStringLiteral("request"), true}}); diff --git a/plugins/notifications/notificationsplugin.h b/plugins/notifications/notificationsplugin.h index dd3a22401..02e814854 100644 --- a/plugins/notifications/notificationsplugin.h +++ b/plugins/notifications/notificationsplugin.h @@ -20,7 +20,7 @@ class NotificationsPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications") public: - explicit NotificationsPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; void receivePacket(const NetworkPacket &np) override; void connected() override; diff --git a/plugins/photo/photoplugin.cpp b/plugins/photo/photoplugin.cpp index 3bdcd2dc8..1a7a26aa8 100644 --- a/plugins/photo/photoplugin.cpp +++ b/plugins/photo/photoplugin.cpp @@ -15,11 +15,6 @@ K_PLUGIN_CLASS_WITH_JSON(PhotoPlugin, "kdeconnect_photo.json") -PhotoPlugin::PhotoPlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void PhotoPlugin::receivePacket(const NetworkPacket &np) { if (np.get(QStringLiteral("cancel"))) { diff --git a/plugins/photo/photoplugin.h b/plugins/photo/photoplugin.h index 591e7670a..bf1e31bb2 100644 --- a/plugins/photo/photoplugin.h +++ b/plugins/photo/photoplugin.h @@ -19,7 +19,7 @@ class PhotoPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.photo") public: - explicit PhotoPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; Q_SCRIPTABLE void requestPhoto(const QString &url); diff --git a/plugins/ping/pingplugin.cpp b/plugins/ping/pingplugin.cpp index 9b5616b28..b6d50ead4 100644 --- a/plugins/ping/pingplugin.cpp +++ b/plugins/ping/pingplugin.cpp @@ -19,17 +19,6 @@ 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(); -} - void PingPlugin::receivePacket(const NetworkPacket &np) { Daemon::instance()->sendSimpleNotification(QStringLiteral("pingReceived"), diff --git a/plugins/ping/pingplugin.h b/plugins/ping/pingplugin.h index b77bc9615..0f5522222 100644 --- a/plugins/ping/pingplugin.h +++ b/plugins/ping/pingplugin.h @@ -18,8 +18,7 @@ class PingPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.ping") public: - explicit PingPlugin(QObject *parent, const QVariantList &args); - ~PingPlugin() override; + using KdeConnectPlugin::KdeConnectPlugin; Q_SCRIPTABLE void sendPing(); Q_SCRIPTABLE void sendPing(const QString &customMessage); diff --git a/plugins/remotecontrol/remotecontrolplugin.cpp b/plugins/remotecontrol/remotecontrolplugin.cpp index b2d7b36b6..28418d2bd 100644 --- a/plugins/remotecontrol/remotecontrolplugin.cpp +++ b/plugins/remotecontrol/remotecontrolplugin.cpp @@ -18,11 +18,6 @@ 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) { NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, {{QStringLiteral("dx"), p.x()}, {QStringLiteral("dy"), p.y()}}); diff --git a/plugins/remotecontrol/remotecontrolplugin.h b/plugins/remotecontrol/remotecontrolplugin.h index ca50ada22..f45ec3dc1 100644 --- a/plugins/remotecontrol/remotecontrolplugin.h +++ b/plugins/remotecontrol/remotecontrolplugin.h @@ -18,7 +18,7 @@ class RemoteControlPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotecontrol") public: - explicit RemoteControlPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; QString dbusPath() const override; diff --git a/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp b/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp index fd1d9fa4b..69e994ae9 100644 --- a/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp +++ b/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp @@ -21,11 +21,6 @@ K_PLUGIN_CLASS_WITH_JSON(RemoteSystemVolumePlugin, "kdeconnect_remotesystemvolume.json") -RemoteSystemVolumePlugin::RemoteSystemVolumePlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - void RemoteSystemVolumePlugin::receivePacket(const NetworkPacket &np) { if (np.has(QStringLiteral("sinkList"))) { diff --git a/plugins/remotesystemvolume/remotesystemvolumeplugin.h b/plugins/remotesystemvolume/remotesystemvolumeplugin.h index a39618abb..dbc31c15d 100644 --- a/plugins/remotesystemvolume/remotesystemvolumeplugin.h +++ b/plugins/remotesystemvolume/remotesystemvolumeplugin.h @@ -21,7 +21,7 @@ class RemoteSystemVolumePlugin : public KdeConnectPlugin Q_PROPERTY(QString deviceId READ deviceId CONSTANT) public: - explicit RemoteSystemVolumePlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; void receivePacket(const NetworkPacket &np) override; void connected() override; diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp index e0b6d391b..c1094e783 100644 --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -17,11 +17,6 @@ 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) { const QString event = np.get(QStringLiteral("event")); diff --git a/plugins/telephony/telephonyplugin.h b/plugins/telephony/telephonyplugin.h index eb1789a2a..2b22ab9a1 100644 --- a/plugins/telephony/telephonyplugin.h +++ b/plugins/telephony/telephonyplugin.h @@ -35,7 +35,7 @@ class TelephonyPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony") public: - explicit TelephonyPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; void receivePacket(const NetworkPacket &np) override; QString dbusPath() const override; diff --git a/plugins/virtualmonitor/virtualmonitorplugin.cpp b/plugins/virtualmonitor/virtualmonitorplugin.cpp index f070f239b..9922be927 100644 --- a/plugins/virtualmonitor/virtualmonitorplugin.cpp +++ b/plugins/virtualmonitor/virtualmonitorplugin.cpp @@ -19,11 +19,6 @@ K_PLUGIN_CLASS_WITH_JSON(VirtualMonitorPlugin, "kdeconnect_virtualmonitor.json") #define QS QLatin1String -VirtualMonitorPlugin::VirtualMonitorPlugin(QObject *parent, const QVariantList &args) - : KdeConnectPlugin(parent, args) -{ -} - VirtualMonitorPlugin::~VirtualMonitorPlugin() { stop(); diff --git a/plugins/virtualmonitor/virtualmonitorplugin.h b/plugins/virtualmonitor/virtualmonitorplugin.h index d714d79d1..da47be79b 100644 --- a/plugins/virtualmonitor/virtualmonitorplugin.h +++ b/plugins/virtualmonitor/virtualmonitorplugin.h @@ -21,7 +21,7 @@ class VirtualMonitorPlugin : public KdeConnectPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.virtualmonitor") public: - explicit VirtualMonitorPlugin(QObject *parent, const QVariantList &args); + using KdeConnectPlugin::KdeConnectPlugin; ~VirtualMonitorPlugin() override; Q_SCRIPTABLE bool requestVirtualMonitor();