2016-04-08 07:12:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-08 07:12:48 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-08 07:12:48 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/toast/toast.h"
|
2019-01-18 11:26:43 +00:00
|
|
|
#include "base/timer.h"
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
namespace Toast {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class Widget;
|
|
|
|
class Manager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Manager(const Manager &other) = delete;
|
|
|
|
Manager &operator=(const Manager &other) = delete;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
static Manager *instance(QWidget *parent);
|
2016-04-08 07:12:48 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
void addToast(std::unique_ptr<Instance> &&toast);
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
~Manager();
|
|
|
|
|
2017-07-11 17:11:06 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *o, QEvent *e);
|
|
|
|
|
2016-04-08 07:12:48 +00:00
|
|
|
private slots:
|
|
|
|
void onToastWidgetDestroyed(QObject *widget);
|
|
|
|
|
|
|
|
private:
|
2016-04-12 21:31:28 +00:00
|
|
|
Manager(QWidget *parent);
|
2016-04-08 07:12:48 +00:00
|
|
|
void startNextHideTimer();
|
2019-01-18 11:26:43 +00:00
|
|
|
void hideByTimer();
|
2016-04-08 07:12:48 +00:00
|
|
|
|
2019-01-18 11:26:43 +00:00
|
|
|
base::Timer _hideTimer;
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs _nextHide = 0;
|
2016-04-08 07:12:48 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
QMultiMap<TimeMs, Instance*> _toastByHideTime;
|
2016-04-08 07:12:48 +00:00
|
|
|
QMap<Widget*, Instance*> _toastByWidget;
|
|
|
|
QList<Instance*> _toasts;
|
2017-07-11 17:11:06 +00:00
|
|
|
OrderedSet<QPointer<QWidget>> _toastParents;
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace Toast
|
|
|
|
} // namespace Ui
|