aboutsummaryrefslogtreecommitdiff
path: root/module/menuproxy.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-01-28 17:21:16 +0100
committerJavier <dev.git@javispedro.com>2014-01-28 17:21:16 +0100
commit982ebc96f2c77c1f9dbddd6a4c0a776c74b425de (patch)
tree6800326ba4da9c84dc14f0b442f088b1c2fb63bf /module/menuproxy.h
downloadtopmenu-qt-982ebc96f2c77c1f9dbddd6a4c0a776c74b425de.tar.gz
topmenu-qt-982ebc96f2c77c1f9dbddd6a4c0a776c74b425de.zip
initial import
Diffstat (limited to 'module/menuproxy.h')
-rw-r--r--module/menuproxy.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/module/menuproxy.h b/module/menuproxy.h
new file mode 100644
index 0000000..6b968ed
--- /dev/null
+++ b/module/menuproxy.h
@@ -0,0 +1,48 @@
+#ifndef MENUPROXY_H
+#define MENUPROXY_H
+
+#include <QtGui/QAction>
+#include <QtGui/QMenu>
+#include <QtGui/QShortcut>
+
+typedef struct _GtkMenu GtkMenu;
+typedef struct _GtkMenuShell GtkMenuShell;
+typedef struct _GtkMenuItem GtkMenuItem;
+typedef struct _GtkAccelGroup GtkAccelGroup;
+
+class MenuProxy : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit MenuProxy(QObject *parent = 0);
+ ~MenuProxy();
+
+ void setTargetMenu(GtkMenuShell *shell);
+
+public:
+ virtual GtkMenuItem * addAction(QAction* action, QAction* before, QMenu* parent);
+ virtual GtkMenu * addMenu(QMenu* menu);
+ virtual void removeAction(QAction* action);
+ virtual void removeMenu(QMenu* menu);
+ virtual void updateAction(QAction* action);
+
+ GtkMenuItem *getItemForAction(QAction *action);
+
+ static QString transformMnemonic(const QString &text);
+
+ bool eventFilter(QObject*, QEvent*);
+
+private:
+ static void handleMenuItemActivated(GtkMenuItem *item, QAction *action);
+ static void handleMenuItemSelected(GtkMenuItem *item, QAction *action);
+ static void handleMenuItemDeselected(GtkMenuItem *item, QAction *action);
+
+private:
+ GtkMenuShell *m_target;
+ QHash<QMenu*, GtkMenu*> m_menus;
+ QHash<QAction*, GtkMenuItem*> m_items;
+ GtkAccelGroup *m_accel;
+};
+
+#endif // MENUPROXY_H