From 592f47a7517ffc637e154133a188c74cbecf2636 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 28 Feb 2022 07:53:18 +0300 Subject: [PATCH] Removed Calls::Group::ConfirmBoxBuilder. --- .../calls/group/calls_choose_join_as.cpp | 9 ++++----- .../group/calls_group_invite_controller.cpp | 6 +++--- .../calls/group/calls_group_menu.cpp | 20 ++++--------------- .../calls/group/calls_group_menu.h | 17 +++------------- .../calls/group/calls_group_panel.cpp | 14 ++++++------- .../calls/group/calls_group_settings.cpp | 5 ++++- 6 files changed, 25 insertions(+), 46 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp index 17a4533fab..5075ec7d13 100644 --- a/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/group/calls_choose_join_as.cpp @@ -466,14 +466,13 @@ void ChooseJoinAsProcess::processList( } return false; }; - auto box = ConfirmBox({ + auto box = Ui::MakeConfirmBox({ .text = confirmation, - .button = (creating + .confirmed = crl::guard(guard, [=] { finish(info); }), + .confirmText = (creating ? tr::lng_create_group_create() : tr::lng_group_call_join()), - .callback = crl::guard(guard, [=] { finish(info); }), - .st = &st::boxLabel, - .filter = filter, + .labelFilter = filter, }); box->boxClosing( ) | rpl::start_with_next([=] { diff --git a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp index d8ed2c2370..516d069451 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp @@ -259,9 +259,9 @@ object_ptr PrepareInviteBox( inviteWithAdd(users, nonMembers, finishWithConfirm); }; auto box = ConfirmBox({ - .text = { text }, - .button = tr::lng_participant_invite(), - .callback = done, + .text = text, + .confirmed = done, + .confirmText = tr::lng_participant_invite(), }); *shared = box.data(); parentBox->getDelegate()->showBox( diff --git a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp index 2f0c52d6fc..875845f038 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_menu.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_menu.cpp @@ -473,22 +473,10 @@ void LeaveBox( box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); } -void ConfirmBoxBuilder( - not_null box, - ConfirmBoxArgs &&args) { - const auto label = box->addRow( - object_ptr( - box.get(), - rpl::single(args.text), - args.st ? *args.st : st::groupCallBoxLabel), - st::boxPadding); - if (args.callback) { - box->addButton(std::move(args.button), std::move(args.callback)); - } - if (args.filter) { - label->setClickHandlerFilter(std::move(args.filter)); - } - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); +object_ptr ConfirmBox(Ui::ConfirmBoxArgs &&args) { + auto copy = std::move(args); + copy.labelStyle = &st::groupCallBoxLabel; + return Ui::MakeConfirmBox(std::move(copy)); } void FillMenu( diff --git a/Telegram/SourceFiles/calls/group/calls_group_menu.h b/Telegram/SourceFiles/calls/group/calls_group_menu.h index 0cb70f3ee2..4241f27db9 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_menu.h +++ b/Telegram/SourceFiles/calls/group/calls_group_menu.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" #include "base/unique_qptr.h" -#include "ui/layers/generic_box.h" +#include "ui/boxes/confirm_box.h" namespace style { struct FlatLabel; @@ -43,19 +43,8 @@ void LeaveBox( bool discardChecked, BoxContext context); -struct ConfirmBoxArgs { - TextWithEntities text; - rpl::producer button; - Fn callback; - const style::FlatLabel *st = nullptr; - Fn filter; -}; - -void ConfirmBoxBuilder(not_null box, ConfirmBoxArgs &&args); - -inline auto ConfirmBox(ConfirmBoxArgs &&args) { - return Box(ConfirmBoxBuilder, std::move(args)); -} +[[nodiscard]] object_ptr ConfirmBox( + Ui::ConfirmBoxArgs &&args); void FillMenu( not_null menu, diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index 38fd259988..18aba7e979 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -341,11 +341,11 @@ void Panel::startScheduledNow() { _call->startScheduledNow(); }; auto owned = ConfirmBox({ - .text = { (_call->peer()->isBroadcast() + .text = (_call->peer()->isBroadcast() ? tr::lng_group_call_start_now_sure_channel - : tr::lng_group_call_start_now_sure)(tr::now) }, - .button = tr::lng_group_call_start_now(), - .callback = done, + : tr::lng_group_call_start_now_sure)(), + .confirmed = done, + .confirmText = tr::lng_group_call_start_now(), }); *box = owned.data(); showBox(std::move(owned)); @@ -1194,9 +1194,9 @@ void Panel::chooseShareScreenSource() { choose(); }; auto box = ConfirmBox({ - .text = { text }, - .button = tr::lng_continue(), - .callback = done, + .text = text, + .confirmed = done, + .confirmText = tr::lng_continue(), }); *shared = box.data(); showBox(std::move(box)); diff --git a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp index 3a1469d6fb..70c68bec83 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp @@ -156,7 +156,10 @@ object_ptr ShareInviteLinkBox( } text.append(error.first); if (const auto weak = *box) { - weak->getDelegate()->show(ConfirmBox({ .text = text })); + weak->getDelegate()->show(ConfirmBox({ + .text = text, + .inform = true, + })); } return; }