mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Slightly refactored code for menu with send options.
This commit is contained in:
parent
e1017380ec
commit
a2e4403b28
8 changed files with 15 additions and 28 deletions
|
@ -1134,7 +1134,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
|||
};
|
||||
SendMenu::FillSendMenu(
|
||||
_menu,
|
||||
[&] { return type; },
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
|
||||
|
|
|
@ -377,7 +377,7 @@ void GifsListWidget::fillContextMenu(
|
|||
};
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
[&] { return type; },
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ Fn<void()> DefaultScheduleCallback(
|
|||
|
||||
FillMenuResult FillSendMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
Fn<Type()> type,
|
||||
Type type,
|
||||
Fn<void()> silent,
|
||||
Fn<void()> 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<base::unique_qptr<Ui::PopupMenu>>();
|
||||
const auto showMenu = [=] {
|
||||
*menu = base::make_unique_q<Ui::PopupMenu>(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());
|
||||
|
|
|
@ -40,7 +40,7 @@ Fn<void()> DefaultScheduleCallback(
|
|||
|
||||
FillMenuResult FillSendMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
Fn<Type()> type,
|
||||
Type type,
|
||||
Fn<void()> silent,
|
||||
Fn<void()> schedule);
|
||||
|
||||
|
|
|
@ -2077,7 +2077,7 @@ void StickersListWidget::fillContextMenu(
|
|||
};
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
[&] { return type; },
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
_beforeHidingCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void setSendMenuType(Fn<SendMenu::Type()> callback) {
|
||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback) {
|
||||
_sendMenuType = std::move(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -301,7 +301,7 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) {
|
|||
};
|
||||
SendMenu::FillSendMenu(
|
||||
_menu,
|
||||
[&] { return type; },
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue