mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Moved default send callbacks to separate functions.
This commit is contained in:
parent
edceed28d7
commit
2ac425f350
5 changed files with 37 additions and 36 deletions
|
@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "history/view/history_view_schedule_box.h"
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "storage/storage_account.h" // Account::writeSavedGifs
|
#include "storage/storage_account.h" // Account::writeSavedGifs
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
@ -376,20 +375,11 @@ void GifsListWidget::fillContextMenu(
|
||||||
const auto send = [=](Api::SendOptions options) {
|
const auto send = [=](Api::SendOptions options) {
|
||||||
selectInlineResult(row, column, options, true);
|
selectInlineResult(row, column, options, true);
|
||||||
};
|
};
|
||||||
const auto silent = [=] { send({ .silent = true }); };
|
|
||||||
const auto schedule = [=] {
|
|
||||||
Ui::show(
|
|
||||||
HistoryView::PrepareScheduleBox(
|
|
||||||
this,
|
|
||||||
type,
|
|
||||||
[=](Api::SendOptions options) { send(options); }),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
};
|
|
||||||
FillSendMenu(
|
FillSendMenu(
|
||||||
menu,
|
menu,
|
||||||
[&] { return type; },
|
[&] { return type; },
|
||||||
silent,
|
DefaultSilentCallback(send),
|
||||||
schedule);
|
DefaultScheduleCallback(this, type, send));
|
||||||
|
|
||||||
[&] {
|
[&] {
|
||||||
const auto row = _selected / MatrixRowShift;
|
const auto row = _selected / MatrixRowShift;
|
||||||
|
|
|
@ -9,12 +9,33 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
|
#include "boxes/abstract_box.h"
|
||||||
#include "core/shortcuts.h"
|
#include "core/shortcuts.h"
|
||||||
|
#include "history/view/history_view_schedule_box.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
|
Fn<void()> DefaultSilentCallback(Fn<void(Api::SendOptions)> send) {
|
||||||
|
return [=] { send({ .silent = true }); };
|
||||||
|
}
|
||||||
|
|
||||||
|
Fn<void()> DefaultScheduleCallback(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
SendMenuType type,
|
||||||
|
Fn<void(Api::SendOptions)> send) {
|
||||||
|
const auto weak = Ui::MakeWeak(parent);
|
||||||
|
return [=] {
|
||||||
|
Ui::show(
|
||||||
|
HistoryView::PrepareScheduleBox(
|
||||||
|
weak,
|
||||||
|
type,
|
||||||
|
[=](Api::SendOptions options) { send(options); }),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
FillMenuResult FillSendMenu(
|
FillMenuResult FillSendMenu(
|
||||||
not_null<Ui::PopupMenu*> menu,
|
not_null<Ui::PopupMenu*> menu,
|
||||||
Fn<SendMenuType()> type,
|
Fn<SendMenuType()> type,
|
||||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
|
|
||||||
|
namespace Api {
|
||||||
|
struct SendOptions;
|
||||||
|
} // namespace Api
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -26,6 +30,12 @@ enum class FillMenuResult {
|
||||||
None,
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Fn<void()> DefaultSilentCallback(Fn<void(Api::SendOptions)> send);
|
||||||
|
Fn<void()> DefaultScheduleCallback(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
SendMenuType type,
|
||||||
|
Fn<void(Api::SendOptions)> send);
|
||||||
|
|
||||||
FillMenuResult FillSendMenu(
|
FillMenuResult FillSendMenu(
|
||||||
not_null<Ui::PopupMenu*> menu,
|
not_null<Ui::PopupMenu*> menu,
|
||||||
Fn<SendMenuType()> type,
|
Fn<SendMenuType()> type,
|
||||||
|
|
|
@ -26,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lottie/lottie_animation.h"
|
#include "lottie/lottie_animation.h"
|
||||||
#include "boxes/stickers_box.h"
|
#include "boxes/stickers_box.h"
|
||||||
#include "inline_bots/inline_bot_result.h"
|
#include "inline_bots/inline_bot_result.h"
|
||||||
#include "history/view/history_view_schedule_box.h"
|
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -2073,20 +2072,11 @@ void StickersListWidget::fillContextMenu(
|
||||||
.document = document,
|
.document = document,
|
||||||
.options = options });
|
.options = options });
|
||||||
};
|
};
|
||||||
const auto silent = [=] { send({ .silent = true }); };
|
|
||||||
const auto schedule = [=] {
|
|
||||||
checkHideWithBox(Ui::show(
|
|
||||||
HistoryView::PrepareScheduleBox(
|
|
||||||
this,
|
|
||||||
type,
|
|
||||||
[=](Api::SendOptions options) { send(options); }),
|
|
||||||
Ui::LayerOption::KeepOther).data());
|
|
||||||
};
|
|
||||||
FillSendMenu(
|
FillSendMenu(
|
||||||
menu,
|
menu,
|
||||||
[&] { return type; },
|
[&] { return type; },
|
||||||
silent,
|
DefaultSilentCallback(send),
|
||||||
schedule);
|
DefaultScheduleCallback(this, type, send));
|
||||||
|
|
||||||
const auto toggleFavedSticker = [=] {
|
const auto toggleFavedSticker = [=] {
|
||||||
document->session().api().toggleFavedSticker(
|
document->session().api().toggleFavedSticker(
|
||||||
|
|
|
@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "history/view/history_view_schedule_box.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
@ -312,20 +311,11 @@ void Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
const auto send = [=](Api::SendOptions options) {
|
const auto send = [=](Api::SendOptions options) {
|
||||||
selectInlineResult(row, column, options);
|
selectInlineResult(row, column, options);
|
||||||
};
|
};
|
||||||
const auto silent = [=] { send({ .silent = true }); };
|
|
||||||
const auto schedule = [=] {
|
|
||||||
Ui::show(
|
|
||||||
HistoryView::PrepareScheduleBox(
|
|
||||||
this,
|
|
||||||
type,
|
|
||||||
[=](Api::SendOptions options) { send(options); }),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
};
|
|
||||||
FillSendMenu(
|
FillSendMenu(
|
||||||
_menu,
|
_menu,
|
||||||
[&] { return type; },
|
[&] { return type; },
|
||||||
silent,
|
DefaultSilentCallback(send),
|
||||||
schedule);
|
DefaultScheduleCallback(this, type, send));
|
||||||
|
|
||||||
if (!_menu->actions().empty()) {
|
if (!_menu->actions().empty()) {
|
||||||
_menu->popup(QCursor::pos());
|
_menu->popup(QCursor::pos());
|
||||||
|
|
Loading…
Add table
Reference in a new issue