aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorBileto Bot <ci-train-bot@canonical.com>2017-01-10 06:41:09 +0000
committerBileto Bot <ci-train-bot@canonical.com>2017-01-10 06:41:09 +0000
commitab9f99775bf9c9a43791bd545e835733d88476ca (patch)
treea53bc9833a0405b0b960590e886812c944a5b143 /libqmenumodel
parent89f2b36ed993aead5599d937f0d870db1321b9e1 (diff)
parenta9c7379c13c4b6494cd8be33925c40f22dd2a6e4 (diff)
downloadqmenumodel-ab9f99775bf9c9a43791bd545e835733d88476ca.tar.gz
qmenumodel-ab9f99775bf9c9a43791bd545e835733d88476ca.tar.bz2
qmenumodel-ab9f99775bf9c9a43791bd545e835733d88476ca.zip
* Added shortcut hasSubmenu and roles to UnityMenuModel
* Added actions property to Group
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.cpp16
4 files changed, 29 insertions, 5 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 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;
}