aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r--libqmenumodel/src/unitymenuaction.h2
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp28
-rw-r--r--libqmenumodel/src/unitymenumodel.h1
3 files changed, 27 insertions, 4 deletions
diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h
index ef844fd..bcbb50d 100644
--- a/libqmenumodel/src/unitymenuaction.h
+++ b/libqmenumodel/src/unitymenuaction.h
@@ -46,7 +46,7 @@ public:
virtual QVariant state() const = 0;
- Q_INVOKABLE virtual void activate() = 0;
+ Q_INVOKABLE virtual void activate(const QVariant &parameter) = 0;
Q_INVOKABLE virtual void changeState(const QVariant& vvalue) = 0;
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index b1c9a6a..631a3c2 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -40,7 +40,9 @@ enum MenuRoles {
IconRole,
TypeRole,
ExtendedAttributesRole,
- ActionRole
+ ActionRole,
+ IsCheckRole,
+ IsRadioRole
};
class UnityMenuModelPrivate
@@ -104,14 +106,18 @@ public:
return d->itemState(item);
}
- virtual void activate()
+ virtual void activate(const QVariant &parameter)
{
GtkMenuTrackerItem* item;
+ gchar *action;
item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index()));
if (!item) return;
- gtk_menu_tracker_item_activated (item);
+ gtk_menu_tracker_item_get_attribute (item, "action", "s", &action);
+ g_action_group_activate_action (G_ACTION_GROUP (d->muxer), action, Converter::toGVariant(parameter));
+
+ g_free (action);
}
virtual void changeState(const QVariant& vvalue)
@@ -468,6 +474,12 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
case ActionRole:
return QVariant::fromValue(new UnityGtkMenuTrackerItemAction(index.row(), priv));
+ case IsCheckRole:
+ return gtk_menu_tracker_item_get_role (item) == GTK_MENU_TRACKER_ITEM_ROLE_CHECK;
+
+ case IsRadioRole:
+ return gtk_menu_tracker_item_get_role (item) == GTK_MENU_TRACKER_ITEM_ROLE_RADIO;
+
default:
return QVariant();
}
@@ -495,6 +507,8 @@ QHash<int, QByteArray> UnityMenuModel::roleNames() const
names[TypeRole] = "type";
names[ExtendedAttributesRole] = "ext";
names[ActionRole] = "action";
+ names[IsCheckRole] = "isCheck";
+ names[IsRadioRole] = "isRadio";
return names;
}
@@ -639,3 +653,11 @@ QVariant UnityMenuModel::get(int row, const QByteArray &role)
return this->data(this->index(row, 0), priv->roles[role]);
}
+
+void UnityMenuModel::activate(int index)
+{
+ GtkMenuTrackerItem *item;
+
+ item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (priv->items, index));
+ gtk_menu_tracker_item_activated (item);
+}
diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h
index 5401331..79dbaa9 100644
--- a/libqmenumodel/src/unitymenumodel.h
+++ b/libqmenumodel/src/unitymenumodel.h
@@ -57,6 +57,7 @@ public:
Q_INVOKABLE QObject * submenu(int position, QQmlComponent* actionStateParser = NULL);
Q_INVOKABLE bool loadExtendedAttributes(int position, const QVariantMap &schema);
Q_INVOKABLE QVariant get(int row, const QByteArray &role);
+ Q_INVOKABLE void activate(int index);
Q_SIGNALS:
void busNameChanged(const QByteArray &name);