From 391ec8ac288036e73ae52f4b87077a821db5c4a1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 30 Oct 2020 03:07:59 +0300 Subject: [PATCH] Moved public var indicating stickers presence to private in PhotoData. --- Telegram/SourceFiles/data/data_photo.cpp | 8 ++++++++ Telegram/SourceFiles/data/data_photo.h | 5 ++++- Telegram/SourceFiles/data/data_session.cpp | 8 ++++---- Telegram/SourceFiles/data/data_session.h | 4 ++-- Telegram/SourceFiles/history/history_inner_widget.cpp | 2 +- .../SourceFiles/media/view/media_view_overlay_widget.cpp | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/data/data_photo.cpp b/Telegram/SourceFiles/data/data_photo.cpp index 254417ed2..d5ede173c 100644 --- a/Telegram/SourceFiles/data/data_photo.cpp +++ b/Telegram/SourceFiles/data/data_photo.cpp @@ -376,6 +376,14 @@ void PhotoData::updateImages( [&](Data::FileOrigin origin) { loadVideo(origin); }); } +[[nodiscard]] bool PhotoData::hasAttachedStickers() const { + return _hasStickers; +} + +void PhotoData::setHasAttachedStickers(bool value) { + _hasStickers = value; +} + int PhotoData::width() const { return _images[PhotoSizeIndex(PhotoSize::Large)].location.width(); } diff --git a/Telegram/SourceFiles/data/data_photo.h b/Telegram/SourceFiles/data/data_photo.h index 2c2a60066..09263dcf9 100644 --- a/Telegram/SourceFiles/data/data_photo.h +++ b/Telegram/SourceFiles/data/data_photo.h @@ -142,13 +142,15 @@ public: bool forceRemoteLoader) const -> std::unique_ptr; + [[nodiscard]] bool hasAttachedStickers() const; + void setHasAttachedStickers(bool value); + // For now they return size of the 'large' image. int width() const; int height() const; PhotoId id = 0; TimeId date = 0; - bool hasSticker = false; PeerData *peer = nullptr; // for chat and channel photos connection // geo, caption @@ -164,6 +166,7 @@ private: int32 _dc = 0; uint64 _access = 0; + bool _hasStickers = false; QByteArray _fileReference; std::unique_ptr _replyPreview; std::weak_ptr _media; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 3a186cc30..8ae6619a8 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2291,7 +2291,7 @@ not_null Session::photo( const QByteArray &fileReference, TimeId date, int32 dc, - bool hasSticker, + bool hasStickers, const QByteArray &inlineThumbnailBytes, const ImageWithLocation &small, const ImageWithLocation &thumbnail, @@ -2305,7 +2305,7 @@ not_null Session::photo( fileReference, date, dc, - hasSticker, + hasStickers, inlineThumbnailBytes, small, thumbnail, @@ -2466,7 +2466,7 @@ void Session::photoApplyFields( const QByteArray &fileReference, TimeId date, int32 dc, - bool hasSticker, + bool hasStickers, const QByteArray &inlineThumbnailBytes, const ImageWithLocation &small, const ImageWithLocation &thumbnail, @@ -2478,7 +2478,7 @@ void Session::photoApplyFields( } photo->setRemoteLocation(dc, access, fileReference); photo->date = date; - photo->hasSticker = hasSticker; + photo->setHasAttachedStickers(hasStickers); photo->updateImages( inlineThumbnailBytes, small, diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 52807a6e8..4474e89b5 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -414,7 +414,7 @@ public: const QByteArray &fileReference, TimeId date, int32 dc, - bool hasSticker, + bool hasStickers, const QByteArray &inlineThumbnailBytes, const ImageWithLocation &small, const ImageWithLocation &thumbnail, @@ -685,7 +685,7 @@ private: const QByteArray &fileReference, TimeId date, int32 dc, - bool hasSticker, + bool hasStickers, const QByteArray &inlineThumbnailBytes, const ImageWithLocation &small, const ImageWithLocation &thumbnail, diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index aea01efe8..750a2273b 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1589,7 +1589,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { copyContextImage(photo); }); - if (photo->hasSticker) { + if (photo->hasAttachedStickers()) { _menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] { session->api().attachedStickers().requestAttachedStickerSets( controller, diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 7d9840f1b..43649dbe2 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -773,7 +773,7 @@ void OverlayWidget::updateActions() { if ((_document && documentContentShown()) || (_photo && _photoMedia->loaded())) { _actions.push_back({ tr::lng_mediaview_copy(tr::now), SLOT(onCopy()) }); } - if (_photo && _photo->hasSticker) { + if (_photo && _photo->hasAttachedStickers()) { _actions.push_back({ tr::lng_context_attached_stickers(tr::now), SLOT(onAttachedStickers()) }); } if (_canForwardItem) {