summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rekonq.kcfg3
-rw-r--r--src/settings/settings_general.ui17
-rw-r--r--src/webview.cpp29
3 files changed, 44 insertions, 5 deletions
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 4050c4a0..2d19b723 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -97,6 +97,9 @@
<entry name="clearHomePageThumbs" type="Bool">
<default>true</default>
</entry>
+ <entry name="enableViShortcuts" type="Bool">
+ <default>false</default>
+ </entry>
</group>
diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui
index d0c31655..3f7c0675 100644
--- a/src/settings/settings_general.ui
+++ b/src/settings/settings_general.ui
@@ -194,6 +194,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="kcfg_enableViShortcuts">
+ <property name="text">
+ <string>Enable Vi-like navigation shortcuts</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -214,15 +221,15 @@
</widget>
<customwidgets>
<customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
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);
}