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:
parent
e894f7c000
commit
ede9e37b40
14 changed files with 24 additions and 24 deletions
|
@ -6,16 +6,13 @@
|
|||
|
||||
#include "kdeconnectpluginkcm.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KService>
|
||||
|
||||
struct KdeConnectPluginKcmPrivate {
|
||||
QString m_deviceId;
|
||||
QString m_pluginName;
|
||||
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
|
||||
: KCModule(qobject_cast<QWidget *>(parent), args)
|
||||
#else
|
||||
|
@ -23,8 +20,10 @@ KdeConnectPluginKcm::KdeConnectPluginKcm(QObject *parent, const QVariantList &ar
|
|||
#endif
|
||||
, 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_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
|
||||
d->m_config = new KdeConnectPluginConfig(d->m_deviceId, d->m_pluginName);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define KDECONNECTPLUGINKCM_H
|
||||
|
||||
#include <KCModule>
|
||||
#include <KPluginMetaData> // Not in KCModule header of older KF5 versions
|
||||
#include <kconfigwidgets_version.h>
|
||||
|
||||
#include "core/kdeconnectpluginconfig.h"
|
||||
|
@ -24,7 +25,7 @@ class KDECONNECTPLUGINKCM_EXPORT KdeConnectPluginKcm : public KCModule
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KdeConnectPluginKcm(QObject *parent, const QVariantList &args, const QString &componentName);
|
||||
KdeConnectPluginKcm(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
||||
~KdeConnectPluginKcm() override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(ClipboardConfigFactory, registerPlugin<ClipboardConfig>();)
|
||||
|
||||
ClipboardConfig::ClipboardConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_clipboard"))
|
||||
ClipboardConfig::ClipboardConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
, m_ui(new Ui::ClipboardConfigUi())
|
||||
{
|
||||
m_ui->setupUi(widget());
|
||||
|
|
|
@ -18,7 +18,7 @@ class ClipboardConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClipboardConfig(QObject *parent, const QVariantList &);
|
||||
ClipboardConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
|
||||
~ClipboardConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(FindThisDeviceConfigFactory, registerPlugin<FindThisDeviceConfig>();)
|
||||
|
||||
FindThisDeviceConfig::FindThisDeviceConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_findthisdevice"))
|
||||
FindThisDeviceConfig::FindThisDeviceConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
, m_ui(new Ui::FindThisDeviceConfigUi())
|
||||
{
|
||||
m_ui->setupUi(widget());
|
||||
|
|
|
@ -18,7 +18,7 @@ class FindThisDeviceConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FindThisDeviceConfig(QObject *parent, const QVariantList &);
|
||||
FindThisDeviceConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
|
||||
~FindThisDeviceConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(PauseMusicConfigFactory, registerPlugin<PauseMusicConfig>();)
|
||||
|
||||
PauseMusicConfig::PauseMusicConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_pausemusic"))
|
||||
PauseMusicConfig::PauseMusicConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
, m_ui(new Ui::PauseMusicConfigUi())
|
||||
{
|
||||
m_ui->setupUi(widget());
|
||||
|
|
|
@ -18,7 +18,7 @@ class PauseMusicConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PauseMusicConfig(QObject *parent, const QVariantList &);
|
||||
PauseMusicConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
|
||||
~PauseMusicConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<RunCommandConfig>();)
|
||||
|
||||
RunCommandConfig::RunCommandConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_runcommand"))
|
||||
RunCommandConfig::RunCommandConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
{
|
||||
// The qdbus executable name is different on some systems
|
||||
QString qdbusExe = QStringLiteral("qdbus-qt5");
|
||||
|
|
|
@ -16,7 +16,7 @@ class RunCommandConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RunCommandConfig(QObject *parent, const QVariantList &);
|
||||
RunCommandConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
|
||||
|
||||
void save() override;
|
||||
void load() override;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(SendNotificationsConfigFactory, registerPlugin<SendNotificationsConfig>();)
|
||||
|
||||
SendNotificationsConfig::SendNotificationsConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_sendnotifications"))
|
||||
SendNotificationsConfig::SendNotificationsConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
, m_ui(new Ui::SendNotificationsConfigUi())
|
||||
, appModel(new NotifyingApplicationModel)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class SendNotificationsConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SendNotificationsConfig(QObject *parent, const QVariantList &);
|
||||
SendNotificationsConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &);
|
||||
~SendNotificationsConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
K_PLUGIN_FACTORY(ShareConfigFactory, registerPlugin<ShareConfig>();)
|
||||
|
||||
ShareConfig::ShareConfig(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_share"))
|
||||
ShareConfig::ShareConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
||||
: KdeConnectPluginKcm(parent, data, args)
|
||||
, m_ui(new Ui::ShareConfigUi())
|
||||
{
|
||||
m_ui->setupUi(widget());
|
||||
|
|
|
@ -18,7 +18,7 @@ class ShareConfig : public KdeConnectPluginKcm
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShareConfig(QObject *parent, const QVariantList &);
|
||||
ShareConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
||||
~ShareConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
|
Loading…
Reference in a new issue