Copy code blocks on header click.

This commit is contained in:
John Preston 2023-10-20 18:00:28 +04:00
parent 575684670c
commit 66f73a5a64
11 changed files with 19 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

View File

@ -2686,6 +2686,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_formatting_link_create" = "Create"; "lng_formatting_link_create" = "Create";
"lng_text_copied" = "Text copied to clipboard."; "lng_text_copied" = "Text copied to clipboard.";
"lng_code_copied" = "Code copied to clipboard.";
"lng_spellchecker_submenu" = "Spelling"; "lng_spellchecker_submenu" = "Spelling";
"lng_spellchecker_add" = "Add to Dictionary"; "lng_spellchecker_add" = "Add to Dictionary";

View File

@ -243,6 +243,16 @@ bool UiIntegration::handleUrlClick(
return true; return true;
} }
bool UiIntegration::copyPreOnClick(const QVariant &context) {
const auto my = context.value<ClickHandlerContext>();
if (const auto window = my.sessionWindow.get()) {
window->showToast(tr::lng_code_copied(tr::now));
} else if (my.show) {
my.show->showToast(tr::lng_code_copied(tr::now));
}
return true;
}
std::unique_ptr<Ui::Text::CustomEmoji> UiIntegration::createCustomEmoji( std::unique_ptr<Ui::Text::CustomEmoji> UiIntegration::createCustomEmoji(
const QString &data, const QString &data,
const std::any &context) { const std::any &context) {

View File

@ -53,6 +53,7 @@ public:
bool handleUrlClick( bool handleUrlClick(
const QString &url, const QString &url,
const QVariant &context) override; const QVariant &context) override;
bool copyPreOnClick(const QVariant &context) override;
rpl::producer<> forcePopupMenuHideRequests() override; rpl::producer<> forcePopupMenuHideRequests() override;
const Ui::Emoji::One *defaultEmojiVariant( const Ui::Emoji::One *defaultEmojiVariant(
const Ui::Emoji::One *emoji) override; const Ui::Emoji::One *emoji) override;

View File

@ -56,6 +56,8 @@ messageTextStyle: TextStyle(defaultTextStyle) {
header: 20px; header: 20px;
headerPosition: point(10px, 2px); headerPosition: point(10px, 2px);
scrollable: true; scrollable: true;
icon: icon{{ "chat/mini_copy", windowFg }};
iconPosition: point(4px, 2px);
} }
} }
msgDateTextStyle: defaultTextStyle; msgDateTextStyle: defaultTextStyle;

View File

@ -60,6 +60,8 @@ void EnsurePreCache(
cache->outline.setAlphaF(0.9); cache->outline.setAlphaF(0.9);
cache->header = color->c; cache->header = color->c;
cache->header.setAlphaF(0.25); cache->header.setAlphaF(0.25);
cache->icon = cache->outline;
cache->icon.setAlphaF(0.6);
} }
} // namespace } // namespace

@ -1 +1 @@
Subproject commit 7f62494bb8cb6478a7cb6053ad7b5668fa013366 Subproject commit 629dc69fbffa5d63954c8e8909a26efdd98573b0

@ -1 +1 @@
Subproject commit 5227bec65b6cb8c2b3172747ecb5f3468580de10 Subproject commit c97b3fe73ddfbc80c9ecacfbf2cda824e5b05ff5

@ -1 +1 @@
Subproject commit 9eb9fcf043276bb3a73f1fc25531e4f4862d6fc9 Subproject commit 17d73a5c0cb7350a2330b85347a919ad639ad1cf