Commit 05e07316 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: Ensure shortcuts work as expected in integrated text editor

We have to override a couple of more keys and some key sequences.
Crtl + Alt is used for keys in certain language layouts.

Change-Id: I471b8c4042989cb2821a8f27a87336f20d0e37e5
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 265890de
......@@ -143,13 +143,28 @@ int TextEditorWidget::currentLine() const
bool TextEditorWidget::eventFilter( QObject *, QEvent *event)
{
static std::vector<int> overrideKeys = { Qt::Key_Delete, Qt::Key_Backspace, Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, Qt::Key_Down };
static std::vector<int> overrideKeys = { Qt::Key_Delete, Qt::Key_Backspace, Qt::Key_Left,
Qt::Key_Right, Qt::Key_Up, Qt::Key_Down, Qt::Key_Insert,
Qt::Key_Escape, Qt::Key_Home, Qt::Key_End };
static std::vector<QKeySequence> overrideSequences = { QKeySequence::SelectAll, QKeySequence::Cut,
QKeySequence::Copy, QKeySequence::Delete,
QKeySequence::Paste, QKeySequence::Undo,
QKeySequence::Redo, QKeySequence(Qt::CTRL + Qt::ALT) };
if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (std::find(overrideKeys.begin(), overrideKeys.end(), keyEvent->key()) != overrideKeys.end()) {
keyEvent->accept();
return true;
}
QKeySequence keySqeuence(keyEvent->key() | keyEvent->modifiers());
for (QKeySequence overrideSequence : overrideSequences)
if (keySqeuence.matches(overrideSequence)) {
keyEvent->accept();
return true;
}
}
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment