2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

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_text_copied" = "Text copied to clipboard.";
"lng_code_copied" = "Code copied to clipboard.";
"lng_spellchecker_submenu" = "Spelling";
"lng_spellchecker_add" = "Add to Dictionary";

View File

@@ -243,6 +243,16 @@ bool UiIntegration::handleUrlClick(
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(
const QString &data,
const std::any &context) {

View File

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

View File

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

View File

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