From 067b99a053b6f8b1ccab507be8e828b2f72a1e43 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 10:57:57 +0100 Subject: Fix copyright for 0.4 beta release --- src/webview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 232a2633..e1ba2a46 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -2,8 +2,8 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin +* Copyright (C) 2008-2010 by Andrea Diamantini +* Copyright (C) 2009-2010 by Lionel Chauvin * * * This program is free software; you can redistribute it and/or -- cgit v1.2.1 From 871fa5c3a2f0f85f7338171c3d7660167150c69d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 18 Feb 2010 03:26:42 +0100 Subject: half fixed (but half is not enough...) the favicon querelle.. --- src/webview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index e1ba2a46..36f62bfa 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -164,7 +164,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter; data.setData(searchProviderPrefix + "some keyword"); a = new KAction(service->name(), this); - a->setIcon(Application::icon(KUrl(data.uri()))); + a->setIcon( Application::icon( data.uri() ) ); a->setData(searchProviderPrefix); connect(a, SIGNAL(triggered(bool)), this, SLOT(search())); searchMenu->addAction(a); -- cgit v1.2.1 From a013b8f0a260ebedbd74f76bd43b0384ca5e2bc4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Feb 2010 12:10:25 +0100 Subject: Save memory. One WebPage pointer less for each WebView :) --- src/webview.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 36f62bfa..e39ff32e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -62,16 +62,16 @@ WebView::WebView(QWidget* parent) : KWebView(parent, false) - , m_page( new WebPage(this) ) - , m_mousePos(QPoint(0,0)) + , m_mousePos( QPoint(0,0) ) { - setPage(m_page); + WebPage *page = new WebPage(this); + setPage(page); // download system connect(this, SIGNAL(linkShiftClicked(const KUrl &)), - m_page, SLOT(downloadUrl(const KUrl &))); - connect(m_page, SIGNAL(downloadRequested(const QNetworkRequest &)), - m_page, SLOT(downloadRequest(const QNetworkRequest &))); + page, SLOT(downloadUrl(const KUrl &))); + connect(page, SIGNAL(downloadRequested(const QNetworkRequest &)), + page, SLOT(downloadRequest(const QNetworkRequest &))); // middle click || ctrl + click signal connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), @@ -89,6 +89,13 @@ WebView::~WebView() } +WebPage *WebView::page() +{ + WebPage *page = qobject_cast( KWebView::page() ); + return page; +} + + void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); -- cgit v1.2.1 From ab75e99f29bcc76d1c476001eab4d877a564a39b Mon Sep 17 00:00:00 2001 From: megabigbug Date: Mon, 22 Feb 2010 10:45:51 +0100 Subject: select element in webinspector when toggle "Inspect Element" --- src/webview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index e39ff32e..80d44d10 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -425,6 +425,7 @@ void WebView::inspect() QAction *a = Application::instance()->mainWindow()->actionByName("web_inspector"); if(a && !a->isChecked()) a->trigger(); + pageAction(QWebPage::InspectElement)->trigger(); } -- cgit v1.2.1 From a6da0df7e0f72f1d7185e39815c17b7fab07d790 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 31 Mar 2010 10:54:02 +0200 Subject: Auto Scrolling, first bunch. key combinations just work :) --- src/webview.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 10 deletions(-) (limited to 'src/webview.cpp') 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; +} -- cgit v1.2.1 From 1bcb6b3509ee9396d45ab9a400764586ffb29594 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 2 Apr 2010 17:39:35 +0200 Subject: more gentle autoscroll.. less intrusive scrollTimer --- src/webview.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 294b7c85..6e3718e0 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -86,7 +86,7 @@ WebView::WebView(QWidget* parent) // scrolling timer connect(_scrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged())); - _scrollTimer->setInterval(50); + _scrollTimer->setInterval(100); } @@ -426,34 +426,38 @@ void WebView::keyPressEvent(QKeyEvent *event) } } + // Auto Scrolling if ( event->modifiers() == Qt::ShiftModifier ) { - kDebug() << "scrolling.."; if( event->key() == Qt::Key_Up ) { - _VScrollSpeed -= 1; - _scrollTimer->start(); + _VScrollSpeed--; + if( !_scrollTimer->isActive() ) + _scrollTimer->start(); return; } if( event->key() == Qt::Key_Down ) { - _VScrollSpeed += 1; - _scrollTimer->start(); + _VScrollSpeed++; + if( !_scrollTimer->isActive() ) + _scrollTimer->start(); return; } if( event->key() == Qt::Key_Right ) { - _HScrollSpeed += 1; - _scrollTimer->start(); + _HScrollSpeed++; + if( !_scrollTimer->isActive() ) + _scrollTimer->start(); return; } if( event->key() == Qt::Key_Left ) { - _HScrollSpeed -= 1; - _scrollTimer->start(); + _HScrollSpeed--; + if( !_scrollTimer->isActive() ) + _scrollTimer->start(); return; } -- cgit v1.2.1 From 9de0047a2d07dd77905a4d6160b6387af7fac4a0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 5 Apr 2010 00:17:30 +0200 Subject: A "nice" hack to fix bug 211557 BUG: 211557 --- src/webview.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 6e3718e0..2083cef3 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -425,6 +425,14 @@ void WebView::keyPressEvent(QKeyEvent *event) return; } } + + QWebHitTestResult result = page()->mainFrame()->hitTestContent( mapFromGlobal( QCursor::pos() ) ); + + if( result.isContentEditable() ) + { + KWebView::keyPressEvent(event); + return; + } // Auto Scrolling if ( event->modifiers() == Qt::ShiftModifier ) -- cgit v1.2.1 From 969efc9bddcc1b21d1c70f301d8cb0d44904c9c5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 6 Apr 2010 01:20:04 +0200 Subject: I confused mouse cursor with the key one :) Here is another hack to fix bug 211557 DISCLAIMER: this, as the previous, is an hack NOT a solution BUG: 211557 --- src/webview.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 2083cef3..e874411d 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -66,6 +66,7 @@ WebView::WebView(QWidget* parent) , _scrollTimer( new QTimer(this) ) , _VScrollSpeed(0) , _HScrollSpeed(0) + , _disableAutoScroll(false) { WebPage *page = new WebPage(this); setPage(page); @@ -320,6 +321,9 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::mousePressEvent(QMouseEvent *event) { + QWebHitTestResult result = page()->mainFrame()->hitTestContent( event->pos() ); + _disableAutoScroll = result.isContentEditable(); + switch(event->button()) { case Qt::XButton1: @@ -426,9 +430,7 @@ void WebView::keyPressEvent(QKeyEvent *event) } } - QWebHitTestResult result = page()->mainFrame()->hitTestContent( mapFromGlobal( QCursor::pos() ) ); - - if( result.isContentEditable() ) + if(_disableAutoScroll) { KWebView::keyPressEvent(event); return; -- cgit v1.2.1 From 5abfd807fcadc72235872ee874bef85246001a88 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 15 Apr 2010 23:55:38 +0200 Subject: Mouse move autoscroll implementation --- src/webview.cpp | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index e874411d..6f6ec128 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -66,7 +66,8 @@ WebView::WebView(QWidget* parent) , _scrollTimer( new QTimer(this) ) , _VScrollSpeed(0) , _HScrollSpeed(0) - , _disableAutoScroll(false) + , _canEnableAutoScroll(true) + , _isAutoScrollEnabled(false) { WebPage *page = new WebPage(this); setPage(page); @@ -321,27 +322,60 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::mousePressEvent(QMouseEvent *event) { - QWebHitTestResult result = page()->mainFrame()->hitTestContent( event->pos() ); - _disableAutoScroll = result.isContentEditable(); + if(_isAutoScrollEnabled) + { + setCursor(Qt::ArrowCursor); + _VScrollSpeed = 0; + _HScrollSpeed = 0; + _scrollTimer->stop(); + _isAutoScrollEnabled = false; + return; + } + QWebHitTestResult result = page()->mainFrame()->hitTestContent( event->pos() ); + _canEnableAutoScroll = !result.isContentEditable() && result.linkUrl().isEmpty(); + switch(event->button()) { case Qt::XButton1: triggerPageAction(KWebPage::Back); break; + case Qt::XButton2: triggerPageAction(KWebPage::Forward); break; + + case Qt::MidButton: + if(_canEnableAutoScroll && !_isAutoScrollEnabled) + { + setCursor( KIcon("transform-move").pixmap(32) ); + _clickPos = event->pos(); + _isAutoScrollEnabled = true; + } + break; + default: - KWebView::mousePressEvent(event); break; }; + KWebView::mousePressEvent(event); } void WebView::mouseMoveEvent(QMouseEvent *event) { _mousePos = event->pos(); + + if(_isAutoScrollEnabled) + { + QPoint r = _mousePos - _clickPos; + _HScrollSpeed = r.x() / 2; // you are too fast.. + _VScrollSpeed = r.y() / 2; + if( !_scrollTimer->isActive() ) + _scrollTimer->start(); + + return; + } + if (Application::instance()->mainWindow()->isFullScreen()) { if (event->pos().y()>=0 && event->pos().y()<=4) @@ -430,7 +464,7 @@ void WebView::keyPressEvent(QKeyEvent *event) } } - if(_disableAutoScroll) + if(!_canEnableAutoScroll) { KWebView::keyPressEvent(event); return; -- cgit v1.2.1 From 2fc4da5614113a8a184f6bdd05185cc875d9ce27 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Apr 2010 00:58:19 +0200 Subject: deleting replies as explained in QNetworkAccessManager docs --- src/webview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/webview.cpp') diff --git a/src/webview.cpp b/src/webview.cpp index 6f6ec128..f48afffb 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -94,7 +94,8 @@ WebView::WebView(QWidget* parent) WebView::~WebView() { - disconnect(); + delete _scrollTimer; + disconnect(); } -- cgit v1.2.1