File indexing completed on 2024-11-24 04:54:31
0001 /* 0002 SPDX-FileCopyrightText: 2022 Aditya Mehra <aix.m@outlook.com> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef KEYFILTER_H 0007 #define KEYFILTER_H 0008 0009 #include <QObject> 0010 #include <QEvent> 0011 #include <QKeyEvent> 0012 0013 class KeyFilter : public QObject 0014 { 0015 Q_OBJECT 0016 0017 public: 0018 explicit KeyFilter(QObject *parent = nullptr); 0019 0020 public Q_SLOTS: 0021 void startFilter(); 0022 void stopFilter(); 0023 bool isFiltering(); 0024 0025 protected: 0026 bool eventFilter(QObject *obj, QEvent *event) override; 0027 0028 Q_SIGNALS: 0029 void keyPress(QEvent *event); 0030 void keyRelease(QEvent *event); 0031 void filterStarted(); 0032 void filterStopped(); 0033 0034 private: 0035 bool m_filtering = false; 0036 }; 0037 0038 #endif // KEYFILTER_H