Added ability to copy link of not installed sticker pack.

This commit is contained in:
23rd 2020-08-31 16:55:47 +03:00 committed by John Preston
parent 91118bf087
commit 94468ecf6d
2 changed files with 29 additions and 4 deletions

View file

@ -24,6 +24,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image_location_factory.h" #include "ui/image/image_location_factory.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/emoji_config.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_multi_player.h"
#include "lottie/lottie_animation.h" #include "lottie/lottie_animation.h"
#include "chat_helpers/stickers_lottie.h" #include "chat_helpers/stickers_lottie.h"
@ -36,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "app.h" #include "app.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "styles/style_info.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
@ -189,11 +192,10 @@ void StickerSetBox::addStickers() {
_inner->install(); _inner->install();
} }
void StickerSetBox::shareStickers() { void StickerSetBox::copyStickersLink() {
const auto url = _controller->session().createInternalLinkFull( const auto url = _controller->session().createInternalLinkFull(
qsl("addstickers/") + _inner->shortName()); qsl("addstickers/") + _inner->shortName());
QGuiApplication::clipboard()->setText(url); QGuiApplication::clipboard()->setText(url);
Ui::show(Box<InformBox>(tr::lng_stickers_copied(tr::now)));
} }
void StickerSetBox::updateTitleAndButtons() { void StickerSetBox::updateTitleAndButtons() {
@ -207,10 +209,33 @@ void StickerSetBox::updateButtons() {
if (_inner->notInstalled()) { if (_inner->notInstalled()) {
addButton(tr::lng_stickers_add_pack(), [=] { addStickers(); }); addButton(tr::lng_stickers_add_pack(), [=] { addStickers(); });
addButton(tr::lng_cancel(), [=] { closeBox(); }); 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<base::unique_qptr<Ui::PopupMenu>>();
top->setClickedCallback([=] {
*menu = base::make_unique_q<Ui::PopupMenu>(top);
(*menu)->addAction(
tr::lng_stickers_share_pack(tr::now),
share);
(*menu)->popup(QCursor::pos());
return true;
});
}
} else if (_inner->official()) { } else if (_inner->official()) {
addButton(tr::lng_about_done(), [=] { closeBox(); }); addButton(tr::lng_about_done(), [=] { closeBox(); });
} else { } 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(); }); addButton(tr::lng_cancel(), [=] { closeBox(); });
} }
} else { } else {

View file

@ -41,7 +41,7 @@ private:
void updateTitleAndButtons(); void updateTitleAndButtons();
void updateButtons(); void updateButtons();
void addStickers(); void addStickers();
void shareStickers(); void copyStickersLink();
const not_null<Window::SessionController*> _controller; const not_null<Window::SessionController*> _controller;
MTPInputStickerSet _set; MTPInputStickerSet _set;