Use KPluginMetaData::pluginId for getting config plugin name

By removing the postfix we consistently use, we get exactly the same string as before

However, all our pluginId logic is now done as part of the buildsystem.
Before, they were in the JSON metadata, the buildsystem and the string constructor parameter

KPluginFactory has the KPluginMetaData object in any case, do using it
doesn't create any overhead.
This commit is contained in:
Alexander Lohnau 2023-07-21 13:26:19 +03:00 committed by Albert Vaca Cintora
parent e894f7c000
commit ede9e37b40
14 changed files with 24 additions and 24 deletions

View file

@ -6,16 +6,13 @@
#include "kdeconnectpluginkcm.h" #include "kdeconnectpluginkcm.h"
#include <KAboutData>
#include <KService>
struct KdeConnectPluginKcmPrivate { struct KdeConnectPluginKcmPrivate {
QString m_deviceId; QString m_deviceId;
QString m_pluginName; QString m_pluginName;
KdeConnectPluginConfig *m_config = nullptr; KdeConnectPluginConfig *m_config = nullptr;
}; };
KdeConnectPluginKcm::KdeConnectPluginKcm(QObject *parent, const QVariantList &args, const QString &pluginName) KdeConnectPluginKcm::KdeConnectPluginKcm(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
#if QT_VERSION_MAJOR < 6 #if QT_VERSION_MAJOR < 6
: KCModule(qobject_cast<QWidget *>(parent), args) : KCModule(qobject_cast<QWidget *>(parent), args)
#else #else
@ -23,8 +20,10 @@ KdeConnectPluginKcm::KdeConnectPluginKcm(QObject *parent, const QVariantList &ar
#endif #endif
, d(new KdeConnectPluginKcmPrivate()) , d(new KdeConnectPluginKcmPrivate())
{ {
Q_ASSERT(data.isValid()); // Even if we have empty metadata, it should be valid!
d->m_deviceId = args.at(0).toString(); d->m_deviceId = args.at(0).toString();
d->m_pluginName = pluginName; const static QRegularExpression removeConfigPostfix(QStringLiteral("_config$"));
d->m_pluginName = data.pluginId().remove(removeConfigPostfix);
// The parent of the config should be the plugin itself // The parent of the config should be the plugin itself
d->m_config = new KdeConnectPluginConfig(d->m_deviceId, d->m_pluginName); d->m_config = new KdeConnectPluginConfig(d->m_deviceId, d->m_pluginName);

View file

@ -8,6 +8,7 @@
#define KDECONNECTPLUGINKCM_H #define KDECONNECTPLUGINKCM_H
#include <KCModule> #include <KCModule>
#include <KPluginMetaData> // Not in KCModule header of older KF5 versions
#include <kconfigwidgets_version.h> #include <kconfigwidgets_version.h>
#include "core/kdeconnectpluginconfig.h" #include "core/kdeconnectpluginconfig.h"
@ -24,7 +25,7 @@ class KDECONNECTPLUGINKCM_EXPORT KdeConnectPluginKcm : public KCModule
Q_OBJECT Q_OBJECT
public: public:
KdeConnectPluginKcm(QObject *parent, const QVariantList &args, const QString &componentName); KdeConnectPluginKcm(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~KdeConnectPluginKcm() override; ~KdeConnectPluginKcm() override;
/** /**

View file

@ -11,8 +11,8 @@
K_PLUGIN_FACTORY(ClipboardConfigFactory, registerPlugin<ClipboardConfig>();) K_PLUGIN_FACTORY(ClipboardConfigFactory, registerPlugin<ClipboardConfig>();)
ClipboardConfig::ClipboardConfig(QObject *parent, const QVariantList &args) ClipboardConfig::ClipboardConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_clipboard")) : KdeConnectPluginKcm(parent, data, args)
, m_ui(new Ui::ClipboardConfigUi()) , m_ui(new Ui::ClipboardConfigUi())
{ {
m_ui->setupUi(widget()); m_ui->setupUi(widget());

View file

@ -18,7 +18,7 @@ class ClipboardConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
ClipboardConfig(QObject *parent, const QVariantList &); ClipboardConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
~ClipboardConfig() override; ~ClipboardConfig() override;
void save() override; void save() override;

View file

@ -21,8 +21,8 @@
K_PLUGIN_FACTORY(FindThisDeviceConfigFactory, registerPlugin<FindThisDeviceConfig>();) K_PLUGIN_FACTORY(FindThisDeviceConfigFactory, registerPlugin<FindThisDeviceConfig>();)
FindThisDeviceConfig::FindThisDeviceConfig(QObject *parent, const QVariantList &args) FindThisDeviceConfig::FindThisDeviceConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_findthisdevice")) : KdeConnectPluginKcm(parent, data, args)
, m_ui(new Ui::FindThisDeviceConfigUi()) , m_ui(new Ui::FindThisDeviceConfigUi())
{ {
m_ui->setupUi(widget()); m_ui->setupUi(widget());

View file

@ -18,7 +18,7 @@ class FindThisDeviceConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
FindThisDeviceConfig(QObject *parent, const QVariantList &); FindThisDeviceConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
~FindThisDeviceConfig() override; ~FindThisDeviceConfig() override;
void save() override; void save() override;

View file

@ -11,8 +11,8 @@
K_PLUGIN_FACTORY(PauseMusicConfigFactory, registerPlugin<PauseMusicConfig>();) K_PLUGIN_FACTORY(PauseMusicConfigFactory, registerPlugin<PauseMusicConfig>();)
PauseMusicConfig::PauseMusicConfig(QObject *parent, const QVariantList &args) PauseMusicConfig::PauseMusicConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_pausemusic")) : KdeConnectPluginKcm(parent, data, args)
, m_ui(new Ui::PauseMusicConfigUi()) , m_ui(new Ui::PauseMusicConfigUi())
{ {
m_ui->setupUi(widget()); m_ui->setupUi(widget());

View file

@ -18,7 +18,7 @@ class PauseMusicConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
PauseMusicConfig(QObject *parent, const QVariantList &); PauseMusicConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
~PauseMusicConfig() override; ~PauseMusicConfig() override;
void save() override; void save() override;

View file

@ -26,8 +26,8 @@
K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<RunCommandConfig>();) K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<RunCommandConfig>();)
RunCommandConfig::RunCommandConfig(QObject *parent, const QVariantList &args) RunCommandConfig::RunCommandConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_runcommand")) : KdeConnectPluginKcm(parent, data, args)
{ {
// The qdbus executable name is different on some systems // The qdbus executable name is different on some systems
QString qdbusExe = QStringLiteral("qdbus-qt5"); QString qdbusExe = QStringLiteral("qdbus-qt5");

View file

@ -16,7 +16,7 @@ class RunCommandConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
RunCommandConfig(QObject *parent, const QVariantList &); RunCommandConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
void save() override; void save() override;
void load() override; void load() override;

View file

@ -13,8 +13,8 @@
K_PLUGIN_FACTORY(SendNotificationsConfigFactory, registerPlugin<SendNotificationsConfig>();) K_PLUGIN_FACTORY(SendNotificationsConfigFactory, registerPlugin<SendNotificationsConfig>();)
SendNotificationsConfig::SendNotificationsConfig(QObject *parent, const QVariantList &args) SendNotificationsConfig::SendNotificationsConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_sendnotifications")) : KdeConnectPluginKcm(parent, data, args)
, m_ui(new Ui::SendNotificationsConfigUi()) , m_ui(new Ui::SendNotificationsConfigUi())
, appModel(new NotifyingApplicationModel) , appModel(new NotifyingApplicationModel)
{ {

View file

@ -20,7 +20,7 @@ class SendNotificationsConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
SendNotificationsConfig(QObject *parent, const QVariantList &); SendNotificationsConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
~SendNotificationsConfig() override; ~SendNotificationsConfig() override;
void save() override; void save() override;

View file

@ -14,8 +14,8 @@
K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<ShareConfig>();) K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<ShareConfig>();)
ShareConfig::ShareConfig(QObject *parent, const QVariantList &args) ShareConfig::ShareConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_share")) : KdeConnectPluginKcm(parent, data, args)
, m_ui(new Ui::ShareConfigUi()) , m_ui(new Ui::ShareConfigUi())
{ {
m_ui->setupUi(widget()); m_ui->setupUi(widget());

View file

@ -18,7 +18,7 @@ class ShareConfig : public KdeConnectPluginKcm
{ {
Q_OBJECT Q_OBJECT
public: public:
ShareConfig(QObject *parent, const QVariantList &); ShareConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~ShareConfig() override; ~ShareConfig() override;
void save() override; void save() override;