From 6f71d21bb7064b0c9c574cf178e93de7eff18d05 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 12 Sep 2024 22:03:16 +0300 Subject: [PATCH] Slightly improved box for link creation when user has link in clipboard. --- Telegram/SourceFiles/chat_helpers/message_field.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 8c4a86ea1..e38c134af 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -147,13 +147,24 @@ void EditLinkBox( object_ptr(content), st::markdownLinkFieldPadding); placeholder->setAttribute(Qt::WA_TransparentForMouseEvents); + const auto link = [&] { + if (!startLink.trimmed().isEmpty()) { + return startLink.trimmed(); + } + const auto clipboard = QGuiApplication::clipboard()->text().trimmed(); + if (clipboard.startsWith("http://") + || clipboard.startsWith("https://")) { + return clipboard; + } + return QString(); + }(); const auto url = Ui::AttachParentChild( content, object_ptr( content, fieldSt, tr::lng_formatting_link_url(), - startLink.trimmed())); + link)); url->heightValue( ) | rpl::start_with_next([placeholder](int height) { placeholder->resize(placeholder->width(), height);