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(),
|
tr::lng_polls_create_button(),
|
||||||
[=] { send({}); });
|
[=] { send({}); });
|
||||||
if (_sendType == Api::SendType::Normal) {
|
if (_sendType == Api::SendType::Normal) {
|
||||||
SetupSendMenu(
|
SetupSendMenuAndShortcuts(
|
||||||
submit.data(),
|
submit.data(),
|
||||||
[=] { return SendMenuType::Scheduled; },
|
[=] { return SendMenuType::Scheduled; },
|
||||||
sendSilent,
|
sendSilent,
|
||||||
|
|
|
@ -1847,7 +1847,7 @@ void SendFilesBox::setupShadows(
|
||||||
void SendFilesBox::prepare() {
|
void SendFilesBox::prepare() {
|
||||||
_send = addButton(tr::lng_send_button(), [=] { send({}); });
|
_send = addButton(tr::lng_send_button(), [=] { send({}); });
|
||||||
if (_sendType == Api::SendType::Normal) {
|
if (_sendType == Api::SendType::Normal) {
|
||||||
SetupSendMenu(
|
SetupSendMenuAndShortcuts(
|
||||||
_send,
|
_send,
|
||||||
[=] { return _sendMenuType; },
|
[=] { return _sendMenuType; },
|
||||||
[=] { sendSilent(); },
|
[=] { sendSilent(); },
|
||||||
|
|
|
@ -426,7 +426,7 @@ void ShareBox::createButtons() {
|
||||||
const auto send = addButton(tr::lng_share_confirm(), [=] {
|
const auto send = addButton(tr::lng_share_confirm(), [=] {
|
||||||
submit({});
|
submit({});
|
||||||
});
|
});
|
||||||
SetupSendMenu(
|
SetupSendMenuAndShortcuts(
|
||||||
send,
|
send,
|
||||||
[=] { return sendMenuType(); },
|
[=] { return sendMenuType(); },
|
||||||
[=] { submitSilent(); },
|
[=] { submitSilent(); },
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/qthelp_url.h"
|
#include "base/qthelp_url.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
#include "core/shortcuts.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
@ -666,7 +667,7 @@ void MessageLinksParser::apply(
|
||||||
_list = std::move(parsed);
|
_list = std::move(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSendMenu(
|
void SetupSendMenuAndShortcuts(
|
||||||
not_null<Ui::RpWidget*> button,
|
not_null<Ui::RpWidget*> button,
|
||||||
Fn<SendMenuType()> type,
|
Fn<SendMenuType()> type,
|
||||||
Fn<void()> silent,
|
Fn<void()> silent,
|
||||||
|
@ -702,4 +703,30 @@ void SetupSendMenu(
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
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,
|
Reminder,
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetupSendMenu(
|
void SetupSendMenuAndShortcuts(
|
||||||
not_null<Ui::RpWidget*> button,
|
not_null<Ui::RpWidget*> button,
|
||||||
Fn<SendMenuType()> type,
|
Fn<SendMenuType()> type,
|
||||||
Fn<void()> silent,
|
Fn<void()> silent,
|
||||||
|
|
|
@ -76,6 +76,11 @@ const auto CommandByName = base::flat_map<QString, Command>{
|
||||||
{ qsl("self_chat") , Command::ChatSelf },
|
{ qsl("self_chat") , Command::ChatSelf },
|
||||||
|
|
||||||
{ qsl("show_archive") , Command::ShowArchive },
|
{ 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>{
|
const auto CommandNames = base::flat_map<Command, QString>{
|
||||||
|
|
|
@ -37,6 +37,9 @@ enum class Command {
|
||||||
|
|
||||||
ShowArchive,
|
ShowArchive,
|
||||||
|
|
||||||
|
SendSilentMessage,
|
||||||
|
ScheduleMessage,
|
||||||
|
|
||||||
SupportReloadTemplates,
|
SupportReloadTemplates,
|
||||||
SupportToggleMuted,
|
SupportToggleMuted,
|
||||||
SupportScrollToCurrent,
|
SupportScrollToCurrent,
|
||||||
|
|
|
@ -314,7 +314,7 @@ HistoryWidget::HistoryWidget(
|
||||||
_fieldBarCancel->addClickHandler([=] { cancelFieldAreaState(); });
|
_fieldBarCancel->addClickHandler([=] { cancelFieldAreaState(); });
|
||||||
_send->addClickHandler([=] { sendButtonClicked(); });
|
_send->addClickHandler([=] { sendButtonClicked(); });
|
||||||
|
|
||||||
SetupSendMenu(
|
SetupSendMenuAndShortcuts(
|
||||||
_send,
|
_send,
|
||||||
[=] { return sendButtonMenuType(); },
|
[=] { return sendButtonMenuType(); },
|
||||||
[=] { sendSilent(); },
|
[=] { sendSilent(); },
|
||||||
|
|
|
@ -688,7 +688,7 @@ void ScheduleBox(
|
||||||
const auto submit = box->addButton(tr::lng_settings_save(), [=] {
|
const auto submit = box->addButton(tr::lng_settings_save(), [=] {
|
||||||
save(false);
|
save(false);
|
||||||
});
|
});
|
||||||
SetupSendMenu(
|
SetupSendMenuAndShortcuts(
|
||||||
submit.data(),
|
submit.data(),
|
||||||
[=] { return SendMenuType::SilentOnly; },
|
[=] { return SendMenuType::SilentOnly; },
|
||||||
[=] { save(true); },
|
[=] { save(true); },
|
||||||
|
|
Loading…
Reference in New Issue