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( PeerListBox::PeerListBox(
QWidget*, QWidget*,
std::unique_ptr<PeerListController> controller, 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 class PeerListBox
: public Ui::BoxContent : public Ui::BoxContent

View file

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