/* 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 "base/flags.h" class Image; namespace Main { class Session; } // namespace Main namespace Data { struct FileOrigin; enum class WallPaperFlag { Pattern = (1 << 0), Default = (1 << 1), Creator = (1 << 2), Dark = (1 << 3), }; inline constexpr bool is_flag_type(WallPaperFlag) { return true; }; using WallPaperFlags = base::flags; class WallPaper { public: explicit WallPaper(WallPaperId id); void setLocalImageAsThumbnail(std::shared_ptr image); [[nodiscard]] WallPaperId id() const; [[nodiscard]] const std::vector backgroundColors() const; [[nodiscard]] DocumentData *document() const; [[nodiscard]] Image *localThumbnail() const; [[nodiscard]] bool isPattern() const; [[nodiscard]] bool isDefault() const; [[nodiscard]] bool isCreator() const; [[nodiscard]] bool isDark() const; [[nodiscard]] bool isLocal() const; [[nodiscard]] bool isBlurred() const; [[nodiscard]] int patternIntensity() const; [[nodiscard]] float64 patternOpacity() const; [[nodiscard]] int gradientRotation() const; [[nodiscard]] bool hasShareUrl() const; [[nodiscard]] QString shareUrl(not_null session) const; void loadDocument() const; void loadDocumentThumbnail() const; [[nodiscard]] FileOrigin fileOrigin() const; [[nodiscard]] UserId ownerId() const; [[nodiscard]] MTPInputWallPaper mtpInput( not_null session) const; [[nodiscard]] MTPWallPaperSettings mtpSettings() const; [[nodiscard]] WallPaper withUrlParams( const QMap ¶ms) const; [[nodiscard]] WallPaper withBlurred(bool blurred) const; [[nodiscard]] WallPaper withPatternIntensity(int intensity) const; [[nodiscard]] WallPaper withGradientRotation(int rotation) const; [[nodiscard]] WallPaper withBackgroundColors( std::vector colors) const; [[nodiscard]] WallPaper withParamsFrom(const WallPaper &other) const; [[nodiscard]] WallPaper withoutImageData() const; [[nodiscard]] static std::optional Create( not_null session, const MTPWallPaper &data); [[nodiscard]] static std::optional Create( not_null session, const MTPDwallPaper &data); [[nodiscard]] static std::optional Create( const MTPDwallPaperNoFile &data); [[nodiscard]] QByteArray serialize() const; [[nodiscard]] static std::optional FromSerialized( const QByteArray &serialized); [[nodiscard]] static std::optional FromLegacySerialized( quint64 id, quint64 accessHash, quint32 flags, QString slug); [[nodiscard]] static std::optional FromLegacyId( qint32 legacyId); [[nodiscard]] static std::optional FromColorsSlug( const QString &slug); [[nodiscard]] static WallPaper ConstructDefault(); private: static constexpr auto kDefaultIntensity = 50; WallPaperId _id = WallPaperId(); uint64 _accessHash = 0; UserId _ownerId = 0; WallPaperFlags _flags; QString _slug; std::vector _backgroundColors; int _rotation = 0; int _intensity = kDefaultIntensity; bool _blurred = false; DocumentData *_document = nullptr; std::shared_ptr _thumbnail; }; [[nodiscard]] WallPaper ThemeWallPaper(); [[nodiscard]] bool IsThemeWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper CustomWallPaper(); [[nodiscard]] bool IsCustomWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper Legacy1DefaultWallPaper(); [[nodiscard]] bool IsLegacy1DefaultWallPaper(const WallPaper &paper); [[nodiscard]] bool IsLegacy2DefaultWallPaper(const WallPaper &paper); [[nodiscard]] bool IsLegacy3DefaultWallPaper(const WallPaper &paper); [[nodiscard]] bool IsLegacy4DefaultWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper DefaultWallPaper(); [[nodiscard]] bool IsDefaultWallPaper(const WallPaper &paper); [[nodiscard]] bool IsCloudWallPaper(const WallPaper &paper); [[nodiscard]] QImage GenerateDitheredGradient(const WallPaper &paper); [[nodiscard]] QColor ColorFromSerialized(quint32 serialized); [[nodiscard]] QColor ColorFromSerialized(MTPint serialized); [[nodiscard]] std::optional MaybeColorFromSerialized( quint32 serialized); [[nodiscard]] std::optional MaybeColorFromSerialized( const tl::conditional &mtp); namespace details { [[nodiscard]] WallPaper UninitializedWallPaper(); [[nodiscard]] bool IsUninitializedWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper TestingThemeWallPaper(); [[nodiscard]] bool IsTestingThemeWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper TestingDefaultWallPaper(); [[nodiscard]] bool IsTestingDefaultWallPaper(const WallPaper &paper); [[nodiscard]] WallPaper TestingEditorWallPaper(); [[nodiscard]] bool IsTestingEditorWallPaper(const WallPaper &paper); } // namespace details } // namespace Data