diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 9179d46d7..10c997f85 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1017,15 +1017,14 @@ void ParticipantsBoxController::addNewItem() { box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); }; - _addBox = Ui::show( + _addBox = showBox( Box( std::make_unique( _peer, _role, adminDone, restrictedDone), - initBox), - Ui::LayerOption::KeepOther); + initBox)); } void ParticipantsBoxController::addNewParticipants() { @@ -1052,7 +1051,7 @@ void ParticipantsBoxController::addNewParticipants() { channel, { already.begin(), already.end() }); } else { - Ui::show(Box(channel), Ui::LayerOption::KeepOther); + showBox(Box(channel)); } } @@ -1204,6 +1203,13 @@ void ParticipantsBoxController::prepare() { delegate()->peerListRefreshRows(); } +QPointer ParticipantsBoxController::showBox( + object_ptr box) const { + const auto weak = Ui::MakeWeak(box.data()); + delegate()->peerListShowBox(std::move(box), Ui::LayerOption::KeepOther); + return weak; +} + void ParticipantsBoxController::prepareChatRows(not_null chat) { if (_role == Role::Profile || _role == Role::Members) { _onlineSorter = std::make_unique( @@ -1615,7 +1621,7 @@ void ParticipantsBoxController::showAdmin(not_null user) { }); box->setSaveCallback(SaveAdminCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); + _editParticipantBox = showBox(std::move(box)); } void ParticipantsBoxController::editAdminDone( @@ -1669,7 +1675,7 @@ void ParticipantsBoxController::showRestricted(not_null user) { box->setSaveCallback( SaveRestrictedCallback(_peer, user, done, fail)); } - _editParticipantBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); + _editParticipantBox = showBox(std::move(box)); } void ParticipantsBoxController::editRestrictedDone( @@ -1717,15 +1723,14 @@ void ParticipantsBoxController::kickParticipant(not_null participant) tr::now, lt_user, user ? user->firstName : participant->name); - _editBox = Ui::show( + _editBox = showBox( Ui::MakeConfirmBox({ .text = text, .confirmed = crl::guard(this, [=] { kickParticipantSure(participant); }), .confirmText = tr::lng_box_remove(), - }), - Ui::LayerOption::KeepOther); + })); } void ParticipantsBoxController::unkickParticipant(not_null user) { @@ -1762,7 +1767,7 @@ void ParticipantsBoxController::kickParticipantSure( } void ParticipantsBoxController::removeAdmin(not_null user) { - _editBox = Ui::show( + _editBox = showBox( Ui::MakeConfirmBox({ .text = tr::lng_profile_sure_remove_admin( tr::now, @@ -1770,8 +1775,7 @@ void ParticipantsBoxController::removeAdmin(not_null user) { user->firstName), .confirmed = crl::guard(this, [=] { removeAdminSure(user); }), .confirmText = tr::lng_box_remove(), - }), - Ui::LayerOption::KeepOther); + })); } void ParticipantsBoxController::removeAdminSure(not_null user) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index cfbb5fbf3..3d3db377a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -221,6 +221,8 @@ private: Role role, not_null additional); + QPointer showBox(object_ptr box) const; + void prepareChatRows(not_null chat); void rebuildChatRows(not_null chat); void rebuildChatParticipants(not_null chat);