Compare nativeVirtualKey with enum value

This commit is contained in:
Ilya Fedin 2023-11-10 12:12:45 +04:00 committed by John Preston
parent 024f438ce5
commit f4b87f2322

View file

@ -31,6 +31,10 @@
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QTextEdit>
#ifdef Q_OS_WIN
#include <WinUser.h>
#endif // Q_OS_WIN
namespace Ui {
namespace {
@ -2910,16 +2914,16 @@ bool InputField::handleMarkdownKey(QKeyEvent *e) {
return sequence.matches(events) == QKeySequence::ExactMatch;
};
const auto matchesCtrlShiftDot = [&] {
#ifdef Q_OS_WIN
// We can't match ctrl+shift+. with QKeySequence because
// shift+. gives us '>' and ctrl+shift+> is not the same.
// So we check by nativeVirtualKey instead.
#ifdef Q_OS_WIN
return e->modifiers().testFlag(Qt::ControlModifier)
&& e->modifiers().testFlag(Qt::ShiftModifier)
&& (e->nativeVirtualKey() == 190); // VK_OEM_PERIOD
&& (e->nativeVirtualKey() == VK_OEM_PERIOD);
#else // Q_OS_WIN
return false;
#endif // Q_OS_WIN
#endif // !Q_OS_WIN
};
if (e == QKeySequence::Bold) {
toggleSelectionMarkdown(kTagBold);