Sayonara Player
EventFilter.h
1 /* EventFilter.h */
2 
3 /* Copyright (C) 2011-2019 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 
30 namespace Gui
31 {
36  class GenericFilter :
37  public QObject
38  {
39  Q_OBJECT
40 
41  signals:
42  void sig_event(QEvent::Type);
43 
44  private:
45  QList<QEvent::Type> m_types;
46 
47  public:
48  explicit GenericFilter(const QEvent::Type& type, QObject* parent=nullptr);
49  explicit GenericFilter(const QList<QEvent::Type>& types, QObject* parent=nullptr);
50 
51  protected:
52  bool eventFilter(QObject* o , QEvent* e);
53  };
54 
60  public QObject
61  {
62  Q_OBJECT
63 
64  public:
65  explicit KeyPressFilter(QObject* parent=nullptr);
66 
67  signals:
68  void sig_key_pressed(int key);
69 
70  protected:
71  bool eventFilter(QObject* o , QEvent* e);
72  };
73 
79  public QObject
80  {
81  Q_OBJECT
82 
83  public:
84  explicit ContextMenuFilter(QObject* parent=nullptr);
85 
86  signals:
87  // directly connect this signal to QMenu::popup
88  void sig_context_menu(const QPoint& p, QAction* action);
89 
90  protected:
91  bool eventFilter(QObject* o , QEvent* e);
92  };
93 
99  public QObject
100  {
101  Q_OBJECT
102 
103  public:
104  explicit MouseMoveFilter(QObject* parent=nullptr);
105 
106  signals:
107  void sig_mouse_moved(const QPoint& p);
108 
109  protected:
110  bool eventFilter(QObject* o , QEvent* e);
111  };
112 
118  public QObject
119  {
120  Q_OBJECT
121 
122  public:
123  explicit MouseEnterFilter(QObject* parent=nullptr);
124 
125  signals:
126  void sig_mouse_entered();
127 
128  protected:
129  bool eventFilter(QObject* o, QEvent* e);
130  };
131 
132 
138  public QObject
139  {
140  Q_OBJECT
141 
142  public:
143  explicit MouseLeaveFilter(QObject* parent=nullptr);
144 
145  signals:
146  void sig_mouse_left();
147 
148  protected:
149  bool eventFilter(QObject* o, QEvent* e);
150  };
151 
152 
157  class HideFilter :
158  public QObject
159  {
160  Q_OBJECT
161 
162  public:
163  explicit HideFilter(QObject* parent=nullptr);
164 
165  signals:
166  void sig_hidden();
167 
168  protected:
169  bool eventFilter(QObject* o, QEvent* e);
170  };
171 
172 
177  class ShowFilter :
178  public QObject
179  {
180  Q_OBJECT
181 
182  public:
183  explicit ShowFilter(QObject* parent=nullptr);
184 
185  signals:
186  void sig_shown();
187 
188  protected:
189  bool eventFilter(QObject* o, QEvent* e);
190  };
191 
192 
197  class PaintFilter :
198  public QObject
199  {
200  Q_OBJECT
201 
202  public:
203  explicit PaintFilter(QObject* parent=nullptr);
204 
205  signals:
206  void sig_painted();
207 
208  protected:
209  bool eventFilter(QObject* o, QEvent* e);
210  };
211 }
212 
213 #endif // EVENTFILTER_H
The GenericFilter class.
Definition: EventFilter.h:36
The MouseEnterFilter class.
Definition: EventFilter.h:117
The PaintFilter class.
Definition: EventFilter.h:197
The MouseMoveFilter class.
Definition: EventFilter.h:98
The HideFilter class.
Definition: EventFilter.h:157
The ContextMenuFilter class.
Definition: EventFilter.h:78
The ShowFilter class.
Definition: EventFilter.h:177
The MouseLeaveFilter class.
Definition: EventFilter.h:137
The KeyPressFilter class.
Definition: EventFilter.h:59