Removed redundant peerListShowBox / peerListHideLayer from delegates.

This commit is contained in:
23rd 2023-11-08 23:43:42 +03:00
parent 135ffb13fd
commit 282c076931
21 changed files with 35 additions and 148 deletions

View file

@ -362,7 +362,7 @@ void EditFilterChatsListController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListSetRowChecked(row, !row->checked());
updateTitle();
} else {
delegate()->peerListShowBox(_limitBox(count));
delegate()->peerListUiShow()->showBox(_limitBox(count));
}
}

View file

@ -575,19 +575,19 @@ void LinkController::addLinkBlock(not_null<Ui::VerticalLayout*> container) {
CopyInviteLink(delegate()->peerListUiShow(), link);
});
const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
ShareInviteLinkBox(&_window->session(), link));
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
});
const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
Box(ChatFilterLinkBox, &_window->session(), _data));
});
const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(DeleteLinkBox(_window, _data));
delegate()->peerListUiShow()->showBox(DeleteLinkBox(_window, _data));
});
const auto createMenu = [=] {
@ -846,7 +846,7 @@ void LinksController::rebuild(const std::vector<InviteLinkData> &rows) {
void LinksController::rowClicked(not_null<PeerListRow*> row) {
const auto link = static_cast<LinkRow*>(row.get())->data();
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
ShowLinkBox(_window, _currentFilter(), link));
}
@ -881,19 +881,19 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
CopyInviteLink(delegate()->peerListUiShow(), link);
};
const auto shareLink = [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
ShareInviteLinkBox(&_window->session(), link));
};
const auto getLinkQr = [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
};
const auto editLink = [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
Box(ChatFilterLinkBox, &_window->session(), data));
};
const auto deleteLink = [=] {
delegate()->peerListShowBox(DeleteLinkBox(_window, data));
delegate()->peerListUiShow()->showBox(DeleteLinkBox(_window, data));
};
auto result = base::make_unique_q<Ui::PopupMenu>(
parent,

View file

@ -85,16 +85,6 @@ PeerListContentDelegateShow::PeerListContentDelegateShow(
: _show(show) {
}
void PeerListContentDelegateShow::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void PeerListContentDelegateShow::peerListHideLayer() {
_show->hideLayer();
}
auto PeerListContentDelegateShow::peerListUiShow()
-> std::shared_ptr<Main::SessionShow>{
return _show;
@ -324,16 +314,6 @@ void PeerListBox::peerListSetSearchMode(PeerListSearchMode mode) {
}
}
void PeerListBox::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void PeerListBox::peerListHideLayer() {
_show->hideLayer();
}
std::shared_ptr<Main::SessionShow> PeerListBox::peerListUiShow() {
return _show;
}

View file

@ -332,10 +332,6 @@ public:
virtual std::optional<QPoint> peerListLastRowMousePosition() = 0;
virtual void peerListSortRows(Fn<bool(const PeerListRow &a, const PeerListRow &b)> compare) = 0;
virtual int peerListPartitionRows(Fn<bool(const PeerListRow &a)> border) = 0;
virtual void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) = 0;
virtual void peerListHideLayer() = 0;
virtual std::shared_ptr<Main::SessionShow> peerListUiShow() = 0;
template <typename PeerDataRange>
@ -1007,14 +1003,6 @@ public:
object_ptr<Ui::FlatLabel> description) override {
description.destroy();
}
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override {
Unexpected("...DelegateSimple::peerListShowBox");
}
void peerListHideLayer() override {
Unexpected("...DelegateSimple::peerListHideLayer");
}
std::shared_ptr<Main::SessionShow> peerListUiShow() override {
Unexpected("...DelegateSimple::peerListUiShow");
}
@ -1025,10 +1013,6 @@ class PeerListContentDelegateShow : public PeerListContentDelegateSimple {
public:
explicit PeerListContentDelegateShow(
std::shared_ptr<Main::SessionShow> show);
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
private:
@ -1064,10 +1048,6 @@ public:
bool peerListIsRowChecked(not_null<PeerListRow*> row) override;
int peerListSelectedRowsCount() override;
void peerListScrollToTop() override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void setAddedTopScrollSkip(int skip);

View file

@ -685,7 +685,7 @@ void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
}, box->lifetime());
});
*weak = owned.data();
delegate()->peerListShowBox(std::move(owned));
delegate()->peerListUiShow()->showBox(std::move(owned));
return;
}
const auto history = peer->owner().history(peer);

