From 01bfa467295684d6ca0943024ca848bddf7a1484 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 18 Apr 2024 04:02:40 +0300 Subject: [PATCH] Fixed display of default box for message schedule in correspond window. --- Telegram/SourceFiles/boxes/sticker_set_box.cpp | 2 +- Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp | 2 +- Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp | 2 +- Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp | 2 +- .../view/controls/history_view_compose_controls.cpp | 2 +- Telegram/SourceFiles/inline_bots/inline_results_inner.cpp | 2 +- Telegram/SourceFiles/menu/menu_send.cpp | 7 +++---- Telegram/SourceFiles/menu/menu_send.h | 3 ++- Telegram/SourceFiles/window/window_peer_menu.cpp | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 88163356c..ac4555120 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -1032,7 +1032,7 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) { _menu.get(), type, SendMenu::DefaultSilentCallback(sendSelected), - SendMenu::DefaultScheduleCallback(this, type, sendSelected), + SendMenu::DefaultScheduleCallback(_show, type, sendSelected), SendMenu::DefaultWhenOnlineCallback(sendSelected)); const auto show = _show; diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 9bc6e88f2..20f32f6e8 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -1379,7 +1379,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) { _menu, type, SendMenu::DefaultSilentCallback(send), - SendMenu::DefaultScheduleCallback(this, type, send), + SendMenu::DefaultScheduleCallback(_show, type, send), SendMenu::DefaultWhenOnlineCallback(send)); if (!_menu->empty()) { diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 13cfda86d..72794de39 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -394,7 +394,7 @@ base::unique_qptr GifsListWidget::fillContextMenu( menu, type, SendMenu::DefaultSilentCallback(send), - SendMenu::DefaultScheduleCallback(this, type, send), + SendMenu::DefaultScheduleCallback(_show, type, send), SendMenu::DefaultWhenOnlineCallback(send), icons); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index a6a52f4be..42ea6b934 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1654,7 +1654,7 @@ base::unique_qptr StickersListWidget::fillContextMenu( menu, type, SendMenu::DefaultSilentCallback(send), - SendMenu::DefaultScheduleCallback(this, type, send), + SendMenu::DefaultScheduleCallback(_show, type, send), SendMenu::DefaultWhenOnlineCallback(send), icons); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index d47ee6ec1..dff29122c 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -2183,7 +2183,7 @@ void ComposeControls::initSendButton() { _send.get(), [=] { return sendButtonMenuType(); }, SendMenu::DefaultSilentCallback(send), - SendMenu::DefaultScheduleCallback(_wrap.get(), sendMenuType(), send), + SendMenu::DefaultScheduleCallback(_show, sendMenuType(), send), SendMenu::DefaultWhenOnlineCallback(send)); } diff --git a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp index 0103789ec..5e45b3d4a 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp @@ -344,7 +344,7 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) { _menu, type, SendMenu::DefaultSilentCallback(send), - SendMenu::DefaultScheduleCallback(this, type, send), + SendMenu::DefaultScheduleCallback(_controller->uiShow(), type, send), SendMenu::DefaultWhenOnlineCallback(send)); const auto item = _mosaic.itemAt(_selected); diff --git a/Telegram/SourceFiles/menu/menu_send.cpp b/Telegram/SourceFiles/menu/menu_send.cpp index 02ab8ed4b..a31fcf103 100644 --- a/Telegram/SourceFiles/menu/menu_send.cpp +++ b/Telegram/SourceFiles/menu/menu_send.cpp @@ -34,12 +34,11 @@ Fn DefaultSilentCallback(Fn send) { } Fn DefaultScheduleCallback( - not_null parent, + std::shared_ptr show, Type type, Fn send) { - const auto weak = Ui::MakeWeak(parent); - return [=] { - Ui::show( + return [=, weak = Ui::MakeWeak(show->toastParent())] { + show->showBox( HistoryView::PrepareScheduleBox( weak, type, diff --git a/Telegram/SourceFiles/menu/menu_send.h b/Telegram/SourceFiles/menu/menu_send.h index 79edc3840..03b7f7ec5 100644 --- a/Telegram/SourceFiles/menu/menu_send.h +++ b/Telegram/SourceFiles/menu/menu_send.h @@ -18,6 +18,7 @@ struct SendOptions; namespace Ui { class PopupMenu; class RpWidget; +class Show; } // namespace Ui namespace Data { @@ -41,7 +42,7 @@ enum class FillMenuResult { Fn DefaultSilentCallback(Fn send); Fn DefaultScheduleCallback( - not_null parent, + std::shared_ptr show, Type type, Fn send); Fn DefaultWhenOnlineCallback(Fn send); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 510902a15..2d3e2a663 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -2046,7 +2046,7 @@ QPointer ShowForwardMessagesBox( state->menu.get(), type, SendMenu::DefaultSilentCallback(submit), - SendMenu::DefaultScheduleCallback(state->box, type, submit), + SendMenu::DefaultScheduleCallback(show, type, submit), SendMenu::DefaultWhenOnlineCallback(submit)); const auto success = (result == SendMenu::FillMenuResult::Success); if (showForwardOptions || success) {