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;
};
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([=] {

View File

@ -259,9 +259,9 @@ object_ptr<Ui::BoxContent> 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(

View File

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

View File

@ -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<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));
}
[[nodiscard]] object_ptr<Ui::GenericBox> ConfirmBox(
Ui::ConfirmBoxArgs &&args);
void FillMenu(
not_null<Ui::DropdownMenu*> menu,

View File

@ -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));

View File

@ -156,7 +156,10 @@ object_ptr<ShareBox> 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;
}