tdesktop/Telegram/SourceFiles/boxes/background_preview_box.h

88 lines
2.3 KiB
C
Raw Normal View History

2019-02-07 16:36:30 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "boxes/abstract_box.h"
#include "base/binary_guard.h"
#include "window/themes/window_theme.h"
#include "history/admin_log/history_admin_log_item.h"
#include "history/view/history_view_element.h"
2019-04-02 09:13:30 +00:00
#include "ui/effects/animations.h"
2019-02-07 16:36:30 +00:00
#include "ui/effects/radial_animation.h"
namespace Data {
class DocumentMedia;
} // namespace Data
2020-06-10 18:08:17 +00:00
namespace Window {
class SessionController;
} // namespace Window
2019-07-24 14:00:30 +00:00
2019-02-07 16:36:30 +00:00
namespace Ui {
class Checkbox;
} // namespace Ui
class BackgroundPreviewBox
2019-09-18 11:19:05 +00:00
: public Ui::BoxContent
2019-09-16 11:14:06 +00:00
, private HistoryView::SimpleElementDelegate
, private base::Subscriber {
2019-02-07 16:36:30 +00:00
public:
2019-07-24 14:00:30 +00:00
BackgroundPreviewBox(
QWidget*,
2020-06-10 18:08:17 +00:00
not_null<Window::SessionController*> controller,
2019-07-24 14:00:30 +00:00
const Data::WallPaper &paper);
2019-02-07 16:36:30 +00:00
static bool Start(
2020-06-10 18:08:17 +00:00
not_null<Window::SessionController*> controller,
2019-02-07 16:36:30 +00:00
const QString &slug,
const QMap<QString, QString> &params);
protected:
void prepare() override;
void paintEvent(QPaintEvent *e) override;
private:
2019-02-07 16:36:30 +00:00
using Element = HistoryView::Element;
not_null<HistoryView::ElementDelegate*> delegate();
2019-02-07 16:36:30 +00:00
HistoryView::Context elementContext() override;
void apply();
void share();
void radialAnimationCallback(crl::time now);
2019-02-07 16:36:30 +00:00
QRect radialRect() const;
void checkLoadedDocument();
bool setScaledFromThumb();
void setScaledFromImage(QImage &&image, QImage &&blurred);
void updateServiceBg(std::optional<QColor> background);
std::optional<QColor> patternBackgroundColor() const;
2019-04-02 09:13:30 +00:00
void paintImage(Painter &p);
void paintRadial(Painter &p);
void paintTexts(Painter &p, crl::time ms);
2019-02-07 16:36:30 +00:00
void paintDate(Painter &p);
void createBlurCheckbox();
int textsTop() const;
void startFadeInFrom(QPixmap previous);
void checkBlurAnimationStart();
2020-06-10 18:08:17 +00:00
const not_null<Window::SessionController*> _controller;
2019-02-07 16:36:30 +00:00
AdminLog::OwnedItem _text1;
AdminLog::OwnedItem _text2;
Data::WallPaper _paper;
std::shared_ptr<Data::DocumentMedia> _media;
2019-02-07 16:36:30 +00:00
QImage _full;
QPixmap _scaled, _blurred, _fadeOutThumbnail;
2019-04-02 09:13:30 +00:00
Ui::Animations::Simple _fadeIn;
2019-02-07 16:36:30 +00:00
Ui::RadialAnimation _radial;
base::binary_guard _generating;
std::optional<QColor> _serviceBg;
object_ptr<Ui::Checkbox> _blur = { nullptr };
};