Sayonara Player
EventFilter.h
1 /* EventFilter.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef EVENTFILTER_H
22 #define EVENTFILTER_H
23 
24 #include <QObject>
25 #include <QEvent>
26 #include <QList>
27 
28 class QAction;
29 class QMouseEvent;
30 
31 namespace Gui
32 {
37  class GenericFilter :
38  public QObject
39  {
40  Q_OBJECT
41 
42  signals:
43  void sigEvent(QEvent::Type);
44 
45  private:
46  QList<QEvent::Type> m_types;
47 
48  public:
49  explicit GenericFilter(const QEvent::Type& type, QObject* parent=nullptr);
50  explicit GenericFilter(const QList<QEvent::Type>& types, QObject* parent=nullptr);
51 
52  protected:
53  bool eventFilter(QObject* o , QEvent* e);
54  };
55 
61  public QObject
62  {
63  Q_OBJECT
64 
65  public:
66  explicit KeyPressFilter(QObject* parent=nullptr);
67 
68  signals:
69  void setKeyPressed(int key);
70 
71  protected:
72  bool eventFilter(QObject* o , QEvent* e);
73  };
74 
80  public QObject
81  {
82  Q_OBJECT
83 
84  public:
85  explicit ContextMenuFilter(QObject* parent=nullptr);
86 
87  signals:
88  // directly connect this signal to QMenu::popup
89  void sigContextMenu(const QPoint& p, QAction* action);
90 
91  protected:
92  bool eventFilter(QObject* o , QEvent* e);
93  };
94 
100  public QObject
101  {
102  Q_OBJECT
103 
104  public:
105  explicit MouseMoveFilter(QObject* parent=nullptr);
106 
107  signals:
108  void sigMouseMoved(QMouseEvent* e);
109 
110  protected:
111  bool eventFilter(QObject* o , QEvent* e);
112  };
113 
119  public QObject
120  {
121  Q_OBJECT
122 
123  public:
124  explicit MousePressedFilter(QObject* parent=nullptr);
125 
126  signals:
127  void sigMousePressed(QMouseEvent* e);
128 
129  protected:
130  bool eventFilter(QObject* o , QEvent* e);
131  };
132 
138  public QObject
139  {
140  Q_OBJECT
141 
142  public:
143  explicit MouseReleasedFilter(QObject* parent=nullptr);
144 
145  signals:
146  void sigMouseReleased(QMouseEvent* e);
147 
148  protected:
149  bool eventFilter(QObject* o , QEvent* e);
150  };
151 
152 
158  public QObject
159  {
160  Q_OBJECT
161 
162  public:
163  explicit MouseEnterFilter(QObject* parent=nullptr);
164 
165  signals:
166  void sigMouseEntered();
167 
168  protected:
169  bool eventFilter(QObject* o, QEvent* e);
170  };
171 
172 
178  public QObject
179  {
180  Q_OBJECT
181 
182  public:
183  explicit MouseLeaveFilter(QObject* parent=nullptr);
184 
185  signals:
186  void sigMouseLeft();
187 
188  protected:
189  bool eventFilter(QObject* o, QEvent* e);
190  };
191 
192 
197  class HideFilter :
198  public QObject
199  {
200  Q_OBJECT
201 
202  public:
203  explicit HideFilter(QObject* parent=nullptr);
204 
205  signals:
206  void sigHidden();
207 
208  protected:
209  bool eventFilter(QObject* o, QEvent* e);
210  };
211 
212 
217  class ShowFilter :
218  public QObject
219  {
220  Q_OBJECT
221 
222  public:
223  explicit ShowFilter(QObject* parent=nullptr);
224 
225  signals:
226  void sigShown();
227 
228  protected:
229  bool eventFilter(QObject* o, QEvent* e);
230  };
231 
232 
233 
238  class ResizeFilter :
239  public QObject
240  {
241  Q_OBJECT
242 
243  public:
244  explicit ResizeFilter(QObject* parent=nullptr);
245 
246  signals:
247  void sigResized(const QSize& newSize);
248 
249  protected:
250  bool eventFilter(QObject* o, QEvent* e);
251  };
252 
253 
258  class PaintFilter :
259  public QObject
260  {
261  Q_OBJECT
262 
263  public:
264  explicit PaintFilter(QObject* parent=nullptr);
265 
266  signals:
267  void sigPainted();
268 
269  protected:
270  bool eventFilter(QObject* o, QEvent* e);
271  };
272 }
273 
274 #endif // EVENTFILTER_H
Gui::MousePressedFilter
The MouseMoveFilter class.
Definition: EventFilter.h:120
Gui::ResizeFilter
The ShowFilter class.
Definition: EventFilter.h:240
Gui::ContextMenuFilter
The ContextMenuFilter class.
Definition: EventFilter.h:81
Gui::PaintFilter
The PaintFilter class.
Definition: EventFilter.h:260
QList< QEvent::Type >
Gui::MouseMoveFilter
The MouseMoveFilter class.
Definition: EventFilter.h:101
Gui::MouseEnterFilter
The MouseEnterFilter class.
Definition: EventFilter.h:159
Gui::GenericFilter
The GenericFilter class.
Definition: EventFilter.h:39
Gui::MouseReleasedFilter
The MouseMoveFilter class.
Definition: EventFilter.h:139
Gui::KeyPressFilter
The KeyPressFilter class.
Definition: EventFilter.h:62
Gui::MouseLeaveFilter
The MouseLeaveFilter class.
Definition: EventFilter.h:179
Gui::ShowFilter
The ShowFilter class.
Definition: EventFilter.h:219
Gui::HideFilter
The HideFilter class.
Definition: EventFilter.h:199