mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Removed Ui::show from window peer menu functions.
This commit is contained in:
parent
4fff812910
commit
fd528aa1b7
5 changed files with 168 additions and 102 deletions
|
@ -535,13 +535,13 @@ void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
||||||
&st::infoIconEdit);
|
&st::infoIconEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsFiller::addDeleteContactAction(
|
void ActionsFiller::addDeleteContactAction(not_null<UserData*> user) {
|
||||||
not_null<UserData*> user) {
|
const auto controller = _controller->parentController();
|
||||||
AddActionButton(
|
AddActionButton(
|
||||||
_wrap,
|
_wrap,
|
||||||
tr::lng_info_delete_contact(),
|
tr::lng_info_delete_contact(),
|
||||||
IsContactValue(user),
|
IsContactValue(user),
|
||||||
[user] { Window::PeerMenuDeleteContact(user); },
|
[=] { Window::PeerMenuDeleteContact(controller, user); },
|
||||||
&st::infoIconDelete);
|
&st::infoIconDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,13 +668,15 @@ void ActionsFiller::addBlockAction(not_null<UserData*> user) {
|
||||||
st::infoBlockButton);
|
st::infoBlockButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsFiller::addLeaveChannelAction(
|
void ActionsFiller::addLeaveChannelAction(not_null<ChannelData*> channel) {
|
||||||
not_null<ChannelData*> channel) {
|
Expects(_controller->parentController());
|
||||||
AddActionButton(
|
AddActionButton(
|
||||||
_wrap,
|
_wrap,
|
||||||
tr::lng_profile_leave_channel(),
|
tr::lng_profile_leave_channel(),
|
||||||
AmInChannelValue(channel),
|
AmInChannelValue(channel),
|
||||||
Window::DeleteAndLeaveHandler(channel),
|
Window::DeleteAndLeaveHandler(
|
||||||
|
_controller->parentController(),
|
||||||
|
channel),
|
||||||
&st::infoIconLeave);
|
&st::infoIconLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,7 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) {
|
||||||
return _session->session().data().chatsFilters().chatsList(id);
|
return _session->session().data().chatsFilters().chatsList(id);
|
||||||
};
|
};
|
||||||
Window::MenuAddMarkAsReadChatListAction(
|
Window::MenuAddMarkAsReadChatListAction(
|
||||||
|
_session,
|
||||||
std::move(filteredChats),
|
std::move(filteredChats),
|
||||||
addAction);
|
addAction);
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ void AddUnreadBadge(
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::SettingsButton> MakeAccountButton(
|
[[nodiscard]] object_ptr<Ui::SettingsButton> MakeAccountButton(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> window,
|
||||||
not_null<Main::Account*> account,
|
not_null<Main::Account*> account,
|
||||||
Fn<void()> callback) {
|
Fn<void()> callback) {
|
||||||
const auto active = (account == &Core::App().activeAccount());
|
const auto active = (account == &Core::App().activeAccount());
|
||||||
|
@ -306,7 +307,7 @@ void AddUnreadBadge(
|
||||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
raw,
|
raw,
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
MenuAddMarkAsReadAllChatsAction(&session->data(), addAction);
|
MenuAddMarkAsReadAllChatsAction(window, addAction);
|
||||||
state->menu->popup(QCursor::pos());
|
state->menu->popup(QCursor::pos());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -325,12 +326,14 @@ void AddUnreadBadge(
|
||||||
close();
|
close();
|
||||||
Core::App().logoutWithChecks(&session->account());
|
Core::App().logoutWithChecks(&session->account());
|
||||||
};
|
};
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
window->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_sure_logout(),
|
.text = tr::lng_sure_logout(),
|
||||||
.confirmed = crl::guard(session, callback),
|
.confirmed = crl::guard(session, callback),
|
||||||
.confirmText = tr::lng_settings_logout(),
|
.confirmText = tr::lng_settings_logout(),
|
||||||
.confirmStyle = &st::attentionBoxButton,
|
.confirmStyle = &st::attentionBoxButton,
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}, &st::menuIconLeave);
|
}, &st::menuIconLeave);
|
||||||
state->menu->popup(QCursor::pos());
|
state->menu->popup(QCursor::pos());
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
|
@ -725,6 +728,7 @@ void MainMenu::setupArchive() {
|
||||||
&st::menuIconFromMainMenu);
|
&st::menuIconFromMainMenu);
|
||||||
|
|
||||||
MenuAddMarkAsReadChatListAction(
|
MenuAddMarkAsReadChatListAction(
|
||||||
|
controller,
|
||||||
[f = folder()] { return f->chatsList(); },
|
[f = folder()] { return f->chatsList(); },
|
||||||
addAction);
|
addAction);
|
||||||
|
|
||||||
|
@ -861,7 +865,7 @@ void MainMenu::rebuildAccounts() {
|
||||||
if (!account->sessionExists()) {
|
if (!account->sessionExists()) {
|
||||||
button = nullptr;
|
button = nullptr;
|
||||||
} else if (!button) {
|
} else if (!button) {
|
||||||
button.reset(inner->add(MakeAccountButton(inner, account, [=] {
|
auto callback = [=] {
|
||||||
if (_reordering) {
|
if (_reordering) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -879,7 +883,12 @@ void MainMenu::rebuildAccounts() {
|
||||||
st::defaultRippleAnimation.hideDuration,
|
st::defaultRippleAnimation.hideDuration,
|
||||||
account,
|
account,
|
||||||
std::move(activate));
|
std::move(activate));
|
||||||
})));
|
};
|
||||||
|
button.reset(inner->add(MakeAccountButton(
|
||||||
|
inner,
|
||||||
|
_controller,
|
||||||
|
account,
|
||||||
|
std::move(callback))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inner->resizeToWidth(_accounts->width());
|
inner->resizeToWidth(_accounts->width());
|
||||||
|
|
|
@ -77,7 +77,7 @@ const char kOptionViewProfileInChatsListContextMenu[] =
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kArchivedToastDuration = crl::time(5000);
|
constexpr auto kArchivedToastDuration = crl::time(5000);
|
||||||
constexpr auto kMaxUnreadWithoutConfirmation = 10000;
|
constexpr auto kMaxUnreadWithoutConfirmation = 1000;
|
||||||
|
|
||||||
base::options::toggle ViewProfileInChatsListContextMenu({
|
base::options::toggle ViewProfileInChatsListContextMenu({
|
||||||
.id = kOptionViewProfileInChatsListContextMenu,
|
.id = kOptionViewProfileInChatsListContextMenu,
|
||||||
|
@ -195,7 +195,10 @@ void AddChatMembers(
|
||||||
AddParticipantsBoxController::Start(navigation, chat);
|
AddParticipantsBoxController::Start(navigation, chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PinnedLimitReached(Dialogs::Key key, FilterId filterId) {
|
bool PinnedLimitReached(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
Dialogs::Key key,
|
||||||
|
FilterId filterId) {
|
||||||
Expects(filterId != 0 || key.entry()->folderKnown());
|
Expects(filterId != 0 || key.entry()->folderKnown());
|
||||||
|
|
||||||
const auto entry = key.entry();
|
const auto entry = key.entry();
|
||||||
|
@ -219,7 +222,9 @@ bool PinnedLimitReached(Dialogs::Key key, FilterId filterId) {
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count,
|
lt_count,
|
||||||
pinnedMax);
|
pinnedMax);
|
||||||
Ui::show(Ui::MakeInformBox(errorText));
|
controller->show(
|
||||||
|
Ui::MakeInformBox(errorText),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +237,7 @@ void TogglePinnedDialog(
|
||||||
}
|
}
|
||||||
const auto owner = &key.entry()->owner();
|
const auto owner = &key.entry()->owner();
|
||||||
const auto isPinned = !key.entry()->isPinnedDialog(0);
|
const auto isPinned = !key.entry()->isPinnedDialog(0);
|
||||||
if (isPinned && PinnedLimitReached(key, 0)) {
|
if (isPinned && PinnedLimitReached(controller, key, 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +282,7 @@ void TogglePinnedDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto isPinned = !key.entry()->isPinnedDialog(filterId);
|
const auto isPinned = !key.entry()->isPinnedDialog(filterId);
|
||||||
if (isPinned && PinnedLimitReached(key, filterId)) {
|
if (isPinned && PinnedLimitReached(controller, key, filterId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +353,7 @@ void Filler::addToggleMute() {
|
||||||
if (_peer->isSelf()) {
|
if (_peer->isSelf()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PeerMenuAddMuteAction(_peer, _addAction);
|
PeerMenuAddMuteAction(_controller, _peer, _addAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addSupportInfo() {
|
void Filler::addSupportInfo() {
|
||||||
|
@ -463,7 +468,7 @@ void Filler::addClearHistory() {
|
||||||
}
|
}
|
||||||
_addAction(
|
_addAction(
|
||||||
tr::lng_profile_clear_history(tr::now),
|
tr::lng_profile_clear_history(tr::now),
|
||||||
ClearHistoryHandler(_peer),
|
ClearHistoryHandler(_controller, _peer),
|
||||||
&st::menuIconClear);
|
&st::menuIconClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +480,7 @@ void Filler::addDeleteChat() {
|
||||||
(_peer->isUser()
|
(_peer->isUser()
|
||||||
? tr::lng_profile_delete_conversation(tr::now)
|
? tr::lng_profile_delete_conversation(tr::now)
|
||||||
: tr::lng_profile_clear_and_exit(tr::now)),
|
: tr::lng_profile_clear_and_exit(tr::now)),
|
||||||
DeleteAndLeaveHandler(_peer),
|
DeleteAndLeaveHandler(_controller, _peer),
|
||||||
&st::menuIconDelete);
|
&st::menuIconDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +493,7 @@ void Filler::addLeaveChat() {
|
||||||
(_peer->isMegagroup()
|
(_peer->isMegagroup()
|
||||||
? tr::lng_profile_leave_group(tr::now)
|
? tr::lng_profile_leave_group(tr::now)
|
||||||
: tr::lng_profile_leave_channel(tr::now)),
|
: tr::lng_profile_leave_channel(tr::now)),
|
||||||
DeleteAndLeaveHandler(_peer),
|
DeleteAndLeaveHandler(_controller, _peer),
|
||||||
&st::menuIconLeave);
|
&st::menuIconLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +669,7 @@ void Filler::addDeleteContact() {
|
||||||
}
|
}
|
||||||
_addAction(
|
_addAction(
|
||||||
tr::lng_info_delete_contact(tr::now),
|
tr::lng_info_delete_contact(tr::now),
|
||||||
[=] { PeerMenuDeleteContact(user); },
|
[=] { PeerMenuDeleteContact(_controller, user); },
|
||||||
&st::menuIconDelete);
|
&st::menuIconDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,6 +837,7 @@ void Filler::fillArchiveActions() {
|
||||||
}, &st::menuIconToMainMenu);
|
}, &st::menuIconToMainMenu);
|
||||||
|
|
||||||
MenuAddMarkAsReadChatListAction(
|
MenuAddMarkAsReadChatListAction(
|
||||||
|
controller,
|
||||||
[folder = _folder] { return folder->chatsList(); },
|
[folder = _folder] { return folder->chatsList(); },
|
||||||
_addAction);
|
_addAction);
|
||||||
}
|
}
|
||||||
|
@ -842,33 +848,38 @@ void PeerMenuExportChat(not_null<PeerData*> peer) {
|
||||||
Core::App().exportManager().start(peer);
|
Core::App().exportManager().start(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerMenuDeleteContact(not_null<UserData*> user) {
|
void PeerMenuDeleteContact(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<UserData*> user) {
|
||||||
const auto text = tr::lng_sure_delete_contact(
|
const auto text = tr::lng_sure_delete_contact(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_contact,
|
lt_contact,
|
||||||
user->name);
|
user->name);
|
||||||
const auto deleteSure = [=] {
|
const auto deleteSure = [=](Fn<void()> &&close) {
|
||||||
Ui::hideLayer();
|
close();
|
||||||
user->session().api().request(MTPcontacts_DeleteContacts(
|
user->session().api().request(MTPcontacts_DeleteContacts(
|
||||||
MTP_vector<MTPInputUser>(1, user->inputUser)
|
MTP_vector<MTPInputUser>(1, user->inputUser)
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
user->session().api().applyUpdates(result);
|
user->session().api().applyUpdates(result);
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
controller->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
.text = text,
|
.text = text,
|
||||||
.confirmed = deleteSure,
|
.confirmed = deleteSure,
|
||||||
.confirmText = tr::lng_box_delete(),
|
.confirmText = tr::lng_box_delete(),
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerMenuShareContactBox(
|
void PeerMenuShareContactBox(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
not_null<UserData*> user) {
|
not_null<UserData*> user) {
|
||||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
// There is no async to make weak from controller.
|
||||||
|
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||||
auto callback = [=](not_null<PeerData*> peer) {
|
auto callback = [=](not_null<PeerData*> peer) {
|
||||||
if (!peer->canWrite()) {
|
if (!peer->canWrite()) {
|
||||||
Ui::show(
|
navigation->parentController()->show(
|
||||||
Ui::MakeInformBox(tr::lng_forward_share_cant()),
|
Ui::MakeInformBox(tr::lng_forward_share_cant()),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
return;
|
return;
|
||||||
|
@ -876,7 +887,9 @@ void PeerMenuShareContactBox(
|
||||||
auto action = Api::SendAction(peer->owner().history(peer));
|
auto action = Api::SendAction(peer->owner().history(peer));
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
user->session().api().shareContact(user, action);
|
user->session().api().shareContact(user, action);
|
||||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
Ui::Toast::Show(
|
||||||
|
navigation->parentController()->widget()->bodyWidget(),
|
||||||
|
tr::lng_share_done(tr::now));
|
||||||
if (auto strong = *weak) {
|
if (auto strong = *weak) {
|
||||||
strong->closeBox();
|
strong->closeBox();
|
||||||
}
|
}
|
||||||
|
@ -885,13 +898,13 @@ void PeerMenuShareContactBox(
|
||||||
auto recipient = peer->isUser()
|
auto recipient = peer->isUser()
|
||||||
? peer->name
|
? peer->name
|
||||||
: '\xAB' + peer->name + '\xBB';
|
: '\xAB' + peer->name + '\xBB';
|
||||||
Ui::show(
|
navigation->parentController()->show(
|
||||||
Ui::MakeConfirmBox({
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_forward_share_contact(
|
.text = tr::lng_forward_share_contact(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_recipient,
|
lt_recipient,
|
||||||
recipient),
|
recipient),
|
||||||
.confirmed = [peer, user, navigation] {
|
.confirmed = [peer, user, navigation](Fn<void()> &&close) {
|
||||||
const auto history = peer->owner().history(peer);
|
const auto history = peer->owner().history(peer);
|
||||||
navigation->showPeerHistory(
|
navigation->showPeerHistory(
|
||||||
history,
|
history,
|
||||||
|
@ -900,12 +913,14 @@ void PeerMenuShareContactBox(
|
||||||
auto action = Api::SendAction(history);
|
auto action = Api::SendAction(history);
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
user->session().api().shareContact(user, action);
|
user->session().api().shareContact(user, action);
|
||||||
|
close();
|
||||||
},
|
},
|
||||||
.confirmText = tr::lng_forward_send(),
|
.confirmText = tr::lng_forward_send(),
|
||||||
}),
|
}),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
};
|
};
|
||||||
*weak = Ui::show(Box<PeerListBox>(
|
*weak = navigation->parentController()->show(
|
||||||
|
Box<PeerListBox>(
|
||||||
std::make_unique<ChooseRecipientBoxController>(
|
std::make_unique<ChooseRecipientBoxController>(
|
||||||
&navigation->session(),
|
&navigation->session(),
|
||||||
std::move(callback)),
|
std::move(callback)),
|
||||||
|
@ -913,7 +928,8 @@ void PeerMenuShareContactBox(
|
||||||
box->addButton(tr::lng_cancel(), [=] {
|
box->addButton(tr::lng_cancel(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerMenuCreatePoll(
|
void PeerMenuCreatePoll(
|
||||||
|
@ -928,12 +944,13 @@ void PeerMenuCreatePoll(
|
||||||
chosen &= ~PollData::Flag::PublicVotes;
|
chosen &= ~PollData::Flag::PublicVotes;
|
||||||
disabled |= PollData::Flag::PublicVotes;
|
disabled |= PollData::Flag::PublicVotes;
|
||||||
}
|
}
|
||||||
const auto box = Ui::show(Box<CreatePollBox>(
|
auto box = Box<CreatePollBox>(
|
||||||
controller,
|
controller,
|
||||||
chosen,
|
chosen,
|
||||||
disabled,
|
disabled,
|
||||||
sendType,
|
sendType,
|
||||||
sendMenuType));
|
sendMenuType);
|
||||||
|
const auto weak = Ui::MakeWeak(box.data());
|
||||||
const auto lock = box->lifetime().make_state<bool>(false);
|
const auto lock = box->lifetime().make_state<bool>(false);
|
||||||
box->submitRequests(
|
box->submitRequests(
|
||||||
) | rpl::start_with_next([=](const CreatePollBox::Result &result) {
|
) | rpl::start_with_next([=](const CreatePollBox::Result &result) {
|
||||||
|
@ -949,13 +966,14 @@ void PeerMenuCreatePoll(
|
||||||
action.clearDraft = localDraft->textWithTags.text.isEmpty();
|
action.clearDraft = localDraft->textWithTags.text.isEmpty();
|
||||||
}
|
}
|
||||||
const auto api = &peer->session().api();
|
const auto api = &peer->session().api();
|
||||||
api->polls().create(result.poll, action, crl::guard(box, [=] {
|
api->polls().create(result.poll, action, crl::guard(weak, [=] {
|
||||||
box->closeBox();
|
weak->closeBox();
|
||||||
}), crl::guard(box, [=](const MTP::Error &error) {
|
}), crl::guard(weak, [=](const MTP::Error &error) {
|
||||||
*lock = false;
|
*lock = false;
|
||||||
box->submitFailed(tr::lng_attach_failed(tr::now));
|
weak->submitFailed(tr::lng_attach_failed(tr::now));
|
||||||
}));
|
}));
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
controller->show(std::move(box), Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerMenuBlockUserBox(
|
void PeerMenuBlockUserBox(
|
||||||
|
@ -1098,7 +1116,7 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
Data::ForwardDraft &&draft,
|
Data::ForwardDraft &&draft,
|
||||||
FnMut<void()> &&successCallback) {
|
FnMut<void()> &&successCallback) {
|
||||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||||
auto callback = [
|
auto callback = [
|
||||||
draft = std::move(draft),
|
draft = std::move(draft),
|
||||||
callback = std::move(successCallback),
|
callback = std::move(successCallback),
|
||||||
|
@ -1114,9 +1132,13 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
auto action = Api::SendAction(peer->owner().history(peer));
|
auto action = Api::SendAction(peer->owner().history(peer));
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
action.generateLocal = false;
|
action.generateLocal = false;
|
||||||
api->forwardMessages(std::move(resolved), action, [] {
|
const auto weakContent = Ui::MakeWeak(content);
|
||||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
api->forwardMessages(
|
||||||
});
|
std::move(resolved),
|
||||||
|
action,
|
||||||
|
crl::guard(weakContent, [w = weakContent] {
|
||||||
|
Ui::Toast::Show(w, tr::lng_share_done(tr::now));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
} else if (!content->setForwardDraft(peer->id, std::move(draft))) {
|
} else if (!content->setForwardDraft(peer->id, std::move(draft))) {
|
||||||
return;
|
return;
|
||||||
|
@ -1133,7 +1155,7 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
*weak = Ui::show(Box<PeerListBox>(
|
*weak = navigation->parentController()->show(Box<PeerListBox>(
|
||||||
std::make_unique<ChooseRecipientBoxController>(
|
std::make_unique<ChooseRecipientBoxController>(
|
||||||
&navigation->session(),
|
&navigation->session(),
|
||||||
std::move(callback)),
|
std::move(callback)),
|
||||||
|
@ -1167,7 +1189,8 @@ QPointer<Ui::BoxContent> ShowSendNowMessagesBox(
|
||||||
TextWithTags());
|
TextWithTags());
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
.text = { error },
|
navigation->parentController()->widget()->bodyWidget(),
|
||||||
|
{ error },
|
||||||
});
|
});
|
||||||
return { nullptr };
|
return { nullptr };
|
||||||
}
|
}
|
||||||
|
@ -1196,7 +1219,7 @@ QPointer<Ui::BoxContent> ShowSendNowMessagesBox(
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Ui::show(
|
return navigation->parentController()->show(
|
||||||
Ui::MakeConfirmBox({
|
Ui::MakeConfirmBox({
|
||||||
.text = text,
|
.text = text,
|
||||||
.confirmed = std::move(done),
|
.confirmed = std::move(done),
|
||||||
|
@ -1211,7 +1234,7 @@ void PeerMenuAddChannelMembers(
|
||||||
if (!channel->isMegagroup()
|
if (!channel->isMegagroup()
|
||||||
&& (channel->membersCount()
|
&& (channel->membersCount()
|
||||||
>= channel->session().serverConfig().chatSizeMax)) {
|
>= channel->session().serverConfig().chatSizeMax)) {
|
||||||
Ui::show(
|
navigation->parentController()->show(
|
||||||
Box<MaxInviteBox>(channel),
|
Box<MaxInviteBox>(channel),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
return;
|
return;
|
||||||
|
@ -1248,12 +1271,14 @@ void ToggleMessagePinned(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pin) {
|
if (pin) {
|
||||||
Ui::show(Box<PinMessageBox>(item->history()->peer, item->id));
|
navigation->parentController()->show(
|
||||||
|
Box<PinMessageBox>(item->history()->peer, item->id),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
} else {
|
} else {
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
const auto session = &peer->session();
|
const auto session = &peer->session();
|
||||||
const auto callback = crl::guard(session, [=] {
|
const auto callback = crl::guard(session, [=](Fn<void()> &&close) {
|
||||||
Ui::hideLayer();
|
close();
|
||||||
session->api().request(MTPmessages_UpdatePinnedMessage(
|
session->api().request(MTPmessages_UpdatePinnedMessage(
|
||||||
MTP_flags(MTPmessages_UpdatePinnedMessage::Flag::f_unpin),
|
MTP_flags(MTPmessages_UpdatePinnedMessage::Flag::f_unpin),
|
||||||
peer->input,
|
peer->input,
|
||||||
|
@ -1262,11 +1287,13 @@ void ToggleMessagePinned(
|
||||||
session->api().applyUpdates(result);
|
session->api().applyUpdates(result);
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
navigation->parentController()->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_pinned_unpin_sure(),
|
.text = tr::lng_pinned_unpin_sure(),
|
||||||
.confirmed = callback,
|
.confirmed = callback,
|
||||||
.confirmText = tr::lng_pinned_unpin(),
|
.confirmText = tr::lng_pinned_unpin(),
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,8 +1301,8 @@ void HidePinnedBar(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> onHidden) {
|
Fn<void()> onHidden) {
|
||||||
const auto callback = crl::guard(navigation, [=] {
|
const auto callback = crl::guard(navigation, [=](Fn<void()> &&close) {
|
||||||
Ui::hideLayer();
|
close();
|
||||||
auto &session = peer->session();
|
auto &session = peer->session();
|
||||||
const auto migrated = peer->migrateFrom();
|
const auto migrated = peer->migrateFrom();
|
||||||
const auto top = Data::ResolveTopPinnedId(peer, migrated);
|
const auto top = Data::ResolveTopPinnedId(peer, migrated);
|
||||||
|
@ -1294,18 +1321,20 @@ void HidePinnedBar(
|
||||||
session.api().requestFullPeer(peer);
|
session.api().requestFullPeer(peer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
navigation->parentController()->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_pinned_hide_all_sure(),
|
.text = tr::lng_pinned_hide_all_sure(),
|
||||||
.confirmed = callback,
|
.confirmed = callback,
|
||||||
.confirmText = tr::lng_pinned_hide_all_hide(),
|
.confirmText = tr::lng_pinned_hide_all_hide(),
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnpinAllMessages(
|
void UnpinAllMessages(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
not_null<History*> history) {
|
not_null<History*> history) {
|
||||||
const auto callback = crl::guard(navigation, [=] {
|
const auto callback = crl::guard(navigation, [=](Fn<void()> &&close) {
|
||||||
Ui::hideLayer();
|
close();
|
||||||
const auto api = &history->session().api();
|
const auto api = &history->session().api();
|
||||||
const auto sendRequest = [=](auto self) -> void {
|
const auto sendRequest = [=](auto self) -> void {
|
||||||
api->request(MTPmessages_UnpinAllMessages(
|
api->request(MTPmessages_UnpinAllMessages(
|
||||||
|
@ -1322,16 +1351,20 @@ void UnpinAllMessages(
|
||||||
};
|
};
|
||||||
sendRequest(sendRequest);
|
sendRequest(sendRequest);
|
||||||
});
|
});
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
navigation->parentController()->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
.text = tr::lng_pinned_unpin_all_sure(),
|
.text = tr::lng_pinned_unpin_all_sure(),
|
||||||
.confirmed = callback,
|
.confirmed = callback,
|
||||||
.confirmText = tr::lng_pinned_unpin(),
|
.confirmText = tr::lng_pinned_unpin(),
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerMenuAddMuteAction(
|
void PeerMenuAddMuteAction(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerMenuCallback &addAction) {
|
const PeerMenuCallback &addAction) {
|
||||||
|
// There is no async to make weak from controller.
|
||||||
peer->owner().requestNotifySettings(peer);
|
peer->owner().requestNotifySettings(peer);
|
||||||
const auto muteText = [](bool isUnmuted) {
|
const auto muteText = [](bool isUnmuted) {
|
||||||
return isUnmuted
|
return isUnmuted
|
||||||
|
@ -1340,7 +1373,9 @@ void PeerMenuAddMuteAction(
|
||||||
};
|
};
|
||||||
const auto muteAction = addAction(QString("-"), [=] {
|
const auto muteAction = addAction(QString("-"), [=] {
|
||||||
if (!peer->owner().notifyIsMuted(peer)) {
|
if (!peer->owner().notifyIsMuted(peer)) {
|
||||||
Ui::show(Box<MuteSettingsBox>(peer));
|
controller->show(
|
||||||
|
Box<MuteSettingsBox>(peer),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
} else {
|
} else {
|
||||||
peer->owner().updateNotifySettings(peer, 0);
|
peer->owner().updateNotifySettings(peer, 0);
|
||||||
}
|
}
|
||||||
|
@ -1355,9 +1390,10 @@ void PeerMenuAddMuteAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuAddMarkAsReadAllChatsAction(
|
void MenuAddMarkAsReadAllChatsAction(
|
||||||
not_null<Data::Session*> data,
|
not_null<Window::SessionController*> controller,
|
||||||
const PeerMenuCallback &addAction) {
|
const PeerMenuCallback &addAction) {
|
||||||
auto callback = [owner = data] {
|
// There is no async to make weak from controller.
|
||||||
|
auto callback = [=, owner = &controller->session().data()] {
|
||||||
auto boxCallback = [=](Fn<void()> &&close) {
|
auto boxCallback = [=](Fn<void()> &&close) {
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
@ -1366,10 +1402,12 @@ void MenuAddMarkAsReadAllChatsAction(
|
||||||
MarkAsReadChatList(folder->chatsList());
|
MarkAsReadChatList(folder->chatsList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
controller->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
tr::lng_context_mark_read_all_sure(),
|
tr::lng_context_mark_read_all_sure(),
|
||||||
std::move(boxCallback)
|
std::move(boxCallback)
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
};
|
};
|
||||||
addAction(
|
addAction(
|
||||||
tr::lng_context_mark_read_all(tr::now),
|
tr::lng_context_mark_read_all(tr::now),
|
||||||
|
@ -1378,8 +1416,10 @@ void MenuAddMarkAsReadAllChatsAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuAddMarkAsReadChatListAction(
|
void MenuAddMarkAsReadChatListAction(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
Fn<not_null<Dialogs::MainList*>()> &&list,
|
Fn<not_null<Dialogs::MainList*>()> &&list,
|
||||||
const PeerMenuCallback &addAction) {
|
const PeerMenuCallback &addAction) {
|
||||||
|
// There is no async to make weak from controller.
|
||||||
const auto unreadState = list()->unreadState();
|
const auto unreadState = list()->unreadState();
|
||||||
if (unreadState.empty()) {
|
if (unreadState.empty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1391,10 +1431,12 @@ void MenuAddMarkAsReadChatListAction(
|
||||||
MarkAsReadChatList(list());
|
MarkAsReadChatList(list());
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
controller->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
tr::lng_context_mark_read_sure(),
|
tr::lng_context_mark_read_sure(),
|
||||||
std::move(boxCallback)
|
std::move(boxCallback)
|
||||||
}));
|
}),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
} else {
|
} else {
|
||||||
MarkAsReadChatList(list());
|
MarkAsReadChatList(list());
|
||||||
}
|
}
|
||||||
|
@ -1424,17 +1466,21 @@ void ToggleHistoryArchived(not_null<History*> history, bool archived) {
|
||||||
callback);
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer) {
|
Fn<void()> ClearHistoryHandler(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer) {
|
||||||
return [=] {
|
return [=] {
|
||||||
Ui::show(
|
controller->show(
|
||||||
Box<DeleteMessagesBox>(peer, true),
|
Box<DeleteMessagesBox>(peer, true),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Fn<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer) {
|
Fn<void()> DeleteAndLeaveHandler(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer) {
|
||||||
return [=] {
|
return [=] {
|
||||||
Ui::show(
|
controller->show(
|
||||||
Box<DeleteMessagesBox>(peer, false),
|
Box<DeleteMessagesBox>(peer, false),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,19 +49,23 @@ void FillDialogsEntryMenu(
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
void PeerMenuAddMuteAction(
|
void PeerMenuAddMuteAction(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
void MenuAddMarkAsReadAllChatsAction(
|
void MenuAddMarkAsReadAllChatsAction(
|
||||||
not_null<Data::Session*> data,
|
not_null<Window::SessionController*> controller,
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
void MenuAddMarkAsReadChatListAction(
|
void MenuAddMarkAsReadChatListAction(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
Fn<not_null<Dialogs::MainList*>()> &&list,
|
Fn<not_null<Dialogs::MainList*>()> &&list,
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
void PeerMenuExportChat(not_null<PeerData*> peer);
|
void PeerMenuExportChat(not_null<PeerData*> peer);
|
||||||
void PeerMenuDeleteContact(not_null<UserData*> user);
|
void PeerMenuDeleteContact(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<UserData*> user);
|
||||||
void PeerMenuShareContactBox(
|
void PeerMenuShareContactBox(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
not_null<UserData*> user);
|
not_null<UserData*> user);
|
||||||
|
@ -96,8 +100,12 @@ void BlockSenderFromRepliesBox(
|
||||||
FullMsgId id);
|
FullMsgId id);
|
||||||
|
|
||||||
void ToggleHistoryArchived(not_null<History*> history, bool archived);
|
void ToggleHistoryArchived(not_null<History*> history, bool archived);
|
||||||
Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer);
|
Fn<void()> ClearHistoryHandler(
|
||||||
Fn<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer);
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer);
|
||||||
|
Fn<void()> DeleteAndLeaveHandler(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer);
|
||||||
|
|
||||||
QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
|
Loading…
Add table
Reference in a new issue