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 
22 
23 #ifndef EVENTFILTER_H
24 #define EVENTFILTER_H
25 
26 #include <QObject>
27 #include <QEvent>
28 #include <QList>
29 
30 class QAction;
31 
33  public QObject
34 {
35  Q_OBJECT
36 
37 signals:
38  void sig_event(QEvent::Type);
39 
40 private:
41  QList<QEvent::Type> m_types;
42 
43 public:
44  explicit GenericFilter(const QEvent::Type& type, QObject* parent=nullptr);
45  explicit GenericFilter(const QList<QEvent::Type>& types, QObject* parent=nullptr);
46 
47 protected:
48  bool eventFilter(QObject* o , QEvent* e);
49 };
50 
52  public QObject
53 {
54  Q_OBJECT
55 
56 public:
57  explicit KeyPressFilter(QObject* parent=nullptr);
58 
59 signals:
60  void sig_key_pressed(int key);
61 
62 protected:
63  bool eventFilter(QObject* o , QEvent* e);
64 };
65 
66 
67 
68 
70  public QObject
71 {
72  Q_OBJECT
73 
74 public:
75  explicit ContextMenuFilter(QObject* parent=nullptr);
76 
77 signals:
78  // directly connect this signal to QMenu::popup
79  void sig_context_menu(const QPoint& p, QAction* action);
80 
81 protected:
82  bool eventFilter(QObject* o , QEvent* e);
83 };
84 
86  public QObject
87 {
88  Q_OBJECT
89 
90 public:
91  explicit MouseMoveFilter(QObject* parent=nullptr);
92 
93 signals:
94  void sig_mouse_moved(const QPoint& p);
95 
96 protected:
97  bool eventFilter(QObject* o , QEvent* e);
98 };
99 
101  public QObject
102 {
103  Q_OBJECT
104 
105 public:
106  explicit MouseEnterFilter(QObject* parent=nullptr);
107 
108 signals:
109  void sig_mouse_entered();
110 
111 protected:
112  bool eventFilter(QObject* o, QEvent* e);
113 };
114 
115 
117  public QObject
118 {
119  Q_OBJECT
120 
121 public:
122  explicit MouseLeaveFilter(QObject* parent=nullptr);
123 
124 signals:
125  void sig_mouse_left();
126 
127 protected:
128  bool eventFilter(QObject* o, QEvent* e);
129 };
130 
131 
132 class HideFilter :
133  public QObject
134 {
135  Q_OBJECT
136 
137 public:
138  explicit HideFilter(QObject* parent=nullptr);
139 
140 signals:
141  void sig_hidden();
142 
143 protected:
144  bool eventFilter(QObject* o, QEvent* e);
145 };
146 
147 
148 
149 class ShowFilter :
150  public QObject
151 {
152  Q_OBJECT
153 
154 public:
155  explicit ShowFilter(QObject* parent=nullptr);
156 
157 signals:
158  void sig_shown();
159 
160 protected:
161  bool eventFilter(QObject* o, QEvent* e);
162 };
163 
164 
165 class PaintFilter :
166  public QObject
167 {
168  Q_OBJECT
169 
170 public:
171  explicit PaintFilter(QObject* parent=nullptr);
172 
173 signals:
174  void sig_painted();
175 
176 protected:
177  bool eventFilter(QObject* o, QEvent* e);
178 };
179 
180 
181 #endif // EVENTFILTER_H
Definition: EventFilter.h:149
Definition: EventFilter.h:32
Definition: EventFilter.h:85
Definition: EventFilter.h:116
Definition: EventFilter.h:100
Definition: EventFilter.h:165
Definition: EventFilter.h:69
Definition: EventFilter.h:51
Definition: EventFilter.h:132