/* 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 "ui/layers/box_content.h" #include "base/binary_guard.h" #include "history/admin_log/history_admin_log_item.h" #include "history/view/history_view_element.h" #include "ui/effects/animations.h" #include "ui/effects/radial_animation.h" #include "data/data_wall_paper.h" namespace Data { class DocumentMedia; } // namespace Data namespace Window { class SessionController; } // namespace Window namespace Ui { class Checkbox; class ChatStyle; class MediaSlider; template class SlideWrap; template class FadeWrap; } // namespace Ui struct BackgroundPreviewArgs { PeerData *forPeer = nullptr; FullMsgId fromMessageId; }; class BackgroundPreviewBox : public Ui::BoxContent , private HistoryView::SimpleElementDelegate { public: BackgroundPreviewBox( QWidget*, not_null controller, const Data::WallPaper &paper, BackgroundPreviewArgs args = {}); ~BackgroundPreviewBox(); static bool Start( not_null controller, const QString &slug, const QMap ¶ms); protected: void prepare() override; void paintEvent(QPaintEvent *e) override; private: struct OverridenStyle; using Element = HistoryView::Element; not_null delegate(); HistoryView::Context elementContext() override; void apply(); void applyForPeer(); void applyForPeer(bool both); void applyForEveryone(); void uploadForPeer(bool both); void setExistingForPeer(const Data::WallPaper &paper, bool both); void share(); void radialAnimationCallback(crl::time now); QRect radialRect() const; void generateBackground(); void checkLoadedDocument(); void setScaledFromThumb(); void setScaledFromImage(QImage &&image, QImage &&blurred); void updateServiceBg(const std::vector &bg); void paintImage(Painter &p); void paintRadial(Painter &p); void paintTexts(Painter &p, crl::time ms); void recreateBlurCheckbox(); int textsTop() const; void startFadeInFrom(QPixmap previous); void checkBlurAnimationStart(); [[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); const not_null _controller; PeerData * const _forPeer = nullptr; FullMsgId _fromMessageId; std::unique_ptr _chatStyle; const not_null _serviceHistory; AdminLog::OwnedItem _service; AdminLog::OwnedItem _text1; AdminLog::OwnedItem _text2; Data::WallPaper _paper; std::shared_ptr _media; QImage _full; QPixmap _generated, _scaled, _blurred, _fadeOutThumbnail; Ui::Animations::Simple _fadeIn; Ui::RadialAnimation _radial; base::binary_guard _generating; std::optional _serviceBg; object_ptr _blur = { nullptr }; rpl::variable _appNightMode; rpl::variable _boxDarkMode; std::unique_ptr _light, _dark; std::unique_ptr _lightPalette, _darkPalette; bool _waitingForPalette = false; object_ptr> _dimmingWrap = { nullptr }; Ui::RpWidget *_dimmingContent = nullptr; Ui::MediaSlider *_dimmingSlider = nullptr; int _dimmingIntensity = 0; rpl::variable _dimmingHeight = 0; bool _dimmed = false; bool _dimmingToggleScheduled = false; FullMsgId _uploadId; float64 _uploadProgress = 0.; rpl::lifetime _uploadLifetime; std::unique_ptr> _forBothOverlay; rpl::variable _paletteServiceBg; rpl::lifetime _serviceBgLifetime; };