-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmenu.h
More file actions
72 lines (67 loc) · 2.04 KB
/
menu.h
File metadata and controls
72 lines (67 loc) · 2.04 KB
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
#ifndef MENU_H
#define MENU_H
#include <QMenu>
#include <QMultiMap>
#include "utilsexport.h"
#include "action.h"
#include "iconstorage.h"
#include <QWidgetAction>
#define AG_NULL -1
#define AG_DEFAULT 500
class Action;
class CustomBorderContainer;
class UTILS_EXPORT Menu :
public QMenu
{
Q_OBJECT
public:
enum Facing
{
Default, // use QMenu::popup()
// move to some point and show
TopLeft,
TopRight,
BottomLeft,
BottomRight
};
Menu(QWidget *AParent = NULL);
~Menu();
bool isEmpty() const;
Action *menuAction() const;
int actionGroup(const Action *AAction) const;
QAction *nextGroupSeparator(int AGroup) const;
QList<Action *> groupActions(int AGroup = AG_NULL) const;
QList<Action *> findActions(const QMultiHash<int, QVariant> AData, bool ASearchInSubMenu = false) const;
void addAction(Action *AAction, int AGroup = AG_DEFAULT, bool ASort = false);
void addActions(QList<Action *> AActions, int AGroup);
void addMenuActions(const Menu *AMenu, int AGroup = AG_DEFAULT, bool ASort = false);
void removeAction(Action *AAction);
void addWidgetAction(QWidgetAction * action);
void clear();
void setIcon(const QIcon &AIcon);
void setIcon(const QString &AStorageName, const QString &AIconKey, int AIconIndex = 0);
void setTitle(const QString &ATitle);
void showMenu(const QPoint & p, Facing facing = Default);
signals:
void actionInserted(QAction *ABefour, Action *AAction, int AGroup, bool ASort);
void actionRemoved(Action *AAction);
void separatorInserted(Action *ABefour, QAction *ASeparator);
void separatorRemoved(QAction *ASeparator);
void menuDestroyed(Menu *AMenu);
protected slots:
void onActionDestroyed(Action *AAction);
public slots:
void onAboutToShow();
void onAboutToHide();
protected:
bool event(QEvent *);
private:
Action *FMenuAction;
IconStorage *FIconStorage;
private:
QMultiMap<int, Action *> FActions;
QMap<int, QAction *> FSeparators;
CustomBorderContainer * border;
bool menuAboutToShow;
};
#endif // MENU_H