File indexing completed on 2024-04-28 16:08:28
0001 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im> 0002 // 0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 0005 #ifndef TAPIN_H 0006 #define TAPIN_H 0007 0008 #include <QObject> 0009 #include <QElapsedTimer> 0010 0011 0012 class TapIn : public QObject 0013 { 0014 Q_OBJECT 0015 0016 Q_PROPERTY(int bpm READ bpm NOTIFY bpmChanged) 0017 Q_PROPERTY(int tapCounter READ tapCounter NOTIFY tapCounterChanged) 0018 0019 public: 0020 explicit TapIn(QObject *parent = nullptr); 0021 0022 Q_INVOKABLE void tap(); 0023 0024 Q_SIGNAL void tapStopped(); 0025 0026 int bpm() const; 0027 Q_SIGNAL void bpmChanged(); 0028 0029 int tapCounter() const; 0030 Q_SIGNAL void tapCounterChanged(); 0031 0032 private: 0033 QElapsedTimer m_tapTimer; 0034 QVector<long long> m_times; 0035 int m_tapCounter = 0; 0036 int m_bpm = 0; 0037 }; 0038 0039 0040 #endif // TAPIN_H