1 | /* |
2 | This file is part of the KDE project. |
3 | |
4 | Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr> |
5 | Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com> |
6 | |
7 | Permission is hereby granted, free of charge, to any person obtaining a |
8 | copy of this software and associated documentation files (the "Software"), |
9 | to deal in the Software without restriction, including without limitation |
10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
11 | and/or sell copies of the Software, and to permit persons to whom the |
12 | Software is furnished to do so, subject to the following conditions: |
13 | |
14 | The above copyright notice and this permission notice shall be included in |
15 | all copies or substantial portions of the Software. |
16 | |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | DEALINGS IN THE SOFTWARE. |
24 | */ |
25 | |
26 | #ifndef MENUWIDGET__H |
27 | #define MENUWIDGET__H |
28 | |
29 | #include "menubutton.h" |
30 | |
31 | #include <QGraphicsWidget> |
32 | #include <QTimer> |
33 | |
34 | class QGraphicsLinearLayout; |
35 | class QGraphicsView; |
36 | |
37 | class : public QGraphicsWidget |
38 | { |
39 | Q_OBJECT |
40 | public: |
41 | (QGraphicsView *view = 0); |
42 | (); |
43 | |
44 | /** |
45 | * Set root menu |
46 | */ |
47 | void (QMenu *); |
48 | /** |
49 | * Init layout with root menu |
50 | */ |
51 | void (); |
52 | /** |
53 | * True if a menu is visible in menuwidget |
54 | */ |
55 | bool () { return m_visibleMenu; } |
56 | /** |
57 | * Activate action, or first action if null |
58 | */ |
59 | void (QAction *action); |
60 | |
61 | /** |
62 | * Auto open menu items on mouse over |
63 | */ |
64 | void () { m_mouseTimer->start(100); } |
65 | |
66 | /** |
67 | * Return content bottom margin |
68 | */ |
69 | qreal () { return m_contentBottomMargin; } |
70 | |
71 | void (); |
72 | |
73 | protected: |
74 | /** |
75 | * Use to get keyboard events |
76 | */ |
77 | virtual bool (QObject*, QEvent*); |
78 | /** |
79 | * Filter events on main menu |
80 | */ |
81 | bool (QEvent* event); |
82 | /** |
83 | * Filter events on submenus |
84 | */ |
85 | bool (QObject* object, QEvent* event); |
86 | private Q_SLOTS: |
87 | /** |
88 | * Clean menu if destroyed |
89 | */ |
90 | void (); |
91 | /** |
92 | * Check hovered item and active it |
93 | */ |
94 | void (); |
95 | /** |
96 | * A menu is hidding |
97 | */ |
98 | void (); |
99 | /** |
100 | * Menubar button clicked |
101 | */ |
102 | void (); |
103 | /** |
104 | * Update pending actions |
105 | */ |
106 | void (); |
107 | Q_SIGNALS: |
108 | void (); |
109 | void (); |
110 | private: |
111 | /** |
112 | * Return a button based on action |
113 | */ |
114 | MenuButton* (QAction *action); |
115 | /** |
116 | * Show current button menu |
117 | * return showed menu |
118 | */ |
119 | QMenu* (); |
120 | /** |
121 | * Show next menu if next, otherwise previous |
122 | */ |
123 | void (bool next); |
124 | /** |
125 | * Install event filter for menu and it submenus |
126 | */ |
127 | void (QMenu *, QObject *object); |
128 | |
129 | //Follow mouse position |
130 | QTimer *; |
131 | //Update actions |
132 | QTimer *; |
133 | QGraphicsView *; |
134 | QGraphicsLinearLayout *; |
135 | QList<MenuButton*> ; |
136 | MenuButton *; |
137 | qreal ; |
138 | QPoint ; |
139 | QMenu *; |
140 | QMenu *; |
141 | }; |
142 | |
143 | #endif //MENUWIDGET__H |
144 | |