From 309d4ea70288bc11f482bdc877a89a3a283d35cf Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 6 Mar 2022 16:02:15 +0300 Subject: [PATCH] Added ability to provide field style to EditLinkBox. --- .../chat_helpers/message_field.cpp | 22 ++++++++++++++----- .../SourceFiles/chat_helpers/message_field.h | 3 ++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 248ad0ad6..ff386a1f1 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -95,15 +95,17 @@ void EditLinkBox( not_null session, const QString &startText, const QString &startLink, - Fn callback) { + Fn callback, + const style::InputField *fieldStyle) { Expects(callback != nullptr); + const auto &fieldSt = fieldStyle ? *fieldStyle : st::defaultInputField; const auto content = box->verticalLayout(); const auto text = content->add( object_ptr( content, - st::defaultInputField, + fieldSt, tr::lng_formatting_link_text(), startText), st::markdownLinkFieldPadding); @@ -114,7 +116,7 @@ void EditLinkBox( box->getDelegate()->outerContainer(), text, session); - InitSpellchecker(std::move(show), session, text); + InitSpellchecker(std::move(show), session, text, fieldStyle != nullptr); const auto placeholder = content->add( object_ptr(content), @@ -124,7 +126,7 @@ void EditLinkBox( content, object_ptr( content, - st::defaultInputField, + fieldSt, tr::lng_formatting_link_url(), startLink.trimmed())); url->heightValue( @@ -243,7 +245,8 @@ Fn DefaultEditLinkCallback( std::shared_ptr show, not_null session, - not_null field) { + not_null field, + const style::InputField *fieldStyle) { const auto weak = Ui::MakeWeak(field); return [=]( EditLinkSelection selection, @@ -260,7 +263,14 @@ FnshowBox( - Box(EditLinkBox, show, session, text, link, std::move(callback)), + Box( + EditLinkBox, + show, + session, + text, + link, + std::move(callback), + fieldStyle), Ui::LayerOption::KeepOther); return true; }; diff --git a/Telegram/SourceFiles/chat_helpers/message_field.h b/Telegram/SourceFiles/chat_helpers/message_field.h index f3f401229..01f4f6dae 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.h +++ b/Telegram/SourceFiles/chat_helpers/message_field.h @@ -41,7 +41,8 @@ Fn DefaultEditLinkCallback( std::shared_ptr show, not_null session, - not_null field); + not_null field, + const style::InputField *fieldStyle = nullptr); void InitMessageField( not_null controller, not_null field);