View file

@ -372,16 +372,6 @@ void PeerListsBox::Delegate::peerListFinishSelectedRowsBunch() {
_box->_select->entity()->finishItemsBunch();
}
void PeerListsBox::Delegate::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void PeerListsBox::Delegate::peerListHideLayer() {
_show->hideLayer();
}
auto PeerListsBox::Delegate::peerListUiShow()
-> std::shared_ptr<Main::SessionShow> {
return _show;

View file

@ -54,10 +54,6 @@ private:
_box->addSelectItem(row, anim::type::instant);
}
void peerListFinishSelectedRowsBunch() override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
private:

View file

@ -366,7 +366,7 @@ bool AddParticipantsBoxController::needsInviteLinkButton() {
QPointer<Ui::BoxContent> AddParticipantsBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box));
delegate()->peerListUiShow()->showBox(std::move(box));
return weak;
}
@ -668,7 +668,7 @@ void AddSpecialBoxController::migrate(
QPointer<Ui::BoxContent> AddSpecialBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box));
delegate()->peerListUiShow()->showBox(std::move(box));
return weak;
}

View file

@ -433,7 +433,7 @@ void ChoosePeerBoxController::rowClicked(not_null<PeerListRow*> row) {
if (const auto user = peer->asUser()) {
done();
} else {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
MakeConfirmBox(_bot, peer, _query, done));
}
}

View file

@ -168,7 +168,7 @@ void Controller::choose(not_null<ChannelData*> chat) {
const auto onstack = _callback;
onstack(chat);
};
delegate()->peerListShowBox(Ui::MakeConfirmBox({
delegate()->peerListUiShow()->showBox(Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),
@ -199,7 +199,7 @@ void Controller::choose(not_null<ChatData*> chat) {
};
chat->session().api().migrateChat(chat, crl::guard(this, done));
};
delegate()->peerListShowBox(Ui::MakeConfirmBox({
delegate()->peerListUiShow()->showBox(Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),

View file

@ -1281,7 +1281,7 @@ void ParticipantsBoxController::rebuild() {
QPointer<Ui::BoxContent> ParticipantsBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box));
delegate()->peerListUiShow()->showBox(std::move(box));
return weak;
}

View file

@ -347,21 +347,24 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
const auto copyLink = crl::guard(weak, [=] {
CopyInviteLink(delegate()->peerListUiShow(), link);
});
const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(ShareInviteLinkBox(_peer, link));
const auto shareLink = crl::guard(weak, [=, peer = _peer] {
delegate()->peerListUiShow()->showBox(ShareInviteLinkBox(peer, link));
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
});
const auto revokeLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(RevokeLinkBox(_peer, admin, link));
delegate()->peerListUiShow()->showBox(
RevokeLinkBox(_peer, admin, link));
});
const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(EditLinkBox(_peer, _data.current()));
delegate()->peerListUiShow()->showBox(
EditLinkBox(_peer, _data.current()));
});
const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(DeleteLinkBox(_peer, admin, link));
delegate()->peerListUiShow()->showBox(
DeleteLinkBox(_peer, admin, link));
});
const auto createMenu = [=] {

View file

@ -537,7 +537,7 @@ void LinksController::appendSlice(const InviteLinksSlice &slice) {
}
void LinksController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()));
}
@ -573,25 +573,27 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
st::popupMenuWithIcons);
if (data.revoked) {
result->addAction(tr::lng_group_invite_context_delete(tr::now), [=] {
delegate()->peerListShowBox(DeleteLinkBox(_peer, _admin, link));
delegate()->peerListUiShow()->showBox(
DeleteLinkBox(_peer, _admin, link));
}, &st::menuIconDelete);
} else {
result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] {
CopyInviteLink(delegate()->peerListUiShow(), link);
}, &st::menuIconCopy);
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
ShareInviteLinkBox(_peer, link));
}, &st::menuIconShare);
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
}, &st::menuIconQrCode);
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
delegate()->peerListShowBox(EditLinkBox(_peer, data));
delegate()->peerListUiShow()->showBox(EditLinkBox(_peer, data));
}, &st::menuIconEdit);
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
delegate()->peerListShowBox(RevokeLinkBox(_peer, _admin, link));
delegate()->peerListUiShow()->showBox(
RevokeLinkBox(_peer, _admin, link));
}, &st::menuIconRemove);
}
return result;
@ -799,7 +801,7 @@ void AdminsController::loadMoreRows() {
}
void AdminsController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox(
delegate()->peerListUiShow()->showBox(
Box(ManageInviteLinksBox, _peer, row->peer()->asUser(), 0, 0));
}

