aboutsummaryrefslogtreecommitdiff
path: root/module/menuproxy.h
diff options
context:
space:
mode:
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