Added verified badge to title in panel for web view bots.

This commit is contained in:
23rd 2024-10-02 21:50:30 +03:00 committed by John Preston
parent d3df2dc1e5
commit 8d93eb919b
4 changed files with 19 additions and 1 deletions

View file

@ -66,6 +66,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_boxes.h"
#include "styles/style_channel_earn.h"
#include "styles/style_chat.h"
#include "styles/style_info.h" // infoVerifiedCheck.
#include "styles/style_layers.h"
#include "styles/style_menu_icons.h"
#include "styles/style_window.h"
@ -1057,6 +1058,17 @@ void WebViewInstance::maybeChooseAndRequestButton(PeerTypes supported) {
void WebViewInstance::show(const QString &url, uint64 queryId) {
auto title = Info::Profile::NameValue(_bot);
auto titleBadge = _bot->isVerified()
? object_ptr<Ui::RpWidget>(_parentShow->toastParent())
: nullptr;
if (titleBadge) {
const auto raw = titleBadge.data();
raw->paintRequest() | rpl::start_with_next([=] {
auto p = Painter(raw);
st::infoVerifiedCheck.paint(p, st::lineWidth, 0, raw->width());
}, raw->lifetime());
raw->resize(st::infoVerifiedCheck.size() + QSize(0, st::lineWidth));
}
const auto &bots = _session->attachWebView().attachBots();
@ -1087,6 +1099,7 @@ void WebViewInstance::show(const QString &url, uint64 queryId) {
.url = url,
.storageId = _session->local().resolveStorageIdBots(),
.title = std::move(title),
.titleBadge = std::move(titleBadge),
.bottom = rpl::single('@' + _bot->username()),
.delegate = static_cast<Ui::BotWebView::Delegate*>(this),
.menuButtons = buttons,

View file

@ -366,6 +366,7 @@ Panel::Progress::Progress(QWidget *parent, Fn<QRect()> rect)
Panel::Panel(
const Webview::StorageId &storageId,
rpl::producer<QString> title,
object_ptr<Ui::RpWidget> titleBadge,
not_null<Delegate*> delegate,
MenuButtons menuButtons,
bool allowClipboardRead)
@ -412,6 +413,7 @@ Panel::Panel(
}, _widget->lifetime());
setTitle(std::move(title));
_widget->setTitleBadge(std::move(titleBadge));
}
Panel::~Panel() {
@ -1620,6 +1622,7 @@ std::unique_ptr<Panel> Show(Args &&args) {
auto result = std::make_unique<Panel>(
args.storageId,
std::move(args.title),
std::move(args.titleBadge),
args.delegate,
args.menuButtons,
args.allowClipboardRead);

View file

@ -76,6 +76,7 @@ public:
Panel(
const Webview::StorageId &storageId,
rpl::producer<QString> title,
object_ptr<Ui::RpWidget> titleBadge,
not_null<Delegate*> delegate,
MenuButtons menuButtons,
bool allowClipboardRead);
@ -191,6 +192,7 @@ struct Args {
QString url;
Webview::StorageId storageId;
rpl::producer<QString> title;
object_ptr<Ui::RpWidget> titleBadge = { nullptr };
rpl::producer<QString> bottom;
not_null<Delegate*> delegate;
MenuButtons menuButtons;

@ -1 +1 @@
Subproject commit a53c0a747ff495e0985bbb1647272c53cb29d501
Subproject commit 3b4db4b98c1341e19cbc7b584a0243b7d6a51510