Added ability to customize shortcuts for sending messages.

This commit is contained in:
23rd 2019-12-24 13:27:36 +03:00 committed by John Preston
parent 7d519990b2
commit 465a42a825
3 changed files with 24 additions and 5 deletions

View File

@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QTextBlock> #include <QtGui/QTextBlock>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtWidgets/QApplication>
namespace { namespace {
@ -713,20 +714,36 @@ void SetupSendMenuAndShortcuts(
|| (!silent && now == SendMenuType::SilentOnly)) { || (!silent && now == SendMenuType::SilentOnly)) {
return; return;
} }
silent (silent
&& (now != SendMenuType::Reminder) && (now != SendMenuType::Reminder)
&& request->check(Command::SendSilentMessage) && request->check(Command::SendSilentMessage)
&& request->handle([=] { && request->handle([=] {
silent(); silent();
return true; return true;
}); }))
||
schedule (schedule
&& (now != SendMenuType::SilentOnly) && (now != SendMenuType::SilentOnly)
&& request->check(Command::ScheduleMessage) && request->check(Command::ScheduleMessage)
&& request->handle([=] { && request->handle([=] {
schedule(); schedule();
return true; return true;
}); }))
||
(request->check(Command::SendMessage) && request->handle([=] {
const auto post = [&](QEvent::Type type) {
QApplication::postEvent(
button,
new QMouseEvent(
type,
QPointF(0, 0),
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier));
};
post(QEvent::MouseButtonPress);
post(QEvent::MouseButtonRelease);
return true;
}));
}, button->lifetime()); }, button->lifetime());
} }

View File

@ -78,6 +78,7 @@ const auto CommandByName = base::flat_map<QString, Command>{
{ qsl("show_archive") , Command::ShowArchive }, { qsl("show_archive") , Command::ShowArchive },
// Shortcuts that have no default values. // Shortcuts that have no default values.
{ qsl("message") , Command::SendMessage },
{ qsl("message_silently") , Command::SendSilentMessage }, { qsl("message_silently") , Command::SendSilentMessage },
{ qsl("message_scheduled"), Command::ScheduleMessage }, { qsl("message_scheduled"), Command::ScheduleMessage },
// //

View File

@ -37,6 +37,7 @@ enum class Command {
ShowArchive, ShowArchive,
SendMessage,
SendSilentMessage, SendSilentMessage,
ScheduleMessage, ScheduleMessage,