From cbef2a0cfc59e5e4607b48215d9cbe04b5eab643 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 22 Apr 2026 13:35:47 +0300 Subject: [PATCH] Added Add-to-Emoji-Set option to menu for small packless stickers. --- .../SourceFiles/api/api_stickers_creator.cpp | 18 ++++++++++++++++++ .../SourceFiles/api/api_stickers_creator.h | 6 ++++++ .../history/history_inner_widget.cpp | 2 +- .../history/view/history_view_context_menu.cpp | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/api/api_stickers_creator.cpp b/Telegram/SourceFiles/api/api_stickers_creator.cpp index 78436916b6..5b1b85d371 100644 --- a/Telegram/SourceFiles/api/api_stickers_creator.cpp +++ b/Telegram/SourceFiles/api/api_stickers_creator.cpp @@ -307,6 +307,24 @@ void AddAddToEmojiSetAction( }); } +void AddAddToOwnedSetAction( + const Ui::Menu::MenuCallback &addAction, + std::shared_ptr show, + not_null document) { + const auto sticker = document->sticker(); + const auto isLottie = sticker && sticker->isLottie(); + const auto size = document->dimensions; + const auto fitsEmoji = !size.isEmpty() + && (size.width() <= kEmojiStickerSideMax) + && (size.height() <= kEmojiStickerSideMax); + if (isLottie || !fitsEmoji) { + AddAddToStickerSetAction(addAction, show, document); + } + if (isLottie || fitsEmoji) { + AddAddToEmojiSetAction(addAction, std::move(show), document); + } +} + void DeleteStickerSet( not_null session, const StickerSetIdentifier &set, diff --git a/Telegram/SourceFiles/api/api_stickers_creator.h b/Telegram/SourceFiles/api/api_stickers_creator.h index d537d1cb6e..069766854d 100644 --- a/Telegram/SourceFiles/api/api_stickers_creator.h +++ b/Telegram/SourceFiles/api/api_stickers_creator.h @@ -32,6 +32,7 @@ namespace Api { inline constexpr auto kStickersInOwnedSetMax = 120; inline constexpr auto kEmojiInOwnedSetMax = 200; +inline constexpr auto kEmojiStickerSideMax = 100; void AddExistingStickerToSet( not_null session, @@ -73,6 +74,11 @@ void AddAddToEmojiSetAction( std::shared_ptr show, not_null document); +void AddAddToOwnedSetAction( + const Ui::Menu::MenuCallback &addAction, + std::shared_ptr show, + not_null document); + class StickerUpload final : public base::has_weak_ptr { public: StickerUpload( diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 599199c81f..44f03da246 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3186,7 +3186,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { showStickerPackInfo(document); }, &st::menuIconStickers); } else { - Api::AddAddToStickerSetAction( + Api::AddAddToOwnedSetAction( Ui::Menu::CreateAddActionCallback(_menu), _controller->uiShow(), document); diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 58f010229a..3bc816d385 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -293,7 +293,7 @@ void AddDocumentActions( &st::menuIconStickers); } if (document->sticker() && !document->sticker()->set) { - Api::AddAddToStickerSetAction( + Api::AddAddToOwnedSetAction( Ui::Menu::CreateAddActionCallback(menu), controller->uiShow(), document);