Editor: accept common text edit short cut override events

see QWidgetTextControl::processEvent and
QInputControl::isCommonTextEditShortcut. This will break assigning
shortcuts to for example Shift+a.

Change-Id: I4f97c27a47e2a7a44bf06b3ca949a6de74d4bb64
Fixes: QTCREATORBUG-22854
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2019-08-27 13:34:23 +02:00
parent 20a304c8e0
commit 587dc52119

View File

@@ -2849,14 +2849,20 @@ bool TextEditorWidget::event(QEvent *e)
if (e->type() != QEvent::InputMethodQuery) if (e->type() != QEvent::InputMethodQuery)
d->m_contentsChanged = false; d->m_contentsChanged = false;
switch (e->type()) { switch (e->type()) {
case QEvent::ShortcutOverride: case QEvent::ShortcutOverride: {
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape && d->m_snippetOverlay->isVisible()) { auto ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && d->m_snippetOverlay->isVisible()) {
e->accept(); e->accept();
} else { } else {
e->ignore(); // we are a really nice citizen // hack copied from QInputControl::isCommonTextEditShortcut
// Fixes: QTCREATORBUG-22854
e->setAccepted((ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier
|| ke->modifiers() == Qt::KeypadModifier)
&& (ke->key() < Qt::Key_Escape));
d->m_maybeFakeTooltipEvent = false; d->m_maybeFakeTooltipEvent = false;
} }
return true; return true;
}
case QEvent::ApplicationPaletteChange: { case QEvent::ApplicationPaletteChange: {
// slight hack: ignore palette changes // slight hack: ignore palette changes
// at this point the palette has changed already, // at this point the palette has changed already,