init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
50
Telegram/lib_ui/ui/toast/toast_manager.h
Normal file
50
Telegram/lib_ui/ui/toast/toast_manager.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// This file is part of Desktop App Toolkit,
|
||||
// a set of libraries for developing nice desktop applications.
|
||||
//
|
||||
// For license and copyright information please follow this link:
|
||||
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "ui/toast/toast.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace Toast {
|
||||
namespace internal {
|
||||
|
||||
class Widget;
|
||||
class Manager final : public QObject {
|
||||
struct CreateTag {
|
||||
};
|
||||
|
||||
public:
|
||||
Manager(not_null<QWidget*> parent, const CreateTag &);
|
||||
Manager(const Manager &other) = delete;
|
||||
Manager &operator=(const Manager &other) = delete;
|
||||
~Manager();
|
||||
|
||||
static not_null<Manager*> instance(not_null<QWidget*> parent);
|
||||
|
||||
base::weak_ptr<Instance> addToast(std::unique_ptr<Instance> &&toast);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
|
||||
private:
|
||||
void toastWidgetDestroyed(QObject *widget);
|
||||
void startNextHideTimer();
|
||||
void hideByTimer();
|
||||
|
||||
base::Timer _hideTimer;
|
||||
|
||||
base::flat_multi_map<crl::time, not_null<Instance*>> _toastByHideTime;
|
||||
base::flat_map<not_null<Widget*>, not_null<Instance*>> _toastByWidget;
|
||||
std::vector<std::unique_ptr<Instance>> _toasts;
|
||||
std::vector<QPointer<QWidget>> _toastParents;
|
||||
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace Toast
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user