diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 95b68324b..6faeb1b66 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -1134,7 +1134,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) { }; SendMenu::FillSendMenu( _menu, - [&] { return type; }, + type, SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send)); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 7e7eaa63e..0960a8cb6 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -377,7 +377,7 @@ void GifsListWidget::fillContextMenu( }; SendMenu::FillSendMenu( menu, - [&] { return type; }, + type, SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send)); diff --git a/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp b/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp index 0f5666dd9..08271abd6 100644 --- a/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp +++ b/Telegram/SourceFiles/chat_helpers/send_context_menu.cpp @@ -40,13 +40,13 @@ Fn DefaultScheduleCallback( FillMenuResult FillSendMenu( not_null menu, - Fn type, + Type type, Fn silent, Fn schedule) { if (!silent && !schedule) { return FillMenuResult::None; } - const auto now = type(); + const auto now = type; if (now == Type::Disabled || (!silent && now == Type::SilentOnly)) { return FillMenuResult::None; @@ -76,7 +76,7 @@ void SetupMenuAndShortcuts( const auto menu = std::make_shared>(); const auto showMenu = [=] { *menu = base::make_unique_q(button); - const auto result = FillSendMenu(*menu, type, silent, schedule); + const auto result = FillSendMenu(*menu, type(), silent, schedule); const auto success = (result == FillMenuResult::Success); if (success) { (*menu)->popup(QCursor::pos()); diff --git a/Telegram/SourceFiles/chat_helpers/send_context_menu.h b/Telegram/SourceFiles/chat_helpers/send_context_menu.h index ec810545e..11f9824b6 100644 --- a/Telegram/SourceFiles/chat_helpers/send_context_menu.h +++ b/Telegram/SourceFiles/chat_helpers/send_context_menu.h @@ -40,7 +40,7 @@ Fn DefaultScheduleCallback( FillMenuResult FillSendMenu( not_null menu, - Fn type, + Type type, Fn silent, Fn schedule); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index d2534c7ed..0cb159ae9 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2077,7 +2077,7 @@ void StickersListWidget::fillContextMenu( }; SendMenu::FillSendMenu( menu, - [&] { return type; }, + type, SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send)); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index d20c67c1d..a73e97e67 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -109,7 +109,7 @@ public: _beforeHidingCallback = std::move(callback); } - void setSendMenuType(Fn callback) { + void setSendMenuType(Fn &&callback) { _sendMenuType = std::move(callback); } 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 74af9ba30..98269b845 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "history/view/controls/history_view_voice_record_bar.h" -#include "history/view/history_view_schedule_box.h" // HistoryView::PrepareScheduleBox #include "history/view/history_view_webpage_preview.h" #include "inline_bots/inline_results_widget.h" #include "inline_bots/inline_bot_result.h" @@ -1419,11 +1418,15 @@ void ComposeControls::initSendButton() { cancelInlineBot(); }, _send->lifetime()); + const auto send = [=](Api::SendOptions options) { + _sendCustomRequests.fire(std::move(options)); + }; + SendMenu::SetupMenuAndShortcuts( _send.get(), [=] { return sendButtonMenuType(); }, - [=] { sendSilent(); }, - [=] { sendScheduled(); }); + SendMenu::DefaultSilentCallback(send), + SendMenu::DefaultScheduleCallback(_wrap.get(), sendMenuType(), send)); } void ComposeControls::inlineBotResolveDone( @@ -2119,22 +2122,6 @@ bool ComposeControls::isRecording() const { return _voiceRecordBar->isRecording(); } -void ComposeControls::sendSilent() { - _sendCustomRequests.fire({ .silent = true }); -} - -void ComposeControls::sendScheduled() { - auto callback = [=](Api::SendOptions options) { - _sendCustomRequests.fire(std::move(options)); - }; - Ui::show( - HistoryView::PrepareScheduleBox( - _wrap.get(), - sendMenuType(), - std::move(callback)), - Ui::LayerOption::KeepOther); -} - void ComposeControls::updateInlineBotQuery() { if (!_history) { return; diff --git a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp index e36111c43..28acc81c8 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_inner.cpp @@ -301,7 +301,7 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) { }; SendMenu::FillSendMenu( _menu, - [&] { return type; }, + type, SendMenu::DefaultSilentCallback(send), SendMenu::DefaultScheduleCallback(this, type, send));