diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 1e82dfe25..d7488d2c5 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -24,6 +24,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/image/image_location_factory.h" #include "ui/text/text_utilities.h" #include "ui/emoji_config.h" +#include "ui/toast/toast.h" +#include "ui/widgets/popup_menu.h" #include "lottie/lottie_multi_player.h" #include "lottie/lottie_animation.h" #include "chat_helpers/stickers_lottie.h" @@ -36,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "app.h" #include "styles/style_layers.h" #include "styles/style_chat_helpers.h" +#include "styles/style_info.h" #include #include @@ -189,11 +192,10 @@ void StickerSetBox::addStickers() { _inner->install(); } -void StickerSetBox::shareStickers() { +void StickerSetBox::copyStickersLink() { const auto url = _controller->session().createInternalLinkFull( qsl("addstickers/") + _inner->shortName()); QGuiApplication::clipboard()->setText(url); - Ui::show(Box(tr::lng_stickers_copied(tr::now))); } void StickerSetBox::updateTitleAndButtons() { @@ -207,10 +209,33 @@ void StickerSetBox::updateButtons() { if (_inner->notInstalled()) { addButton(tr::lng_stickers_add_pack(), [=] { addStickers(); }); addButton(tr::lng_cancel(), [=] { closeBox(); }); + + if (!_inner->shortName().isEmpty()) { + const auto top = addTopButton(st::infoTopBarMenu); + const auto share = [=] { + copyStickersLink(); + Ui::Toast::Show(tr::lng_stickers_copied(tr::now)); + closeBox(); + }; + const auto menu = + std::make_shared>(); + top->setClickedCallback([=] { + *menu = base::make_unique_q(top); + (*menu)->addAction( + tr::lng_stickers_share_pack(tr::now), + share); + (*menu)->popup(QCursor::pos()); + return true; + }); + } } else if (_inner->official()) { addButton(tr::lng_about_done(), [=] { closeBox(); }); } else { - addButton(tr::lng_stickers_share_pack(), [=] { shareStickers(); }); + auto share = [=] { + copyStickersLink(); + Ui::Toast::Show(tr::lng_stickers_copied(tr::now)); + }; + addButton(tr::lng_stickers_share_pack(), std::move(share)); addButton(tr::lng_cancel(), [=] { closeBox(); }); } } else { diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.h b/Telegram/SourceFiles/boxes/sticker_set_box.h index 30eb10b0b..b480f5885 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.h +++ b/Telegram/SourceFiles/boxes/sticker_set_box.h @@ -41,7 +41,7 @@ private: void updateTitleAndButtons(); void updateButtons(); void addStickers(); - void shareStickers(); + void copyStickersLink(); const not_null _controller; MTPInputStickerSet _set;