aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/qdbusactiongroup.cpp13
-rw-r--r--libqmenumodel/src/qdbusactiongroup.h3
-rw-r--r--libqmenumodel/src/unitymenuaction.cpp2
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp14
4 files changed, 28 insertions, 4 deletions
diff --git a/libqmenumodel/src/qdbusactiongroup.cpp b/libqmenumodel/src/qdbusactiongroup.cpp
index b29ece0..76e28ed 100644
--- a/libqmenumodel/src/qdbusactiongroup.cpp
+++ b/libqmenumodel/src/qdbusactiongroup.cpp
@@ -70,6 +70,18 @@ QDBusActionGroup::~QDBusActionGroup()
clear();
}
+QStringList QDBusActionGroup::actions() const
+{
+ if (!m_actionGroup) return QStringList();
+ QStringList list;
+ gchar** actions = g_action_group_list_actions(m_actionGroup);
+ for (uint i = 0; actions[i]; i++) {
+ list << QString(actions[i]);
+ }
+ g_strfreev(actions);
+ return list;
+}
+
/*!
\qmlmethod QDBusActionGroup::action(QString name)
@@ -258,6 +270,7 @@ bool QDBusActionGroup::event(QEvent* e)
} else {
Q_EMIT actionVanish(dave->name);
}
+ Q_EMIT actionsChanged();
} else if (e->type() == DBusActionStateEvent::eventType) {
DBusActionStateEvent *dase = static_cast<DBusActionStateEvent*>(e);
diff --git a/libqmenumodel/src/qdbusactiongroup.h b/libqmenumodel/src/qdbusactiongroup.h
index afb12f2..d588b8e 100644
--- a/libqmenumodel/src/qdbusactiongroup.h
+++ b/libqmenumodel/src/qdbusactiongroup.h
@@ -42,11 +42,13 @@ class QDBusActionGroup : public QObject, public QDBusObject
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)
+ Q_PROPERTY(QStringList actions READ actions NOTIFY actionsChanged)
public:
QDBusActionGroup(QObject *parent=0);
~QDBusActionGroup();
+ QStringList actions() const;
void updateActionState(const QString &name, const QVariant &state);
void activateAction(const QString &name, const QVariant &parameter);
bool hasAction(const QString &name);
@@ -67,6 +69,7 @@ Q_SIGNALS:
void actionVanish(const QString &name);
void actionStateChanged(const QString &name, QVariant state);
void actionStateParserChanged(ActionStateParser* parser);
+ void actionsChanged();
public Q_SLOTS:
void start();
diff --git a/libqmenumodel/src/unitymenuaction.cpp b/libqmenumodel/src/unitymenuaction.cpp
index 5de3cf8..1f0372d 100644
--- a/libqmenumodel/src/unitymenuaction.cpp
+++ b/libqmenumodel/src/unitymenuaction.cpp
@@ -20,8 +20,6 @@
#include "unitymenumodel.h"
#include "unitymenuactionevents.h"
-#include <QDebug>
-
UnityMenuAction::UnityMenuAction(QObject* parent)
: QObject(parent),
m_valid(false),
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 63d5e5b..8b64ee2 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -26,6 +26,7 @@
#include <QIcon>
#include <QQmlComponent>
#include <QCoreApplication>
+#include <QKeySequence>
extern "C" {
#include "gtk/gtkactionmuxer.h"
@@ -50,7 +51,9 @@ enum MenuRoles {
ActionStateRole,
IsCheckRole,
IsRadioRole,
- IsToggledRole
+ IsToggledRole,
+ ShortcutRole,
+ HasSubmenuRole
};
class UnityMenuModelPrivate
@@ -482,6 +485,12 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
case IsToggledRole:
return gtk_menu_tracker_item_get_toggled (item) == TRUE ? true : false;
+ case ShortcutRole:
+ return QKeySequence(gtk_menu_tracker_item_get_accel (item), QKeySequence::NativeText);
+
+ case HasSubmenuRole:
+ return gtk_menu_tracker_item_get_has_submenu (item) == TRUE ? true : false;
+
default:
return QVariant();
}
@@ -497,7 +506,6 @@ QModelIndex UnityMenuModel::parent(const QModelIndex &index) const
return QModelIndex();
}
-#include <QtDebug>
QHash<int, QByteArray> UnityMenuModel::roleNames() const
{
QHash<int, QByteArray> names;
@@ -513,6 +521,8 @@ QHash<int, QByteArray> UnityMenuModel::roleNames() const
names[IsCheckRole] = "isCheck";
names[IsRadioRole] = "isRadio";
names[IsToggledRole] = "isToggled";
+ names[ShortcutRole] = "shortcut";
+ names[HasSubmenuRole] = "hasSubmenu";
return names;
}