diff options
author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-08-22 12:03:08 +0100 |
---|---|---|
committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-08-22 12:03:08 +0100 |
commit | d912a0aed3c62b8f615c37fd9406583b9f0a6a36 (patch) | |
tree | 226dc94cb084203dd3c303e1ffc8983cb83bd73c | |
parent | 72cd124bc6a71d7be3bf9e6602c9de55156508ee (diff) | |
download | qmenumodel-d912a0aed3c62b8f615c37fd9406583b9f0a6a36.tar.gz qmenumodel-d912a0aed3c62b8f615c37fd9406583b9f0a6a36.tar.bz2 qmenumodel-d912a0aed3c62b8f615c37fd9406583b9f0a6a36.zip |
Added activate/changeState to UnityMenuModel
-rw-r--r-- | libqmenumodel/src/unitymenuaction.h | 3 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.cpp | 26 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.h | 2 |
3 files changed, 31 insertions, 0 deletions
diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h index e6cc4d9..7c19fc5 100644 --- a/libqmenumodel/src/unitymenuaction.h +++ b/libqmenumodel/src/unitymenuaction.h @@ -53,6 +53,9 @@ public Q_SLOTS: void onStateChanged(const QVariant &state); Q_SIGNALS: + Q_INVOKABLE void activate(const QVariant& parameter = QVariant()); + Q_INVOKABLE void changeState(const QVariant& parameter); + void nameChanged(const QString& name); void modelChanged(UnityMenuModel* model); void stateChanged(const QVariant& name); diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 920761c..953af01 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -727,6 +727,8 @@ void UnityMenuModel::registerAction(UnityMenuAction* action) priv->registeredActions[action] = observer_item; connect(action, SIGNAL(nameChanged(const QString&)), SLOT(onRegisteredActionNameChanged(const QString&))); + connect(action, SIGNAL(activate(const QVariant&)), SLOT(onRegisteredActionActivated(const QVariant&))); + connect(action, SIGNAL(changeState(const QVariant&)), SLOT(onRegisteredActionStateChanged(const QVariant&))); } } @@ -770,6 +772,30 @@ void UnityMenuModel::onRegisteredActionNameChanged(const QString& name) } } +void UnityMenuModel::onRegisteredActionActivated(const QVariant& parameter) +{ + UnityMenuAction* action = qobject_cast<UnityMenuAction*>(sender()); + if (!action || action->name().isEmpty()) + return; + + QByteArray nameArray = action->name().toUtf8(); + const gchar* action_name = nameArray.constData(); + + g_action_group_activate_action (G_ACTION_GROUP (priv->muxer), action_name, Converter::toGVariant(parameter)); +} + +void UnityMenuModel::onRegisteredActionStateChanged(const QVariant& parameter) +{ + UnityMenuAction* action = qobject_cast<UnityMenuAction*>(sender()); + if (!action || action->name().isEmpty()) + return; + + QByteArray nameArray = action->name().toUtf8(); + const gchar* action_name = nameArray.constData(); + + g_action_group_change_action_state (G_ACTION_GROUP (priv->muxer), action_name, Converter::toGVariant(parameter)); +} + void UnityMenuModelPrivate::registeredActionAdded(GtkActionObserverItem *observer_item, const gchar *action_name, gboolean enabled, diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h index 21a4c3c..0c18121 100644 --- a/libqmenumodel/src/unitymenumodel.h +++ b/libqmenumodel/src/unitymenumodel.h @@ -73,6 +73,8 @@ Q_SIGNALS: protected Q_SLOTS: void onRegisteredActionNameChanged(const QString& name); + void onRegisteredActionActivated(const QVariant& parameter); + void onRegisteredActionStateChanged(const QVariant& parameter); protected: |