summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-09 18:50:23 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-09 18:50:23 +0200
commitbc5b70046e84c6e5a33a19bd2e64e626fdf0579e (patch)
tree49452d6add3626d527b19298acd1587de167350b /libsowatch
parentc7c6a2c596637fd4942c7fb80341ca2ef7b47808 (diff)
downloadsowatch-bc5b70046e84c6e5a33a19bd2e64e626fdf0579e.tar.gz
sowatch-bc5b70046e84c6e5a33a19bd2e64e626fdf0579e.zip
first UI editable settings!
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/configkey.h7
-rw-r--r--libsowatch/declarativewatchlet.cpp3
-rw-r--r--libsowatch/gconfkey.cpp10
-rw-r--r--libsowatch/gconfkey.h3
-rw-r--r--libsowatch/watchplugininterface.h1
5 files changed, 22 insertions, 2 deletions
diff --git a/libsowatch/configkey.h b/libsowatch/configkey.h
index ef7665e..a30ae67 100644
--- a/libsowatch/configkey.h
+++ b/libsowatch/configkey.h
@@ -12,7 +12,7 @@ namespace sowatch
class SOWATCH_EXPORT ConfigKey : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString key READ key CONSTANT)
+ Q_PROPERTY(QString key READ key WRITE setKey NOTIFY keyChanged)
Q_PROPERTY(QVariant value READ value WRITE set RESET unset NOTIFY changed USER true)
Q_PROPERTY(QStringList dirs READ dirs)
Q_PROPERTY(QStringList keys READ keys)
@@ -21,6 +21,7 @@ public:
ConfigKey(QObject *parent = 0);
virtual QString key() const = 0;
+ virtual void setKey(const QString& key) = 0;
virtual QVariant value() const = 0;
virtual void set(const QVariant& value) = 0;
@@ -43,7 +44,11 @@ public:
virtual ConfigKey* getSubkey(const QString& subkey, QObject *parent = 0) const = 0;
signals:
+ /** Key property changed (via setKey) */
+ void keyChanged();
+ /** Value changed. */
void changed();
+ /** A value of a subkey changed. */
void subkeyChanged(const QString& subkey);
};
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp
index 275af2a..68d6c28 100644
--- a/libsowatch/declarativewatchlet.cpp
+++ b/libsowatch/declarativewatchlet.cpp
@@ -1,6 +1,7 @@
#include <QtCore/QDebug>
#include <QtDeclarative/QtDeclarative>
#include "watchserver.h"
+#include "gconfkey.h"
#include "declarativewatchwrapper.h"
#include "declarativewatchlet.h"
@@ -20,6 +21,8 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id)
if (!_registered) {
qmlRegisterUncreatableType<DeclarativeWatchWrapper>("com.javispedro.sowatch", 1, 0,
"Watch", "Watch is only available via the 'watch' object");
+ qmlRegisterType<ConfigKey>();
+ qmlRegisterType<GConfKey>("com.javispedro.sowatch", 1, 0, "GConfKey");
_registered = true;
}
diff --git a/libsowatch/gconfkey.cpp b/libsowatch/gconfkey.cpp
index c6becc4..da6aeff 100644
--- a/libsowatch/gconfkey.cpp
+++ b/libsowatch/gconfkey.cpp
@@ -141,6 +141,16 @@ QString GConfKey::key() const
return _key;
}
+void GConfKey::setKey(const QString &key)
+{
+ _key = key;
+ if (_key.endsWith("/")) {
+ _key.chop(1);
+ }
+ emit keyChanged();
+ emit changed();
+}
+
QVariant GConfKey::value() const
{
return value(QString());
diff --git a/libsowatch/gconfkey.h b/libsowatch/gconfkey.h
index c9074ea..d2bf088 100644
--- a/libsowatch/gconfkey.h
+++ b/libsowatch/gconfkey.h
@@ -11,10 +11,11 @@ class SOWATCH_EXPORT GConfKey : public ConfigKey
Q_OBJECT
public:
- GConfKey(const QString& key, QObject *parent = 0);
+ GConfKey(const QString& key = QString(), QObject *parent = 0);
~GConfKey();
QString key() const;
+ void setKey(const QString &key);
QVariant value() const;
void set(const QVariant& value);
diff --git a/libsowatch/watchplugininterface.h b/libsowatch/watchplugininterface.h
index 804f7f5..0ab2c4b 100644
--- a/libsowatch/watchplugininterface.h
+++ b/libsowatch/watchplugininterface.h
@@ -20,6 +20,7 @@ public:
virtual QStringList drivers() = 0;
virtual WatchScanner* getScanner(QObject *parent = 0) = 0;
+ virtual QUrl getConfigQmlUrl(const QString& driver) = 0;
virtual Watch* getWatch(const QString& driver, ConfigKey* settings, QObject *parent = 0) = 0;
};