aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog8
-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.cpp16
5 files changed, 37 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 75a16d6..6f859b4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+qmenumodel (0.2.11) UNRELEASED; urgency=medium
+
+ [ Nick Dedekind ]
+ * Added shortcut hasSubmenu and roles to UnityMenuModel
+ * Added actions property to Group
+
+ -- Nick Dedekind <nick.dedekind@canonical.com> Fri, 09 Dec 2016 17:11:01 +0000
+
qmenumodel (0.2.10+17.04.20161116-0ubuntu1) zesty; urgency=medium
[ Florian Boucault ]
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 aac1d92..192ee46 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -27,6 +27,7 @@
#include <QIcon>
#include <QQmlComponent>
#include <QCoreApplication>
+#include <QKeySequence>
extern "C" {
#include "gtk/gtkactionmuxer.h"
@@ -53,7 +54,9 @@ enum MenuRoles {
ActionStateRole,
IsCheckRole,
IsRadioRole,
- IsToggledRole
+ IsToggledRole,
+ ShortcutRole,
+ HasSubmenuRole
};
class UnityMenuModelPrivate
@@ -483,7 +486,13 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
return gtk_menu_tracker_item_get_role (item) == GTK_MENU_TRACKER_ITEM_ROLE_RADIO;
case IsToggledRole:
- return gtk_menu_tracker_item_get_toggled (item) == TRUE ? true : false;
+ return gtk_menu_tracker_item_get_toggled (item) != 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) != FALSE;
default:
return QVariant();
@@ -500,7 +509,6 @@ QModelIndex UnityMenuModel::parent(const QModelIndex &index) const
return QModelIndex();
}
-#include <QtDebug>
QHash<int, QByteArray> UnityMenuModel::roleNames() const
{
QHash<int, QByteArray> names;
@@ -516,6 +524,8 @@ QHash<int, QByteArray> UnityMenuModel::roleNames() const
names[IsCheckRole] = "isCheck";
names[IsRadioRole] = "isRadio";
names[IsToggledRole] = "isToggled";
+ names[ShortcutRole] = "shortcut";
+ names[HasSubmenuRole] = "hasSubmenu";
return names;
}