Added a signal so plugins know when we update the config
This commit is contained in:
parent
cfe0e60eb9
commit
4230f4fb44
2 changed files with 21 additions and 1 deletions
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include "kdeconnectconfig.h"
|
||||
|
||||
|
@ -29,6 +31,7 @@ struct KdeConnectPluginConfigPrivate
|
|||
{
|
||||
QDir mConfigDir;
|
||||
QSettings* mConfig;
|
||||
QDBusMessage signal;
|
||||
};
|
||||
|
||||
KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QString& pluginName)
|
||||
|
@ -38,6 +41,9 @@ KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QS
|
|||
QDir().mkpath(d->mConfigDir.path());
|
||||
|
||||
d->mConfig = new QSettings(d->mConfigDir.absoluteFilePath("config"), QSettings::IniFormat);
|
||||
|
||||
d->signal = QDBusMessage::createSignal("/kdeconnect/"+deviceId+"/"+pluginName, "org.kde.kdeconnect.config", "configChanged");
|
||||
QDBusConnection::sessionBus().connect("", "/kdeconnect/"+deviceId+"/"+pluginName, "org.kde.kdeconnect.config", "configChanged", this, SLOT(slotConfigChanged()));
|
||||
}
|
||||
|
||||
KdeConnectPluginConfig::~KdeConnectPluginConfig()
|
||||
|
@ -60,4 +66,10 @@ void KdeConnectPluginConfig::set(const QString& key, const QVariant& value)
|
|||
{
|
||||
d->mConfig->setValue(key, value);
|
||||
d->mConfig->sync();
|
||||
QDBusConnection::sessionBus().send(d->signal);
|
||||
}
|
||||
|
||||
void KdeConnectPluginConfig::slotConfigChanged()
|
||||
{
|
||||
Q_EMIT configChanged();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef KDECONNECTPLUGINCONFIG_H
|
||||
#define KDECONNECTPLUGINCONFIG_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
@ -30,8 +31,10 @@
|
|||
|
||||
struct KdeConnectPluginConfigPrivate;
|
||||
|
||||
class KDECONNECTCORE_EXPORT KdeConnectPluginConfig
|
||||
class KDECONNECTCORE_EXPORT KdeConnectPluginConfig : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KdeConnectPluginConfig(const QString& deviceId, const QString& pluginName);
|
||||
~KdeConnectPluginConfig();
|
||||
|
@ -59,6 +62,11 @@ public:
|
|||
return get(key, QVariant(defaultValue)).template value<T>(); //Important note: Awesome template syntax is awesome
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotConfigChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void configChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<KdeConnectPluginConfigPrivate> d;
|
||||
|
|
Loading…
Reference in a new issue