| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 3 |  | 
| 4 | #ifndef QQMLTIMER_H | 
| 5 | #define QQMLTIMER_H | 
| 6 |  | 
| 7 | // | 
| 8 | //  W A R N I N G | 
| 9 | //  ------------- | 
| 10 | // | 
| 11 | // This file is not part of the Qt API.  It exists purely as an | 
| 12 | // implementation detail.  This header file may change from version to | 
| 13 | // version without notice, or even be removed. | 
| 14 | // | 
| 15 | // We mean it. | 
| 16 | // | 
| 17 |  | 
| 18 | #include <private/qtqmlglobal_p.h> | 
| 19 |  | 
| 20 | #include <QtQmlMeta/qtqmlmetaexports.h> | 
| 21 | #include <QtQml/qqml.h> | 
| 22 | #include <QtCore/qobject.h> | 
| 23 |  | 
| 24 | QT_REQUIRE_CONFIG(qml_animation); | 
| 25 |  | 
| 26 | QT_BEGIN_NAMESPACE | 
| 27 |  | 
| 28 | class QQmlTimerPrivate; | 
| 29 | class Q_QMLMETA_EXPORT QQmlTimer : public QObject, public QQmlParserStatus | 
| 30 | { | 
| 31 |     Q_OBJECT | 
| 32 |     Q_DECLARE_PRIVATE(QQmlTimer) | 
| 33 |     Q_INTERFACES(QQmlParserStatus) | 
| 34 |     Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) | 
| 35 |     Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) | 
| 36 |     Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) | 
| 37 |     Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) | 
| 38 |     Q_PROPERTY(QObject *parent READ parent CONSTANT) | 
| 39 |     Q_CLASSINFO("ParentProperty" , "parent" ) | 
| 40 |     QML_NAMED_ELEMENT(Timer) | 
| 41 |     QML_ADDED_IN_VERSION(2, 0) | 
| 42 |  | 
| 43 | public: | 
| 44 |     QQmlTimer(QObject *parent=nullptr); | 
| 45 |  | 
| 46 |     void setInterval(int interval); | 
| 47 |     int interval() const; | 
| 48 |  | 
| 49 |     bool isRunning() const; | 
| 50 |     void setRunning(bool running); | 
| 51 |  | 
| 52 |     bool isRepeating() const; | 
| 53 |     void setRepeating(bool repeating); | 
| 54 |  | 
| 55 |     bool triggeredOnStart() const; | 
| 56 |     void setTriggeredOnStart(bool triggeredOnStart); | 
| 57 |  | 
| 58 | protected: | 
| 59 |     void classBegin() override; | 
| 60 |     void componentComplete() override; | 
| 61 |  | 
| 62 |     bool event(QEvent *) override; | 
| 63 |  | 
| 64 | public Q_SLOTS: | 
| 65 |     void start(); | 
| 66 |     void stop(); | 
| 67 |     void restart(); | 
| 68 |  | 
| 69 | Q_SIGNALS: | 
| 70 |     void triggered(); | 
| 71 |     void runningChanged(); | 
| 72 |     void intervalChanged(); | 
| 73 |     void repeatChanged(); | 
| 74 |     void triggeredOnStartChanged(); | 
| 75 |  | 
| 76 | private: | 
| 77 |     void update(); | 
| 78 |  | 
| 79 | private Q_SLOTS: | 
| 80 |     void ticked(); | 
| 81 | }; | 
| 82 |  | 
| 83 | QT_END_NAMESPACE | 
| 84 |  | 
| 85 | #endif | 
| 86 |  |