| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // Copyright (C) 2016 Intel Corporation. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QSINGLESHOTTIMER_P_H |
| 6 | #define QSINGLESHOTTIMER_P_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists purely as an |
| 13 | // implementation detail. This header file may change from version to |
| 14 | // version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtCore/qobject.h> |
| 20 | #include <QtCore/qabstracteventdispatcher.h> |
| 21 | #include <QtCore/qnamespace.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | namespace QtPrivate { |
| 26 | class QSlotObjectBase; |
| 27 | } |
| 28 | |
| 29 | class QSingleShotTimer : public QObject |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | |
| 33 | Qt::TimerId timerId = Qt::TimerId::Invalid; |
| 34 | |
| 35 | public: |
| 36 | // use the same duration type |
| 37 | using Duration = QAbstractEventDispatcher::Duration; |
| 38 | |
| 39 | explicit QSingleShotTimer(Duration interval, Qt::TimerType timerType, |
| 40 | const QObject *r, const char *member); |
| 41 | explicit QSingleShotTimer(Duration interval, Qt::TimerType timerType, |
| 42 | const QObject *r, QtPrivate::QSlotObjectBase *slotObj); |
| 43 | ~QSingleShotTimer() override; |
| 44 | |
| 45 | void startTimerForReceiver(Duration interval, Qt::TimerType timerType, |
| 46 | const QObject *receiver); |
| 47 | Q_SIGNALS: |
| 48 | void timeout(); |
| 49 | |
| 50 | private: |
| 51 | void timerEvent(QTimerEvent *) override; |
| 52 | }; |
| 53 | |
| 54 | QT_END_NAMESPACE |
| 55 | |
| 56 | #endif // QSINGLESHOTTIMER_P_H |
| 57 | |