2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Don't switch chats on ctrl+shift+send (support).

This commit is contained in:
John Preston
2018-10-08 17:08:17 +03:00
parent 83919492d3
commit be6e329e94
10 changed files with 101 additions and 40 deletions

View File

@@ -2473,19 +2473,28 @@ not_null<const QTextEdit*> InputField::rawTextEdit() const {
return _inner.get();
}
bool InputField::ShouldSubmit(
SubmitSettings settings,
Qt::KeyboardModifiers modifiers) {
const auto shift = modifiers.testFlag(Qt::ShiftModifier);
const auto ctrl = modifiers.testFlag(Qt::ControlModifier)
|| modifiers.testFlag(Qt::MetaModifier);
return (ctrl && shift)
|| (ctrl
&& settings != SubmitSettings::None
&& settings != SubmitSettings::Enter)
|| (!ctrl
&& !shift
&& settings != SubmitSettings::None
&& settings != SubmitSettings::CtrlEnter);
}
void InputField::keyPressEventInner(QKeyEvent *e) {
bool shift = e->modifiers().testFlag(Qt::ShiftModifier), alt = e->modifiers().testFlag(Qt::AltModifier);
bool macmeta = (cPlatform() == dbipMac || cPlatform() == dbipMacOld) && e->modifiers().testFlag(Qt::ControlModifier) && !e->modifiers().testFlag(Qt::MetaModifier) && !e->modifiers().testFlag(Qt::AltModifier);
bool ctrl = e->modifiers().testFlag(Qt::ControlModifier) || e->modifiers().testFlag(Qt::MetaModifier);
bool enterSubmit = (_mode == Mode::SingleLine)
|| (ctrl && shift)
|| (ctrl
&& _submitSettings != SubmitSettings::None
&& _submitSettings != SubmitSettings::Enter)
|| (!ctrl
&& !shift
&& _submitSettings != SubmitSettings::None
&& _submitSettings != SubmitSettings::CtrlEnter);
|| ShouldSubmit(_submitSettings, e->modifiers());
bool enter = (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return);
if (e->key() == Qt::Key_Left
|| e->key() == Qt::Key_Right

View File

@@ -267,6 +267,9 @@ public:
using SubmitSettings = InputSubmitSettings;
void setSubmitSettings(SubmitSettings settings);
static bool ShouldSubmit(
SubmitSettings settings,
Qt::KeyboardModifiers modifiers);
void customUpDown(bool isCustom);
void customTab(bool isCustom);
int borderAnimationStart() const;