diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2012-02-09 18:40:21 +0100 |
---|---|---|
committer | Yoann Laissus <yoann.laissus@gmail.com> | 2012-02-09 18:40:21 +0100 |
commit | f5c45173623e39fb5ad67ae870c4bdfe5fe8520c (patch) | |
tree | 79e1703c95cf40c3d426f1ff1980bc50d6778028 /src/webview.cpp | |
parent | Fix right icon duplication in the UrlBar on some website (diff) | |
parent | Clean up sessionmanager mess :) (diff) | |
download | rekonq-f5c45173623e39fb5ad67ae870c4bdfe5fe8520c.tar.xz |
Merge branch 'master' of git://anongit.kde.org/rekonq
Diffstat (limited to 'src/webview.cpp')
-rw-r--r-- | src/webview.cpp | 142 |
1 files changed, 76 insertions, 66 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index 1c2a4028..f2328be5 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -665,74 +665,76 @@ void WebView::keyPressEvent(QKeyEvent *event) } } - bool isContentEditable = page()->mainFrame()->evaluateJavaScript("document.activeElement.isContentEditable").toBool(); - // Auto Scrolling if (event->modifiers() == Qt::ShiftModifier && tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") - && !isContentEditable ) { - kDebug() << "AutoScrolling: " << event->key(); + // NOTE: I'm doing this check here to prevent this to be done EVERYTIME + // we'll do it just when SHIFT has been pressed in an element NOT usually editable + bool isContentEditable = page()->mainFrame()->hitTestContent(QCursor::pos()).isContentEditable(); - if (event->key() == Qt::Key_Up) + if (!isContentEditable) { - m_verticalAutoScrollSpeed--; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Up) + { + m_verticalAutoScrollSpeed--; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Down) - { - m_verticalAutoScrollSpeed++; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Down) + { + m_verticalAutoScrollSpeed++; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Right) - { - m_horizontalAutoScrollSpeed++; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Right) + { + m_horizontalAutoScrollSpeed++; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (event->key() == Qt::Key_Left) - { - m_horizontalAutoScrollSpeed--; - if (!m_autoScrollTimer->isActive()) - m_autoScrollTimer->start(); + if (event->key() == Qt::Key_Left) + { + m_horizontalAutoScrollSpeed--; + if (!m_autoScrollTimer->isActive()) + m_autoScrollTimer->start(); - event->accept(); - return; - } + event->accept(); + return; + } - if (m_autoScrollTimer->isActive()) - { - m_autoScrollTimer->stop(); - event->accept(); - return; - } - else - { - if (m_verticalAutoScrollSpeed || m_horizontalAutoScrollSpeed) + if (m_autoScrollTimer->isActive()) { - m_autoScrollTimer->start(); + m_autoScrollTimer->stop(); event->accept(); return; } + else + { + if (m_verticalAutoScrollSpeed || m_horizontalAutoScrollSpeed) + { + m_autoScrollTimer->start(); + event->accept(); + return; + } + } } - // if you arrived here, it means SHIFT has been pressed NOT for autoscroll management... + // if you arrived here, I hope it means SHIFT has been pressed NOT for autoscroll management... } if (ReKonfig::accessKeysEnabled() && m_accessKeysActive) @@ -745,28 +747,36 @@ void WebView::keyPressEvent(QKeyEvent *event) // vi-like navigation if (ReKonfig::enableViShortcuts()) { - if (tagName != QL1S("INPUT") && tagName != QL1S("TEXTAREA") && !isContentEditable && event->modifiers() == Qt::NoModifier) + if (event->modifiers() == Qt::NoModifier + && tagName != QL1S("INPUT") + && tagName != QL1S("TEXTAREA") + ) { - switch (event->key()) + bool isContentEditable = page()->mainFrame()->hitTestContent(QCursor::pos()).isContentEditable(); + + if (!isContentEditable) { - 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; + 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; + } } } } |