diff options
author | Johannes Troscher <fritz_van_tom@hotmail.com> | 2011-08-21 18:15:06 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-08-21 18:15:06 +0200 |
commit | 4743583e3852d616daf7a7ade480ac5d04295474 (patch) | |
tree | 5092211901c066bc64d306a467facc9129b37ee0 /src/webview.cpp | |
parent | Restore tab's history when restoring a tab/session (diff) | |
download | rekonq-4743583e3852d616daf7a7ade480ac5d04295474.tar.xz |
Fix vi-like navigation shortcuts
This patch introduces a check on input/textarea elements to be sure
we are NOT stealing focus there.. ;)
It also introduces a check to let the feature being optional (just to
be completely sure... )
CCBUG: 238761
REVIEW: 102255
REVIEWED-BY: adjam,elproxy
Diffstat (limited to 'src/webview.cpp')
-rw-r--r-- | src/webview.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index d8325543..8dfcc051 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -643,6 +643,35 @@ void WebView::keyPressEvent(QKeyEvent *event) } } + // vi-like navigation + if (ReKonfig::enableViShortcuts()) + { + const QString tagName = page()->mainFrame()->evaluateJavaScript("document.activeElement.tagName").toString(); + if (tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") && event->modifiers() == Qt::NoModifier) + { + switch (event->key()) + { + case Qt::Key_J: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); + break; + case Qt::Key_K: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); + break; + case Qt::Key_L: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); + break; + case Qt::Key_H: + event->accept(); + event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); + break; + default: + break; + } + } + } KWebView::keyPressEvent(event); } |