/* 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" namespace style { struct ShortInfoCover; struct ShortInfoBox; } // namespace style namespace Media::Streaming { class Document; class Instance; struct Update; enum class Error; struct Information; } // namespace Media::Streaming namespace Ui { class VerticalLayout; class RpWidget; } // namespace Ui enum class PeerShortInfoType { Self, User, Group, Channel, }; struct PeerShortInfoFields { QString name; QString phone; QString link; TextWithEntities about; QString username; bool isBio = false; }; struct PeerShortInfoUserpic { int index = 0; int count = 0; QImage photo; float64 photoLoadingProgress = 0.; std::shared_ptr videoDocument; crl::time videoStartPosition = 0; QString additionalStatus; }; class PeerShortInfoCover final { public: PeerShortInfoCover( not_null parent, const style::ShortInfoCover &st, rpl::producer name, rpl::producer status, rpl::producer userpic, Fn videoPaused); ~PeerShortInfoCover(); [[nodiscard]] not_null widget() const; [[nodiscard]] object_ptr takeOwned(); [[nodiscard]] gsl::span roundMask() const; void setScrollTop(int scrollTop); [[nodiscard]] rpl::producer moveRequests() const; [[nodiscard]] rpl::lifetime &lifetime(); private: struct CustomLabelStyle; struct Radial; void paint(QPainter &p); void paintCoverImage(QPainter &p, const QImage &image); void paintBars(QPainter &p); void paintShadow(QPainter &p); void paintRadial(QPainter &p); [[nodiscard]] QImage currentVideoFrame() const; void applyUserpic(PeerShortInfoUserpic &&value); void applyAdditionalStatus(const QString &status); [[nodiscard]] QRect radialRect() const; void videoWaiting(); void checkStreamedIsStarted(); void handleStreamingUpdate(Media::Streaming::Update &&update); void handleStreamingError(Media::Streaming::Error &&error); void streamingReady(Media::Streaming::Information &&info); void clearVideo(); void updateRadialState(); void refreshCoverCursor(); void refreshBarImages(); void refreshLabelsGeometry(); const style::ShortInfoCover &_st; object_ptr _owned; const not_null _widget; std::unique_ptr _nameStyle; object_ptr _name; std::unique_ptr _statusStyle; object_ptr _status; object_ptr _additionalStatus = { nullptr }; std::array _roundMask; QImage _userpicImage; QImage _roundedTopImage; QImage _barSmall; QImage _barLarge; QImage _shadowTop; int _scrollTop = 0; int _smallWidth = 0; int _largeWidth = 0; int _index = 0; int _count = 0; style::cursor _cursor = style::cur_default; std::unique_ptr _videoInstance; crl::time _videoStartPosition = 0; crl::time _videoPosition = 0; crl::time _videoDuration = 0; Fn _videoPaused; QImage _shadowBottom; std::unique_ptr _radial; float64 _photoLoadingProgress = 0.; rpl::event_stream _moveRequests; }; class PeerShortInfoBox final : public Ui::BoxContent { public: PeerShortInfoBox( QWidget*, PeerShortInfoType type, rpl::producer fields, rpl::producer status, rpl::producer userpic, Fn videoPaused, const style::ShortInfoBox *stOverride); ~PeerShortInfoBox(); [[nodiscard]] rpl::producer<> openRequests() const; [[nodiscard]] rpl::producer moveRequests() const; private: void prepare() override; void prepareRows(); RectParts customCornersFilling() override; void resizeEvent(QResizeEvent *e) override; void refreshRoundedTopImage(const QColor &color); int fillRoundedTopHeight(); [[nodiscard]] rpl::producer nameValue() const; [[nodiscard]] rpl::producer linkValue() const; [[nodiscard]] rpl::producer phoneValue() const; [[nodiscard]] rpl::producer usernameValue() const; [[nodiscard]] rpl::producer aboutValue() const; const style::ShortInfoBox &_st; const PeerShortInfoType _type = PeerShortInfoType::User; rpl::variable _fields; QColor _roundedTopColor; QImage _roundedTop; object_ptr _topRoundBackground; object_ptr _scroll; not_null _rows; PeerShortInfoCover _cover; rpl::event_stream<> _openRequests; };