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
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
|
|
|
|
2016-04-08 07:12:48 +00:00
|
|
|
namespace Ui {
|
|
|
|
namespace Toast {
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
class Manager;
|
|
|
|
class Widget;
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
static constexpr const int DefaultDuration = 1500;
|
|
|
|
struct Config {
|
|
|
|
QString text;
|
|
|
|
int durationMs = DefaultDuration;
|
2016-12-23 13:21:01 +00:00
|
|
|
int maxWidth = 0;
|
|
|
|
QMargins padding;
|
2016-04-08 07:12:48 +00:00
|
|
|
};
|
2016-04-12 21:31:28 +00:00
|
|
|
void Show(QWidget *parent, const Config &config);
|
2017-02-03 20:07:26 +00:00
|
|
|
void Show(const Config &config);
|
|
|
|
void Show(const QString &text);
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
class Instance {
|
|
|
|
struct Private {
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Instance(const Config &config, QWidget *widgetParent, const Private &);
|
|
|
|
Instance(const Instance &other) = delete;
|
|
|
|
Instance &operator=(const Instance &other) = delete;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void hideAnimated();
|
2016-04-08 07:12:48 +00:00
|
|
|
void hide();
|
|
|
|
|
|
|
|
private:
|
2016-12-07 13:32:25 +00:00
|
|
|
void opacityAnimationCallback();
|
|
|
|
|
|
|
|
bool _hiding = false;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_opacity;
|
2016-04-08 07:12:48 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
const crl::time _hideAtMs;
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
// ToastManager should reset _widget pointer if _widget is destroyed.
|
|
|
|
friend class internal::Manager;
|
2016-04-12 21:31:28 +00:00
|
|
|
friend void Show(QWidget *parent, const Config &config);
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<internal::Widget> _widget;
|
2016-04-08 07:12:48 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Toast
|
|
|
|
} // namespace Ui
|