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 "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"
|
2021-07-15 11:12:38 +00:00
|
|
|
#include "data/data_wall_paper.h"
|
2019-02-07 16:36:30 +00:00
|
|
|
|
2020-04-09 14:02:09 +00:00
|
|
|
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;
|
2021-08-27 20:44:47 +00:00
|
|
|
class ChatStyle;
|
2023-04-20 10:39:39 +00:00
|
|
|
class MediaSlider;
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2019-02-07 16:36:30 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2023-04-17 12:36:13 +00:00
|
|
|
struct BackgroundPreviewArgs {
|
|
|
|
PeerData *forPeer = nullptr;
|
|
|
|
FullMsgId fromMessageId;
|
|
|
|
};
|
|
|
|
|
2019-02-07 16:36:30 +00:00
|
|
|
class BackgroundPreviewBox
|
2019-09-18 11:19:05 +00:00
|
|
|
: public Ui::BoxContent
|
2021-07-15 11:12:38 +00:00
|
|
|
, private HistoryView::SimpleElementDelegate {
|
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,
|
2023-04-17 12:36:13 +00:00
|
|
|
const Data::WallPaper &paper,
|
|
|
|
BackgroundPreviewArgs args = {});
|
2023-04-20 10:39:39 +00:00
|
|
|
~BackgroundPreviewBox();
|
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> ¶ms);
|
|
|
|
|
2019-03-19 13:50:36 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2023-04-20 10:39:39 +00:00
|
|
|
struct OverridenStyle;
|
|
|
|
|
2019-02-07 16:36:30 +00:00
|
|
|
using Element = HistoryView::Element;
|
2019-03-19 13:50:36 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate();
|
2019-02-07 16:36:30 +00:00
|
|
|
HistoryView::Context elementContext() override;
|
|
|
|
|
|
|
|
void apply();
|
2023-04-17 12:36:13 +00:00
|
|
|
void applyForPeer();
|
|
|
|
void applyForEveryone();
|
2023-04-19 06:42:01 +00:00
|
|
|
void uploadForPeer();
|
|
|
|
void setExistingForPeer(const Data::WallPaper &paper);
|
2019-02-07 16:36:30 +00:00
|
|
|
void share();
|
2019-04-01 17:44:54 +00:00
|
|
|
void radialAnimationCallback(crl::time now);
|
2019-02-07 16:36:30 +00:00
|
|
|
QRect radialRect() const;
|
|
|
|
|
2021-08-13 12:58:38 +00:00
|
|
|
void generateBackground();
|
2019-02-07 16:36:30 +00:00
|
|
|
void checkLoadedDocument();
|
2021-08-13 12:58:38 +00:00
|
|
|
void setScaledFromThumb();
|
2019-02-07 16:36:30 +00:00
|
|
|
void setScaledFromImage(QImage &&image, QImage &&blurred);
|
2021-08-12 14:51:44 +00:00
|
|
|
void updateServiceBg(const std::vector<QColor> &bg);
|
2019-04-02 09:13:30 +00:00
|
|
|
void paintImage(Painter &p);
|
|
|
|
void paintRadial(Painter &p);
|
2019-02-19 06:57:53 +00:00
|
|
|
void paintTexts(Painter &p, crl::time ms);
|
2023-04-20 10:39:39 +00:00
|
|
|
void recreateBlurCheckbox();
|
2019-02-07 16:36:30 +00:00
|
|
|
int textsTop() const;
|
|
|
|
void startFadeInFrom(QPixmap previous);
|
|
|
|
void checkBlurAnimationStart();
|
|
|
|
|
2023-04-20 10:39:39 +00:00
|
|
|
[[nodiscard]] const style::Box &overridenStyle(bool dark);
|
|
|
|
void paletteReady();
|
|
|
|
void applyDarkMode(bool dark);
|
|
|
|
[[nodiscard]] OverridenStyle prepareOverridenStyle(bool dark);
|
|
|
|
|
|
|
|
void resetTitle();
|
|
|
|
void rebuildButtons(bool dark);
|
|
|
|
void createDimmingSlider(bool dark);
|
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
2023-04-17 12:36:13 +00:00
|
|
|
PeerData * const _forPeer = nullptr;
|
|
|
|
FullMsgId _fromMessageId;
|
2021-08-27 20:44:47 +00:00
|
|
|
std::unique_ptr<Ui::ChatStyle> _chatStyle;
|
2023-04-17 12:36:13 +00:00
|
|
|
const not_null<History*> _serviceHistory;
|
|
|
|
AdminLog::OwnedItem _service;
|
2019-02-07 16:36:30 +00:00
|
|
|
AdminLog::OwnedItem _text1;
|
|
|
|
AdminLog::OwnedItem _text2;
|
|
|
|
Data::WallPaper _paper;
|
2020-04-09 14:02:09 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> _media;
|
2019-02-07 16:36:30 +00:00
|
|
|
QImage _full;
|
2021-08-13 12:58:38 +00:00
|
|
|
QPixmap _generated, _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 };
|
|
|
|
|
2023-04-20 10:39:39 +00:00
|
|
|
rpl::variable<bool> _appNightMode;
|
|
|
|
rpl::variable<bool> _boxDarkMode;
|
|
|
|
std::unique_ptr<OverridenStyle> _light, _dark;
|
|
|
|
std::unique_ptr<style::palette> _lightPalette, _darkPalette;
|
|
|
|
bool _waitingForPalette = false;
|
|
|
|
|
|
|
|
object_ptr<Ui::SlideWrap<Ui::RpWidget>> _dimmingWrap = { nullptr };
|
|
|
|
Ui::RpWidget *_dimmingContent = nullptr;
|
|
|
|
Ui::MediaSlider *_dimmingSlider = nullptr;
|
|
|
|
int _dimmingIntensity = 0;
|
|
|
|
rpl::variable<int> _dimmingHeight = 0;
|
|
|
|
bool _dimmed = false;
|
|
|
|
bool _dimmingToggleScheduled = false;
|
|
|
|
|
2023-04-19 06:42:01 +00:00
|
|
|
FullMsgId _uploadId;
|
|
|
|
float64 _uploadProgress = 0.;
|
|
|
|
rpl::lifetime _uploadLifetime;
|
|
|
|
|
2023-04-20 10:39:39 +00:00
|
|
|
rpl::variable<QColor> _paletteServiceBg;
|
|
|
|
rpl::lifetime _serviceBgLifetime;
|
|
|
|
|
2019-02-07 16:36:30 +00:00
|
|
|
};
|