From 794fa75715840f3333ab9248b9a663d26f5241bb Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sat, 10 Sep 2022 20:24:46 +0300 Subject: [PATCH] [Improvement] Copy bot button callback data --- Telegram/Resources/langs/rewrites/en.json | 1 + .../SourceFiles/history/history_item_components.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 54dd7483f..b9e646d65 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -30,6 +30,7 @@ "ktg_user_status_unaccessible": "account inaccessible", "ktg_settings_show_json_settings": "Show settings file", "ktg_settings_restart": "Restart Kotatogram", + "ktg_copy_btn_callback": "Copy callback data", "ktg_settings_chats": "Chats", "ktg_settings_sticker_height": "Sticker height: {pixels}px", "ktg_settings_sticker_scale_both": "Apply to sticker width", diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index dc4a38c7a..aba832f18 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/history_item_components.h" +#include "kotato/kotato_lang.h" #include "api/api_text_entities.h" #include "base/qt/qt_key_modifiers.h" #include "lang/lang_keys.h" @@ -600,7 +601,14 @@ QString ReplyMarkupClickHandler::copyToClipboardText() const { QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const { const auto button = getUrlButton(); - return button ? tr::lng_context_copy_link(tr::now) : QString(); + using Type = HistoryMessageMarkupButton::Type; + return button + ? ((button->type == Type::Url || button->type == Type::Auth) + ? tr::lng_context_copy_link(tr::now) + : (button->type == Type::Callback || button->type == Type::CallbackWithPassword) + ? ktr("ktg_copy_btn_callback") + : QString()) + : QString(); } // Finds the corresponding button in the items markup struct. @@ -614,10 +622,13 @@ const HistoryMessageMarkupButton *ReplyMarkupClickHandler::getButton() const { auto ReplyMarkupClickHandler::getUrlButton() const -> const HistoryMessageMarkupButton* { if (const auto button = getButton()) { + /* using Type = HistoryMessageMarkupButton::Type; if (button->type == Type::Url || button->type == Type::Auth) { return button; } + */ + return button; } return nullptr; }