| 1 | /* |
| 2 | * qca_safetimer.h - Qt Cryptographic Architecture |
| 3 | * Copyright (C) 2014 Ivan Romanov <drizt@land.ru> |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 | * 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef QCA_SAFETIMER_H |
| 23 | #define QCA_SAFETIMER_H |
| 24 | |
| 25 | #include "qca_export.h" |
| 26 | #include <QObject> |
| 27 | |
| 28 | class QEvent; |
| 29 | class QTimerEvent; |
| 30 | |
| 31 | namespace QCA { |
| 32 | |
| 33 | class QCA_EXPORT SafeTimer : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | public: |
| 37 | SafeTimer(QObject *parent = nullptr); |
| 38 | ~SafeTimer() override; |
| 39 | |
| 40 | int interval() const; |
| 41 | bool isActive() const; |
| 42 | bool isSingleShot() const; |
| 43 | void setInterval(int msec); |
| 44 | void setSingleShot(bool singleShot); |
| 45 | int timerId() const; |
| 46 | |
| 47 | public Q_SLOTS: |
| 48 | void start(int msec); |
| 49 | void start(); |
| 50 | void stop(); |
| 51 | |
| 52 | Q_SIGNALS: |
| 53 | void timeout(); |
| 54 | |
| 55 | protected: |
| 56 | bool event(QEvent *event) override; |
| 57 | void timerEvent(QTimerEvent *event) override; |
| 58 | |
| 59 | private: |
| 60 | // Functions is used internally. Outer world mustn't have access them. |
| 61 | void startTimer() |
| 62 | { |
| 63 | } |
| 64 | void killTimer(int) |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | class Private; |
| 69 | Private *d; |
| 70 | }; |
| 71 | |
| 72 | } |
| 73 | |
| 74 | #endif // QCA_SAFETIMER_H |
| 75 | |