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"
26namespace UbuntuGestures {
28/* Defines an interface for a Timer. Useful for tests. */
29class UBUNTUGESTURES_EXPORT AbstractTimer : public QObject
33 AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
34 virtual int interval() const = 0;
35 virtual void setInterval(int msecs) = 0;
36 virtual void start() { m_isRunning = true; }
37 virtual void stop() { m_isRunning = false; }
38 bool isRunning() const { return m_isRunning; }
39 virtual bool isSingleShot() const = 0;
40 virtual void setSingleShot(bool value) = 0;
47/* Essentially a QTimer wrapper */
48class UBUNTUGESTURES_EXPORT Timer : public AbstractTimer
52 Timer(QObject *parent = nullptr);
54 int interval() const override;
55 void setInterval(int msecs) override;
56 void start() override;
58 bool isSingleShot() const override;
59 void setSingleShot(bool value) override;
65class UBUNTUGESTURES_EXPORT FakeTimer : public AbstractTimer
69 FakeTimer(QObject *parent = nullptr);
71 virtual void emitTimeout() { Q_EMIT timeout(); }
73 int interval() const override;
74 void setInterval(int msecs) override;
75 bool isSingleShot() const override;
76 void setSingleShot(bool value) override;
82class UBUNTUGESTURES_EXPORT AbstractTimerFactory
85 virtual ~AbstractTimerFactory() {}
86 virtual AbstractTimer *createTimer(QObject *parent = nullptr) = 0;
89class UBUNTUGESTURES_EXPORT TimerFactory : public AbstractTimerFactory
92 AbstractTimer *createTimer(QObject *parent = nullptr) override { return new Timer(parent); }
95class UBUNTUGESTURES_EXPORT FakeTimerFactory : public AbstractTimerFactory
98 AbstractTimer *createTimer(QObject *parent = nullptr) override;
99 void makeRunningTimersTimeout();
100 QList<QPointer<FakeTimer>> timers;
103} // namespace UbuntuGestures
105#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