aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorNick Dedekind <nick.dedekind@canonical.com>2015-01-08 13:55:44 +0000
committerCI Train Bot <${CITRAIN_USER}@canonical.com>2015-01-08 13:55:44 +0000
commit79ef5bc388db99c12963648abf3d96b7b8ce8a4f (patch)
treea90dd09c20f53f86b92a58acba876fee620d0569 /libqmenumodel
parentf3a203bbe1350c5c69d19c1d4d82f984ad23e28d (diff)
parent7dc65fdaebc16de9521ddabec184fafe2132a518 (diff)
downloadqmenumodel-79ef5bc388db99c12963648abf3d96b7b8ce8a4f.tar.gz
qmenumodel-79ef5bc388db99c12963648abf3d96b7b8ce8a4f.tar.bz2
qmenumodel-79ef5bc388db99c12963648abf3d96b7b8ce8a4f.zip
Add support for overriding QDBusActionGroup state parser Fixes: #1385331
Approved by: PS Jenkins bot, Albert Astals Cid
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/qdbusactiongroup.cpp25
-rw-r--r--libqmenumodel/src/qdbusactiongroup.h9
2 files changed, 32 insertions, 2 deletions
diff --git a/libqmenumodel/src/qdbusactiongroup.cpp b/libqmenumodel/src/qdbusactiongroup.cpp
index 0ef907a..b29ece0 100644
--- a/libqmenumodel/src/qdbusactiongroup.cpp
+++ b/libqmenumodel/src/qdbusactiongroup.cpp
@@ -17,6 +17,7 @@
* Renato Araujo Oliveira Filho <renato@canonical.com>
*/
+#include "actionstateparser.h"
#include "qdbusactiongroup.h"
#include "qstateaction.h"
#include "converter.h"
@@ -58,7 +59,8 @@ extern "C" {
QDBusActionGroup::QDBusActionGroup(QObject *parent)
:QObject(parent),
QDBusObject(this),
- m_actionGroup(NULL)
+ m_actionGroup(NULL),
+ m_actionStateParser(new ActionStateParser(this))
{
}
@@ -89,7 +91,13 @@ QVariant QDBusActionGroup::actionState(const QString &name)
{
QVariant result;
GVariant *state = g_action_group_get_action_state(m_actionGroup, name.toUtf8().data());
- result = Converter::toQVariant(state);
+
+ if (m_actionStateParser != NULL) {
+ result = m_actionStateParser->toQVariant(state);
+ } else {
+ result = Converter::toQVariant(state);
+ }
+
if (state) {
g_variant_unref(state);
}
@@ -190,6 +198,19 @@ void QDBusActionGroup::setActionGroup(GDBusActionGroup *ag)
}
}
+ActionStateParser* QDBusActionGroup::actionStateParser() const
+{
+ return m_actionStateParser;
+}
+
+void QDBusActionGroup::setActionStateParser(ActionStateParser* actionStateParser)
+{
+ if (m_actionStateParser != actionStateParser) {
+ m_actionStateParser = actionStateParser;
+ Q_EMIT actionStateParserChanged(actionStateParser);
+ }
+}
+
/*! \internal */
void QDBusActionGroup::clear()
{
diff --git a/libqmenumodel/src/qdbusactiongroup.h b/libqmenumodel/src/qdbusactiongroup.h
index f369a4e..afb12f2 100644
--- a/libqmenumodel/src/qdbusactiongroup.h
+++ b/libqmenumodel/src/qdbusactiongroup.h
@@ -26,6 +26,7 @@
#include <QVariant>
class QStateAction;
+class ActionStateParser;
typedef char gchar;
typedef void* gpointer;
@@ -40,6 +41,7 @@ class QDBusActionGroup : public QObject, public QDBusObject
Q_PROPERTY(QString busName READ busName WRITE setBusName NOTIFY busNameChanged)
Q_PROPERTY(QString objectPath READ objectPath WRITE setObjectPath NOTIFY objectPathChanged)
Q_PROPERTY(int status READ status NOTIFY statusChanged)
+ Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)
public:
QDBusActionGroup(QObject *parent=0);
@@ -52,6 +54,10 @@ public:
Q_INVOKABLE QStateAction *action(const QString &name);
Q_INVOKABLE QVariant actionState(const QString &name);
+ ActionStateParser* actionStateParser() const;
+ // Ownership of the actionStateParser is not passed to this object.
+ void setActionStateParser(ActionStateParser* actionStateParser);
+
Q_SIGNALS:
void busTypeChanged(DBusEnums::BusType type);
void busNameChanged(const QString &busNameChanged);
@@ -60,6 +66,7 @@ Q_SIGNALS:
void actionAppear(const QString &name);
void actionVanish(const QString &name);
void actionStateChanged(const QString &name, QVariant state);
+ void actionStateParserChanged(ActionStateParser* parser);
public Q_SLOTS:
void start();
@@ -77,6 +84,8 @@ private:
int m_signalActionRemovedId;
int m_signalStateChangedId;
+ ActionStateParser* m_actionStateParser;
+
// workaround to support int as busType
void setIntBusType(int busType);