From 905a7e6346bfe7ca83006acbb52ed1747bb9378d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 6 Mar 2022 10:35:43 +0300 Subject: [PATCH] Added simple PeerListDelegate to show content. --- Telegram/SourceFiles/boxes/peer_list_box.cpp | 19 +++++++++++++++++++ Telegram/SourceFiles/boxes/peer_list_box.h | 12 ++++++++++++ .../boxes/peers/edit_peer_invite_links.cpp | 16 +++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index fd877b17e..0b903b878 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -52,6 +52,25 @@ PaintRoundImageCallback PaintUserpicCallback( }; } +PeerListContentDelegateShow::PeerListContentDelegateShow( + std::shared_ptr show) +: _show(show) { +} + +void PeerListContentDelegateShow::peerListShowBox( + object_ptr content, + Ui::LayerOptions options) { + _show->showBox(std::move(content), options); +} + +void PeerListContentDelegateShow::peerListHideLayer() { + _show->hideLayer(); +} + +not_null PeerListContentDelegateShow::peerListToastParent() { + return _show->toastParent(); +} + PeerListBox::PeerListBox( QWidget*, std::unique_ptr controller, diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 6d1a8a9e3..34377542b 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -994,6 +994,18 @@ public: }; +class PeerListContentDelegateShow : public PeerListContentDelegateSimple { +public: + PeerListContentDelegateShow(std::shared_ptr show); + void peerListShowBox( + object_ptr content, + Ui::LayerOptions options = Ui::LayerOption::KeepOther) override; + void peerListHideLayer() override; + not_null peerListToastParent() override; +private: + std::shared_ptr _show; + +}; class PeerListBox : public Ui::BoxContent diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp index edbf03e64..b345bdb05 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp @@ -830,15 +830,15 @@ struct LinksList { }; LinksList AddLinksList( + std::shared_ptr show, not_null container, not_null peer, not_null admin, int count, bool revoked) { auto &lifetime = container->lifetime(); - const auto delegate = lifetime.make_state< - PeerListContentDelegateSimple - >(); + const auto delegate = lifetime.make_state( + show); const auto controller = lifetime.make_state( peer, admin, @@ -855,13 +855,13 @@ LinksList AddLinksList( } not_null AddAdminsList( + std::shared_ptr show, not_null container, not_null peer, not_null admin) { auto &lifetime = container->lifetime(); - const auto delegate = lifetime.make_state< - PeerListContentDelegateSimple - >(); + const auto delegate = lifetime.make_state( + show); const auto controller = lifetime.make_state( 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>( container, @@ -979,6 +980,7 @@ void ManageInviteLinksBox( st::settingsSubsectionTitle), st::inviteLinkRevokedTitlePadding)); const auto revoked = AddLinksList( + show, container, peer, admin,