Added simple PeerListDelegate to show content.

This commit is contained in:
23rd 2022-03-06 10:35:43 +03:00
parent 9dccc12734
commit 905a7e6346
3 changed files with 40 additions and 7 deletions

View file

@ -52,6 +52,25 @@ PaintRoundImageCallback PaintUserpicCallback(
};
}
PeerListContentDelegateShow::PeerListContentDelegateShow(
std::shared_ptr<Ui::Show> show)
: _show(show) {
}
void PeerListContentDelegateShow::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void PeerListContentDelegateShow::peerListHideLayer() {
_show->hideLayer();
}
not_null<QWidget*> PeerListContentDelegateShow::peerListToastParent() {
return _show->toastParent();
}
PeerListBox::PeerListBox(
QWidget*,
std::unique_ptr<PeerListController> controller,

View file

@ -994,6 +994,18 @@ public:
};
class PeerListContentDelegateShow : public PeerListContentDelegateSimple {
public:
PeerListContentDelegateShow(std::shared_ptr<Ui::Show> show);
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
private:
std::shared_ptr<Ui::Show> _show;
};
class PeerListBox
: public Ui::BoxContent

View file

@ -830,15 +830,15 @@ struct LinksList {
};
LinksList AddLinksList(
std::shared_ptr<Ui::BoxShow> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
not_null<UserData*> admin,
int count,
bool revoked) {
auto &lifetime = container->lifetime();
const auto delegate = lifetime.make_state<
PeerListContentDelegateSimple
>();
const auto delegate = lifetime.make_state<PeerListContentDelegateShow>(
show);
const auto controller = lifetime.make_state<LinksController>(
peer,
admin,
@ -855,13 +855,13 @@ LinksList AddLinksList(
}
not_null<Ui::RpWidget*> AddAdminsList(
std::shared_ptr<Ui::BoxShow> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
not_null<UserData*> admin) {
auto &lifetime = container->lifetime();
const auto delegate = lifetime.make_state<
PeerListContentDelegateSimple
>();
const auto delegate = lifetime.make_state<PeerListContentDelegateShow>(
show);
const auto controller = lifetime.make_state<AdminsController>(
peer,
admin);
@ -933,6 +933,7 @@ void ManageInviteLinksBox(
}
auto [list, controller] = AddLinksList(
show,
container,
peer,
admin,
@ -966,7 +967,7 @@ void ManageInviteLinksBox(
tr::lng_group_invite_other_title(),
st::settingsSubsectionTitle),
st::inviteLinkRevokedTitlePadding));
const auto admins = AddAdminsList(container, peer, admin);
const auto admins = AddAdminsList(show, container, peer, admin);
const auto revokedDivider = container->add(object_ptr<Ui::SlideWrap<>>(
container,
@ -979,6 +980,7 @@ void ManageInviteLinksBox(
st::settingsSubsectionTitle),
st::inviteLinkRevokedTitlePadding));
const auto revoked = AddLinksList(
show,
container,
peer,
admin,