aboutsummaryrefslogtreecommitdiff
path: root/module/topmenumenubarimpl.h
blob: 49e8d83fe66994d92a5f075b12e405969eeaf97d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef TOPMENUMENUBARIMPL_H
#define TOPMENUMENUBARIMPL_H

#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QHash>
#include <QtCore/QTimer>
#include <QtGui/QAction>
#include <QtGui/QShortcut>
#include <QtGui/QX11Info>
#include <QtGui/private/qabstractplatformmenubar_p.h>
#include <QtGui/private/qt_x11_p.h>

#include "menuproxy.h"

class AppMenu;
typedef struct _TopMenuMonitor        TopMenuMonitor;
typedef struct _TopMenuAppMenuBar     TopMenuAppMenuBar;

class TopMenuMenuBarImpl : public MenuProxy, public QAbstractPlatformMenuBar {
    Q_OBJECT

public:
	explicit TopMenuMenuBarImpl(QObject *parent = 0);
	~TopMenuMenuBarImpl();

	void init(QMenuBar *);

	void setVisible(bool visible);

	void actionEvent(QActionEvent*);

	void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow);

	bool allowCornerWidgets() const;

	void popupAction(QAction*);

	void setNativeMenuBar(bool);
	bool isNativeMenuBar() const;

	bool shortcutsHandledByNativeMenuBar() const;
	bool menuBarEventFilter(QObject *, QEvent *event);

protected:
	GtkMenuItem * addAction(QAction* action, QAction* before, QMenu* parent);
	void removeAction(QAction* action);
	void updateAction(QAction* action);

private:
	QShortcut * createMnemonicShortcut(QAction *action, QWidget *parent);
	static void handleMonitorAvailabilityChanged(TopMenuMenuBarImpl *self);

private slots:
	void handleShortcutActivated();

private:
	static bool staticInitialized;
	static TopMenuMonitor *menuMonitor;

	QWidget *m_window;
	QMenuBar *m_menubar;
	TopMenuAppMenuBar *m_appmenubar;
	AppMenu *m_appmenu;

	ulong m_monitor_connection_id;

	QList<QAction*> m_rootitems;

	bool m_disable;
};

#endif // TOPMENUMENUBARIMPL_H