File indexing completed on 2024-04-28 04:43:41
0001 /* 0002 * qca_safetimer.h - Qt Cryptographic Architecture 0003 * Copyright (C) 2014 Ivan Romanov <drizt@land.ru> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2.1 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public 0016 * License along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0018 * 02110-1301 USA 0019 * 0020 */ 0021 0022 #ifndef QCA_SAFETIMER_H 0023 #define QCA_SAFETIMER_H 0024 0025 #include "qca_export.h" 0026 #include <QObject> 0027 0028 class QEvent; 0029 class QTimerEvent; 0030 0031 namespace QCA { 0032 0033 class QCA_EXPORT SafeTimer : public QObject 0034 { 0035 Q_OBJECT 0036 public: 0037 SafeTimer(QObject *parent = nullptr); 0038 ~SafeTimer() override; 0039 0040 int interval() const; 0041 bool isActive() const; 0042 bool isSingleShot() const; 0043 void setInterval(int msec); 0044 void setSingleShot(bool singleShot); 0045 int timerId() const; 0046 0047 public Q_SLOTS: 0048 void start(int msec); 0049 void start(); 0050 void stop(); 0051 0052 Q_SIGNALS: 0053 void timeout(); 0054 0055 protected: 0056 bool event(QEvent *event) override; 0057 void timerEvent(QTimerEvent *event) override; 0058 0059 private: 0060 // Functions is used internally. Outer world mustn't have access them. 0061 void startTimer() 0062 { 0063 } 0064 void killTimer(int) 0065 { 0066 } 0067 0068 class Private; 0069 Private *d; 0070 }; 0071 0072 } 0073 0074 #endif // QCA_SAFETIMER_H