View file

@ -115,10 +115,6 @@ public:
void peerListFinishSelectedRowsBunch() override;
void peerListSetDescription(
object_ptr<Ui::FlatLabel> description) override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void peerListSetRowChecked(
not_null<PeerListRow*> row,
@ -183,14 +179,6 @@ void InactiveDelegate::peerListSetDescription(
description.destroy();
}
void InactiveDelegate::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
}
void InactiveDelegate::peerListHideLayer() {
}
std::shared_ptr<Main::SessionShow> InactiveDelegate::peerListUiShow() {
Unexpected("...InactiveDelegate::peerListUiShow");
}

View file

@ -1975,14 +1975,6 @@ void Members::peerListSetDescription(
description.destroy();
}
void Members::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
}
void Members::peerListHideLayer() {
}
std::shared_ptr<Main::SessionShow> Members::peerListUiShow() {
Unexpected("...Members::peerListUiShow");
}

View file

@ -88,10 +88,6 @@ private:
void peerListFinishSelectedRowsBunch() override;
void peerListSetDescription(
object_ptr<Ui::FlatLabel> description) override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void setupAddMember(not_null<GroupCall*> call);

View file

@ -281,16 +281,6 @@ void InnerWidget::peerListSetDescription(
description.destroy();
}
void InnerWidget::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void InnerWidget::peerListHideLayer() {
_show->hideLayer();
}
std::shared_ptr<Main::SessionShow> InnerWidget::peerListUiShow() {
return _show;
}

View file

@ -64,10 +64,6 @@ private:
void peerListFinishSelectedRowsBunch() override;
void peerListSetDescription(
object_ptr<Ui::FlatLabel> description) override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
object_ptr<ListWidget> setupList(

View file

@ -51,10 +51,6 @@ public:
void peerListFinishSelectedRowsBunch() override;
void peerListSetDescription(
object_ptr<Ui::FlatLabel> description) override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
};
@ -92,14 +88,6 @@ void ListDelegate::peerListSetDescription(
description.destroy();
}
void ListDelegate::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
}
void ListDelegate::peerListHideLayer() {
}
std::shared_ptr<Main::SessionShow> ListDelegate::peerListUiShow() {
Unexpected("...ListDelegate::peerListUiShow");
}

View file

@ -459,16 +459,6 @@ void Members::peerListAddSelectedRowInBunch(not_null<PeerListRow*> row) {
void Members::peerListFinishSelectedRowsBunch() {
}
void Members::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show->showBox(std::move(content), options);
}
void Members::peerListHideLayer() {
_show->hideLayer();
}
std::shared_ptr<Main::SessionShow> Members::peerListUiShow() {
return _show;
}

View file

@ -78,10 +78,6 @@ private:
void peerListFinishSelectedRowsBunch() override;
void peerListSetDescription(
object_ptr<Ui::FlatLabel> description) override;
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
//void peerListAppendRow(