summaryrefslogtreecommitdiff
path: root/src/webview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp125
1 files changed, 14 insertions, 111 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index cdbb7b11..60bb496b 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -52,17 +52,13 @@
#include <QtGui/QClipboard>
#include <QtGui/QKeyEvent>
#include <QtGui/QAction>
-#include <QtCore/QTimer>
WebView::WebView(QWidget* parent)
: QWebView(parent)
, m_page(new WebPage(this))
, m_progress(0)
- , m_scrollTimer(new QTimer(this))
- , m_scrollDirection(WebView::NoScroll)
- , m_scrollSpeedVertical(0)
- , m_scrollSpeedHorizontal(0)
+ , m_mousePos(QPoint(0,0))
{
setPage(m_page);
@@ -70,9 +66,6 @@ WebView::WebView(QWidget* parent)
connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotUpdateProgress(int)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
-
- connect(m_scrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged()));
- m_scrollTimer->setInterval(50);
}
@@ -333,8 +326,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
menu.addAction(mainwindow->actionByName("page_source"));
-
- menu.addAction(mainwindow->actionByName("add_to_favorites"));
+
QAction *addBookmarkAction = Application::bookmarkProvider()->actionByName("rekonq_add_bookmark");
menu.addAction(addBookmarkAction);
@@ -356,83 +348,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.exec(mapToGlobal(event->pos()));
}
-
-void WebView::stopScrollAnimation()
-{
- m_scrollTimer->stop();
- m_scrollSpeedVertical = 0;
- m_scrollSpeedHorizontal = 0;
- m_scrollDirection = WebView::NoScroll;
-}
-
-
-void WebView::startScrollAnimation(ScrollDirection direction)
-{
- // if no scrollspeed, set the requested direction, otherwise it's just a slowdown or speedup
- if (m_scrollSpeedVertical == 0 && (direction == WebView::Up || direction == WebView::Down))
- m_scrollDirection |= direction;
- if (m_scrollSpeedHorizontal == 0 && (direction == WebView::Left || direction == WebView::Right))
- m_scrollDirection |= direction;
-
- // update scrollspeed
- switch (direction)
- {
- case WebView::Up:
- --m_scrollSpeedVertical;
- break;
- case WebView::Down:
- ++m_scrollSpeedVertical;
- break;
- case WebView::Left:
- --m_scrollSpeedHorizontal;
- break;
- case WebView::Right:
- ++m_scrollSpeedHorizontal;
- break;
- default:
- break;
- }
-
- if (!m_scrollTimer->isActive())
- m_scrollTimer->start();
-
- return;
-}
-
-
-void WebView::scrollFrameChanged()
-{
- // clear finished scrolling
- if (m_scrollSpeedVertical == 0)
- m_scrollDirection &= ~WebView::Up | ~WebView::Down;
- if (m_scrollSpeedHorizontal == 0)
- m_scrollDirection &= ~WebView::Left | ~WebView::Right;
-
- // all scrolling finished
- if (m_scrollDirection == WebView::NoScroll)
- {
- m_scrollTimer->stop();
- return;
- }
-
- // do the scrolling
- page()->currentFrame()->scroll(m_scrollSpeedHorizontal, m_scrollSpeedVertical);
-
- // check if we reached the end
- int y = page()->currentFrame()->scrollPosition().y();
- int x = page()->currentFrame()->scrollPosition().x();
-
- if (y == 0 || y == page()->currentFrame()->scrollBarMaximum(Qt::Vertical))
- m_scrollSpeedVertical = 0;
- if (x == 0 || x == page()->currentFrame()->scrollBarMaximum(Qt::Horizontal))
- m_scrollSpeedHorizontal = 0;
-}
-
-
void WebView::mousePressEvent(QMouseEvent *event)
{
- stopScrollAnimation();
-
m_page->m_pressedButtons = event->buttons();
m_page->m_keyboardModifiers = event->modifiers();
@@ -452,17 +369,18 @@ void WebView::mousePressEvent(QMouseEvent *event)
void WebView::mouseMoveEvent(QMouseEvent *event)
{
- if( url().protocol() != "rekonq" )
- {
- QWebView::mouseMoveEvent(event);
- }
+ m_mousePos = event->pos();
+ QWebView::mouseMoveEvent(event);
+}
+
+QPoint WebView::mousePos()
+{
+ return m_mousePos;
}
void WebView::wheelEvent(QWheelEvent *event)
{
- stopScrollAnimation();
-
if (QApplication::keyboardModifiers() & Qt::ControlModifier)
{
int numDegrees = event->delta() / 8;
@@ -486,13 +404,13 @@ void WebView::slotSearch()
void WebView::slotUpdateProgress(int p)
{
- m_progress=p;
+ m_progress = p;
}
void WebView::slotLoadFinished(bool)
{
- m_progress=0;
+ m_progress = 0;
}
@@ -542,25 +460,10 @@ void WebView::keyPressEvent(QKeyEvent *event)
return;
}
- if (event->modifiers() == Qt::ShiftModifier)
+ if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A))
{
- switch (event->key())
- {
- case Qt::Key_Down:
- startScrollAnimation(WebView::Down);
- return;
- case Qt::Key_Up:
- startScrollAnimation(WebView::Up);
- return;
- case Qt::Key_Left:
- startScrollAnimation(WebView::Left);
- return;
- case Qt::Key_Right:
- startScrollAnimation(WebView::Right);
- return;
- default:
- break;
- }
+ triggerPageAction(QWebPage::SelectAll);
+ return;
}
QWebView::keyPressEvent(event);