summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-03-31 10:54:02 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-03-31 10:54:02 +0200
commita6da0df7e0f72f1d7185e39815c17b7fab07d790 (patch)
tree36158efa98e29bcc0bc27d5128d2ecb44d36b45c /src
parentThis patch solves some problems of clipped text (diff)
downloadrekonq-a6da0df7e0f72f1d7185e39815c17b7fab07d790.tar.xz
Auto Scrolling, first bunch.
key combinations just work :)
Diffstat (limited to 'src')
-rw-r--r--src/adblock/adblockmanager.cpp15
-rw-r--r--src/webview.cpp88
-rw-r--r--src/webview.h10
3 files changed, 85 insertions, 28 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index feb92864..0a139bdc 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -211,21 +211,6 @@ void AdBlockManager::applyHidingRules(WebPage *page)
if (!_isAdblockEnabled)
return;
-// // BLACK RULES
-// foreach(const AdBlockRule &filter, _blackList)
-// {
-// QWebElementCollection elements = document.findAll("*");
-// foreach (QWebElement el, elements)
-// {
-// if(filter.match( el.attribute("src") ) )
-// {
-// kDebug() << "MATCHES!!!!!";
-// el.setStyleProperty(QLatin1String("visibility"), QLatin1String("hidden"));
-// el.removeFromDocument();
-// }
-// }
-// }
-
if (!_isHideAdsEnabled)
return;
diff --git a/src/webview.cpp b/src/webview.cpp
index 80d44d10..294b7c85 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -62,7 +62,10 @@
WebView::WebView(QWidget* parent)
: KWebView(parent, false)
- , m_mousePos( QPoint(0,0) )
+ , _mousePos( QPoint(0,0) )
+ , _scrollTimer( new QTimer(this) )
+ , _VScrollSpeed(0)
+ , _HScrollSpeed(0)
{
WebPage *page = new WebPage(this);
setPage(page);
@@ -80,6 +83,10 @@ WebView::WebView(QWidget* parent)
// loadUrl signal
connect(this, SIGNAL(loadUrl(const KUrl &, const Rekonq::OpenType &)),
Application::instance(), SLOT(loadUrl(const KUrl &, const Rekonq::OpenType &)));
+
+ // scrolling timer
+ connect(_scrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged()));
+ _scrollTimer->setInterval(50);
}
@@ -330,7 +337,7 @@ void WebView::mousePressEvent(QMouseEvent *event)
void WebView::mouseMoveEvent(QMouseEvent *event)
{
- m_mousePos = event->pos();
+ _mousePos = event->pos();
if (Application::instance()->mainWindow()->isFullScreen())
{
if (event->pos().y()>=0 && event->pos().y()<=4)
@@ -348,7 +355,7 @@ void WebView::mouseMoveEvent(QMouseEvent *event)
QPoint WebView::mousePos()
{
- return m_mousePos;
+ return _mousePos;
}
@@ -404,16 +411,61 @@ void WebView::openLinkInNewTab()
void WebView::keyPressEvent(QKeyEvent *event)
{
- if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_C))
+ if ( event->modifiers() == Qt::ControlModifier )
{
- triggerPageAction(KWebPage::Copy);
- return;
- }
+ if ( event->key() == Qt::Key_C )
+ {
+ triggerPageAction(KWebPage::Copy);
+ return;
+ }
- if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A))
+ if ( event->key() == Qt::Key_A )
+ {
+ triggerPageAction(KWebPage::SelectAll);
+ return;
+ }
+ }
+
+ if ( event->modifiers() == Qt::ShiftModifier )
{
- triggerPageAction(KWebPage::SelectAll);
- return;
+ kDebug() << "scrolling..";
+ if( event->key() == Qt::Key_Up )
+ {
+ _VScrollSpeed -= 1;
+ _scrollTimer->start();
+ return;
+ }
+
+ if( event->key() == Qt::Key_Down )
+ {
+ _VScrollSpeed += 1;
+ _scrollTimer->start();
+ return;
+ }
+
+ if( event->key() == Qt::Key_Right )
+ {
+ _HScrollSpeed += 1;
+ _scrollTimer->start();
+ return;
+ }
+
+ if( event->key() == Qt::Key_Left )
+ {
+ _HScrollSpeed -= 1;
+ _scrollTimer->start();
+ return;
+ }
+
+ if(_scrollTimer->isActive())
+ {
+ _scrollTimer->stop();
+ }
+ else
+ {
+ if(_VScrollSpeed || _HScrollSpeed)
+ _scrollTimer->start();
+ }
}
KWebView::keyPressEvent(event);
@@ -433,3 +485,19 @@ void WebView::loadUrlInNewTab(const KUrl &url)
{
emit loadUrl(url, Rekonq::SettingOpenTab);
}
+
+
+void WebView::scrollFrameChanged()
+{
+ // do the scrolling
+ page()->currentFrame()->scroll( _HScrollSpeed, _VScrollSpeed );
+
+ // check if we reached the end
+ int y = page()->currentFrame()->scrollPosition().y();
+ if (y == 0 || y == page()->currentFrame()->scrollBarMaximum(Qt::Vertical))
+ _VScrollSpeed = 0;
+
+ int x = page()->currentFrame()->scrollPosition().x();
+ if (x == 0 || x == page()->currentFrame()->scrollBarMaximum(Qt::Horizontal))
+ _HScrollSpeed = 0;
+}
diff --git a/src/webview.h b/src/webview.h
index b0700e8f..59105267 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -30,8 +30,6 @@
// Local Includes
#include "rekonqprivate_export.h"
-
-// Local Includes
#include "application.h"
// KDE Includes
@@ -70,11 +68,17 @@ private slots:
void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
void inspect();
+ void scrollFrameChanged();
+
signals:
void loadUrl(const KUrl &, const Rekonq::OpenType &);
private:
- QPoint m_mousePos;
+ QPoint _mousePos;
+
+ QTimer *_scrollTimer;
+ int _VScrollSpeed;
+ int _HScrollSpeed;
};
#endif