2016-10-05 19:56:27 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-10-05 19:56:27 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-10-05 19:56:27 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "core/basic_types.h"
|
|
|
|
|
|
|
|
class SingleTimer : public QTimer { // single shot timer with check
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-13 20:07:56 +03:00
|
|
|
SingleTimer(QObject *parent = nullptr);
|
2016-10-05 19:56:27 +03:00
|
|
|
|
|
|
|
void setSingleShot(bool); // is not available
|
|
|
|
void start(); // is not available
|
|
|
|
|
2018-06-04 18:35:11 +03:00
|
|
|
void setTimeoutHandler(Fn<void()> handler);
|
2016-10-05 19:56:27 +03:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void start(int msec);
|
|
|
|
void startIfNotActive(int msec);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void adjust();
|
|
|
|
void onTimeout();
|
|
|
|
|
|
|
|
private:
|
2016-12-01 22:20:33 +03:00
|
|
|
TimeMs _finishing = 0;
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void()> _handler;
|
2016-10-05 19:56:27 +03:00
|
|
|
|
|
|
|
};
|