From 9077db2e97329fce5e95439001c034b282a1a0f0 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 15 Oct 2024 12:46:04 +0300 Subject: [PATCH] Added verified mark of web view bots to box of confirmation to open. --- .../inline_bots/bot_attach_web_view.cpp | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index a89e904e9..be215bc50 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -384,11 +384,9 @@ void FillBotUsepic( const auto userpic = Ui::CreateChild( box->verticalLayout(), bot, - st::mainMenuUserpic); + st::infoPersonalChannelUserpic); Ui::AddSkip(box->verticalLayout()); - aboutLabel->setClickHandlerFilter([=]( - const ClickHandlerPtr &, - Qt::MouseButton) { + aboutLabel->setClickHandlerFilter([=](auto &&...) { if (const auto strong = weak.get()) { strong->showPeerHistory( bot->id, @@ -397,14 +395,36 @@ void FillBotUsepic( } return false; }); - Ui::IconWithTitle( - box->verticalLayout(), - userpic, - Ui::CreateChild( - box->verticalLayout(), - rpl::single(bot->name()), - box->getDelegate()->style().title), - aboutLabel); + const auto title = Ui::CreateChild(box->verticalLayout()); + const auto titleLabel = Ui::CreateChild( + title, + rpl::single(bot->name()), + box->getDelegate()->style().title); + const auto icon = bot->isVerified() ? &st::infoVerifiedCheck : nullptr; + title->resize( + titleLabel->width() + (icon ? icon->width() : 0), + titleLabel->height()); + title->widthValue( + ) | rpl::distinct_until_changed() | rpl::start_with_next([=](int w) { + titleLabel->resizeToWidth(w + - (icon ? icon->width() + st::lineWidth : 0)); + }, title->lifetime()); + if (icon) { + title->paintRequest( + ) | rpl::start_with_next([=] { + auto p = Painter(title); + p.fillRect(title->rect(), Qt::transparent); + icon->paint( + p, + std::min( + titleLabel->textMaxWidth() + st::lineWidth, + title->width() - st::lineWidth - icon->width()), + (title->height() - icon->height()) / 2, + title->width()); + }, title->lifetime()); + } + + Ui::IconWithTitle(box->verticalLayout(), userpic, title, aboutLabel); } class BotAction final : public Ui::Menu::ItemBase {