From 7b19d67e18cc67a02e58439aeca69ef455f3291e Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sat, 10 Sep 2022 20:39:51 +0300 Subject: [PATCH] [Improvement] Copy sticker pack title --- Telegram/Resources/langs/rewrites/en.json | 2 ++ Telegram/SourceFiles/boxes/sticker_set_box.cpp | 15 +++++++++++++++ Telegram/SourceFiles/boxes/sticker_set_box.h | 1 + 3 files changed, 18 insertions(+) diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index f437b84bf..bf3983f31 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -82,6 +82,8 @@ "ktg_settings_messages": "Messages", "ktg_settings_filters_hide_all": "Hide \"All chats\" folder", "ktg_hide_pinned_message": "Hide", + "ktg_stickers_copy_title": "Copy name", + "ktg_stickers_title_copied": "Sticker pack name copied to clipboard.", "ktg_settings_tray_icon": "Tray icon", "ktg_settings_tray_icon_default": "Default", "ktg_settings_tray_icon_blue": "Blue", diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index f25e0e4a5..46bfbcc02 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/sticker_set_box.h" +#include "kotato/kotato_lang.h" #include "data/data_document.h" #include "data/data_session.h" #include "data/data_file_origin.h" @@ -510,6 +511,15 @@ void StickerSetBox::copyStickersLink() { QGuiApplication::clipboard()->setText(url); } +void StickerSetBox::copyTitle() { + _inner->title( + ) | rpl::start_with_next([this](const TextWithEntities &value) { + QGuiApplication::clipboard()->setText(value.text); + _show->showBox( + Ui::MakeInformBox(ktr("ktg_stickers_title_copied"))); + }, lifetime()); +} + void StickerSetBox::handleError(Error error) { const auto guard = gsl::finally(crl::guard(this, [=] { closeBox(); @@ -680,6 +690,11 @@ bool StickerSetBox::showMenu(not_null button) { }); button->installEventFilter(_menu); + _menu->addAction( + ktr("ktg_stickers_copy_title"), + [=] { copyTitle(); }, + &st::menuIconCopy); + if (!_inner->shortName().isEmpty()) { _menu->addAction( tr::lng_stickers_share_pack(tr::now), diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.h b/Telegram/SourceFiles/boxes/sticker_set_box.h index 97b57b486..449a1a5ac 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.h +++ b/Telegram/SourceFiles/boxes/sticker_set_box.h @@ -88,6 +88,7 @@ private: bool showMenu(not_null button); void addStickers(); void copyStickersLink(); + void copyTitle(); void handleError(Error error); const std::shared_ptr _show;