mirror of https://github.com/procxx/kepka.git
Added ability to customize shortcuts for silent or scheduled messages.
This commit is contained in:
parent
19fd3a15e1
commit
7d519990b2
|
@ -942,7 +942,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
tr::lng_polls_create_button(),
|
||||
[=] { send({}); });
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
SetupSendMenu(
|
||||
SetupSendMenuAndShortcuts(
|
||||
submit.data(),
|
||||
[=] { return SendMenuType::Scheduled; },
|
||||
sendSilent,
|
||||
|
|
|
@ -1847,7 +1847,7 @@ void SendFilesBox::setupShadows(
|
|||
void SendFilesBox::prepare() {
|
||||
_send = addButton(tr::lng_send_button(), [=] { send({}); });
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
SetupSendMenu(
|
||||
SetupSendMenuAndShortcuts(
|
||||
_send,
|
||||
[=] { return _sendMenuType; },
|
||||
[=] { sendSilent(); },
|
||||
|
|
|
@ -426,7 +426,7 @@ void ShareBox::createButtons() {
|
|||
const auto send = addButton(tr::lng_share_confirm(), [=] {
|
||||
submit({});
|
||||
});
|
||||
SetupSendMenu(
|
||||
SetupSendMenuAndShortcuts(
|
||||
send,
|
||||
[=] { return sendMenuType(); },
|
||||
[=] { submitSilent(); },
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/qthelp_url.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
@ -666,7 +667,7 @@ void MessageLinksParser::apply(
|
|||
_list = std::move(parsed);
|
||||
}
|
||||
|
||||
void SetupSendMenu(
|
||||
void SetupSendMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
Fn<SendMenuType()> type,
|
||||
Fn<void()> silent,
|
||||
|
@ -702,4 +703,30 @@ void SetupSendMenu(
|
|||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
Shortcuts::Requests(
|
||||
) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||
using Command = Shortcuts::Command;
|
||||
|
||||
const auto now = type();
|
||||
if (now == SendMenuType::Disabled
|
||||
|| (!silent && now == SendMenuType::SilentOnly)) {
|
||||
return;
|
||||
}
|
||||
silent
|
||||
&& (now != SendMenuType::Reminder)
|
||||
&& request->check(Command::SendSilentMessage)
|
||||
&& request->handle([=] {
|
||||
silent();
|
||||
return true;
|
||||
});
|
||||
|
||||
schedule
|
||||
&& (now != SendMenuType::SilentOnly)
|
||||
&& request->check(Command::ScheduleMessage)
|
||||
&& request->handle([=] {
|
||||
schedule();
|
||||
return true;
|
||||
});
|
||||
}, button->lifetime());
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ enum class SendMenuType {
|
|||
Reminder,
|
||||
};
|
||||
|
||||
void SetupSendMenu(
|
||||
void SetupSendMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
Fn<SendMenuType()> type,
|
||||
Fn<void()> silent,
|
||||
|
|
|
@ -76,6 +76,11 @@ const auto CommandByName = base::flat_map<QString, Command>{
|
|||
{ qsl("self_chat") , Command::ChatSelf },
|
||||
|
||||
{ qsl("show_archive") , Command::ShowArchive },
|
||||
|
||||
// Shortcuts that have no default values.
|
||||
{ qsl("message_silently") , Command::SendSilentMessage },
|
||||
{ qsl("message_scheduled"), Command::ScheduleMessage },
|
||||
//
|
||||
};
|
||||
|
||||
const auto CommandNames = base::flat_map<Command, QString>{
|
||||
|
|
|
@ -37,6 +37,9 @@ enum class Command {
|
|||
|
||||
ShowArchive,
|
||||
|
||||
SendSilentMessage,
|
||||
ScheduleMessage,
|
||||
|
||||
SupportReloadTemplates,
|
||||
SupportToggleMuted,
|
||||
SupportScrollToCurrent,
|
||||
|
|
|
@ -314,7 +314,7 @@ HistoryWidget::HistoryWidget(
|
|||
_fieldBarCancel->addClickHandler([=] { cancelFieldAreaState(); });
|
||||
_send->addClickHandler([=] { sendButtonClicked(); });
|
||||
|
||||
SetupSendMenu(
|
||||
SetupSendMenuAndShortcuts(
|
||||
_send,
|
||||
[=] { return sendButtonMenuType(); },
|
||||
[=] { sendSilent(); },
|
||||
|
|
|
@ -688,7 +688,7 @@ void ScheduleBox(
|
|||
const auto submit = box->addButton(tr::lng_settings_save(), [=] {
|
||||
save(false);
|
||||
});
|
||||
SetupSendMenu(
|
||||
SetupSendMenuAndShortcuts(
|
||||
submit.data(),
|
||||
[=] { return SendMenuType::SilentOnly; },
|
||||
[=] { save(true); },
|
||||
|
|
Loading…
Reference in New Issue