2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#ifndef UBUNTUGESTURES_TIMER_H
18#define UBUNTUGESTURES_TIMER_H
20#include "UbuntuGesturesGlobal.h"
21#include "TimeSource.h"
27namespace UbuntuGestures {
29/* Defines an interface for a Timer. Useful for tests. */
30class UBUNTUGESTURES_EXPORT AbstractTimer : public QObject
34 AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
35 virtual int interval() const = 0;
36 virtual void setInterval(int msecs) = 0;
37 virtual void start() { m_isRunning = true; }
38 virtual void stop() { m_isRunning = false; }
39 bool isRunning() const { return m_isRunning; }
40 virtual bool isSingleShot() const = 0;
41 virtual void setSingleShot(bool value) = 0;
48/* Essentially a QTimer wrapper */
49class UBUNTUGESTURES_EXPORT Timer : public AbstractTimer
53 Timer(QObject *parent = nullptr);
55 int interval() const override;
56 void setInterval(int msecs) override;
57 void start() override;
59 bool isSingleShot() const override;
60 void setSingleShot(bool value) override;
66class UBUNTUGESTURES_EXPORT FakeTimer : public AbstractTimer
70 FakeTimer(const SharedTimeSource &timeSource, QObject *parent = nullptr);
73 qint64 nextTimeoutTime() const { return m_nextTimeoutTime; }
75 int interval() const override;
76 void setInterval(int msecs) override;
77 void start() override;
78 bool isSingleShot() const override;
79 void setSingleShot(bool value) override;
83 SharedTimeSource m_timeSource;
84 qint64 m_nextTimeoutTime;
87class UBUNTUGESTURES_EXPORT AbstractTimerFactory
90 virtual ~AbstractTimerFactory() {}
91 virtual AbstractTimer *createTimer(QObject *parent = nullptr) = 0;
94class UBUNTUGESTURES_EXPORT TimerFactory : public AbstractTimerFactory
97 AbstractTimer *createTimer(QObject *parent = nullptr) override { return new Timer(parent); }
100class UBUNTUGESTURES_EXPORT FakeTimerFactory : public AbstractTimerFactory
104 virtual ~FakeTimerFactory() {}
106 void updateTime(qint64 msecsSinceReference);
107 QSharedPointer<TimeSource> timeSource() { return m_timeSource; }
109 AbstractTimer *createTimer(QObject *parent = nullptr) override;
110 QList<QPointer<FakeTimer>> timers;
112 QSharedPointer<FakeTimeSource> m_timeSource;
115} // namespace UbuntuGestures
117#endif // UBUNTUGESTURES_TIMER_H
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list