File indexing completed on 2024-05-12 16:01:52

0001 /*
0002  *  SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISMOUSECLICKEATER_H
0008 #define KISMOUSECLICKEATER_H
0009 
0010 #include <QtGlobal>
0011 #include <QObject>
0012 #include <QElapsedTimer>
0013 
0014 
0015 class KisMouseClickEater : public QObject
0016 {
0017 public:
0018     KisMouseClickEater(Qt::MouseButtons buttons,
0019                        int clicksToEat = 1,
0020                        QObject *parent = 0);
0021 
0022     ~KisMouseClickEater();
0023 
0024     void reset();
0025     bool eventFilter(QObject *watched, QEvent *event) override;
0026 
0027 private:
0028     Qt::MouseButtons m_buttons = Qt::NoButton;
0029     int m_clicksToEat = 1;
0030     int m_clicksHappened = 0;
0031     QElapsedTimer m_timeSinceReset;
0032 };
0033 
0034 #endif // KISMOUSECLICKEATER_H