Removed Calls::Group::ConfirmBoxBuilder.

This commit is contained in:
23rd 2022-02-28 07:53:18 +03:00
parent df125bac19
commit 592f47a751
6 changed files with 25 additions and 46 deletions

View File

@ -466,14 +466,13 @@ void ChooseJoinAsProcess::processList(
} }
return false; return false;
}; };
auto box = ConfirmBox({ auto box = Ui::MakeConfirmBox({
.text = confirmation, .text = confirmation,
.button = (creating .confirmed = crl::guard(guard, [=] { finish(info); }),
.confirmText = (creating
? tr::lng_create_group_create() ? tr::lng_create_group_create()
: tr::lng_group_call_join()), : tr::lng_group_call_join()),
.callback = crl::guard(guard, [=] { finish(info); }), .labelFilter = filter,
.st = &st::boxLabel,
.filter = filter,
}); });
box->boxClosing( box->boxClosing(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {

View File

@ -259,9 +259,9 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
inviteWithAdd(users, nonMembers, finishWithConfirm); inviteWithAdd(users, nonMembers, finishWithConfirm);
}; };
auto box = ConfirmBox({ auto box = ConfirmBox({
.text = { text }, .text = text,
.button = tr::lng_participant_invite(), .confirmed = done,
.callback = done, .confirmText = tr::lng_participant_invite(),
}); });
*shared = box.data(); *shared = box.data();
parentBox->getDelegate()->showBox( parentBox->getDelegate()->showBox(

View File

@ -473,22 +473,10 @@ void LeaveBox(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
} }
void ConfirmBoxBuilder( object_ptr<Ui::GenericBox> ConfirmBox(Ui::ConfirmBoxArgs &&args) {
not_null<Ui::GenericBox*> box, auto copy = std::move(args);
ConfirmBoxArgs &&args) { copy.labelStyle = &st::groupCallBoxLabel;
const auto label = box->addRow( return Ui::MakeConfirmBox(std::move(copy));
object_ptr<Ui::FlatLabel>(
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(); });
} }
void FillMenu( void FillMenu(

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/object_ptr.h" #include "base/object_ptr.h"
#include "base/unique_qptr.h" #include "base/unique_qptr.h"
#include "ui/layers/generic_box.h" #include "ui/boxes/confirm_box.h"
namespace style { namespace style {
struct FlatLabel; struct FlatLabel;
@ -43,19 +43,8 @@ void LeaveBox(
bool discardChecked, bool discardChecked,
BoxContext context); BoxContext context);
struct ConfirmBoxArgs { [[nodiscard]] object_ptr<Ui::GenericBox> ConfirmBox(
TextWithEntities text; Ui::ConfirmBoxArgs &&args);
rpl::producer<QString> button;
Fn<void()> callback;
const style::FlatLabel *st = nullptr;
Fn<bool(const ClickHandlerPtr&, Qt::MouseButton)> filter;
};
void ConfirmBoxBuilder(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args);
inline auto ConfirmBox(ConfirmBoxArgs &&args) {
return Box(ConfirmBoxBuilder, std::move(args));
}
void FillMenu( void FillMenu(
not_null<Ui::DropdownMenu*> menu, not_null<Ui::DropdownMenu*> menu,

View File

@ -341,11 +341,11 @@ void Panel::startScheduledNow() {
_call->startScheduledNow(); _call->startScheduledNow();
}; };
auto owned = ConfirmBox({ 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_channel
: tr::lng_group_call_start_now_sure)(tr::now) }, : tr::lng_group_call_start_now_sure)(),
.button = tr::lng_group_call_start_now(), .confirmed = done,
.callback = done, .confirmText = tr::lng_group_call_start_now(),
}); });
*box = owned.data(); *box = owned.data();
showBox(std::move(owned)); showBox(std::move(owned));
@ -1194,9 +1194,9 @@ void Panel::chooseShareScreenSource() {
choose(); choose();
}; };
auto box = ConfirmBox({ auto box = ConfirmBox({
.text = { text }, .text = text,
.button = tr::lng_continue(), .confirmed = done,
.callback = done, .confirmText = tr::lng_continue(),
}); });
*shared = box.data(); *shared = box.data();
showBox(std::move(box)); showBox(std::move(box));

View File

@ -156,7 +156,10 @@ object_ptr<ShareBox> ShareInviteLinkBox(
} }
text.append(error.first); text.append(error.first);
if (const auto weak = *box) { if (const auto weak = *box) {
weak->getDelegate()->show(ConfirmBox({ .text = text })); weak->getDelegate()->show(ConfirmBox({
.text = text,
.inform = true,
}));
} }
return; return;
} }