summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-01-17 16:36:24 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-01-17 16:36:24 +0100
commitbca368f9fa495334b3dd9670a5ee7264c62e0c80 (patch)
tree789bcae04011b5eff47f728536bf846c69c70afd
parentFix a bookmarks bar crash (diff)
downloadrekonq-bca368f9fa495334b3dd9670a5ee7264c62e0c80.tar.xz
Moved access keys activation to release key event
This to copy konqueror behavior. Also added some kDebug messages to better work with the "key event" features: - vi-like navigation - access keys - autoscroll
-rw-r--r--src/webview.cpp53
-rw-r--r--src/webview.h6
2 files changed, 39 insertions, 20 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index ac861fb0..740024c2 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -618,26 +618,6 @@ void WebView::bookmarkLink()
void WebView::keyPressEvent(QKeyEvent *event)
{
- if (ReKonfig::accessKeysEnabled())
- {
- m_accessKeysPressed = (event->modifiers() == Qt::ControlModifier
- && event->key() == Qt::Key_Control);
- if (!m_accessKeysPressed)
- {
- if (checkForAccessKey(event))
- {
- hideAccessKeys();
- event->accept();
- return;
- }
- hideAccessKeys();
- }
- else
- {
- QTimer::singleShot(200, this, SLOT(accessKeyShortcut()));
- }
- }
-
if (event->modifiers() == Qt::ControlModifier)
{
if (event->key() == Qt::Key_C)
@@ -662,6 +642,8 @@ void WebView::keyPressEvent(QKeyEvent *event)
// Auto Scrolling
if (event->modifiers() == Qt::ShiftModifier)
{
+ kDebug() << "AutoScrolling: " << event->key();
+
if (event->key() == Qt::Key_Up)
{
m_vScrollSpeed--;
@@ -711,6 +693,8 @@ void WebView::keyPressEvent(QKeyEvent *event)
const QString tagName = page()->mainFrame()->evaluateJavaScript("document.activeElement.tagName").toString();
if (tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") && event->modifiers() == Qt::NoModifier)
{
+ kDebug() << "Using VI-LIKE modifiers: " << event->key();
+
switch (event->key())
{
case Qt::Key_J:
@@ -734,10 +718,39 @@ void WebView::keyPressEvent(QKeyEvent *event)
}
}
}
+
KWebView::keyPressEvent(event);
}
+void WebView::keyReleaseEvent(QKeyEvent *event)
+{
+ // access keys management
+ if (ReKonfig::accessKeysEnabled())
+ {
+ m_accessKeysPressed = (event->key() == Qt::Key_Control);
+
+ if (!m_accessKeysPressed)
+ {
+ if (checkForAccessKey(event))
+ {
+ hideAccessKeys();
+ event->accept();
+ return;
+ }
+ hideAccessKeys();
+ }
+ else
+ {
+ kDebug() << "Shotting access keys";
+ QTimer::singleShot(200, this, SLOT(accessKeyShortcut()));
+ }
+ }
+
+ KWebView::keyReleaseEvent(event);
+}
+
+
void WebView::wheelEvent(QWheelEvent *event)
{
if (event->orientation() == Qt::Vertical || !ReKonfig::hScrollWheelHistory())
diff --git a/src/webview.h b/src/webview.h
index 6eb5b84d..b0254aa4 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -70,13 +70,19 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent *event);
+
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
+
void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+
void wheelEvent(QWheelEvent *event);
+
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent * event);
+
void paintEvent(QPaintEvent *event);
private Q_SLOTS: