summaryrefslogtreecommitdiff
path: root/src/webview.cpp
diff options
context:
space:
mode:
authorFelix Rohrbach <fxrh@gmx.de>2011-04-11 20:03:58 +0200
committerFelix Rohrbach <fxrh@gmx.de>2011-04-11 20:03:58 +0200
commitb5345a5be80a29616d3433ccbda034de80a47734 (patch)
treef4c12bcc21546311dc38887cb77124357474a3f0 /src/webview.cpp
parentMake rekonq desktop aware (diff)
downloadrekonq-b5345a5be80a29616d3433ccbda034de80a47734.tar.xz
firefox-like autoscroll look
Add an icon to indicate the origin of an autoscroll action. Patch by Johannes Tröscher, thanks! REVIEW: 101068
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index f72041bf..7c02ee06 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -72,6 +72,7 @@ WebView::WebView(QWidget* parent)
, m_hScrollSpeed(0)
, m_canEnableAutoScroll(true)
, m_isAutoScrollEnabled(false)
+ , m_autoScrollIndicator(QPixmap(KStandardDirs::locate("appdata" , "pics/autoscroll.png")))
, m_smoothScrollTimer(new QTimer(this))
, m_smoothScrolling(false)
, m_dy(0)
@@ -354,11 +355,11 @@ void WebView::mousePressEvent(QMouseEvent *event)
{
if (m_isAutoScrollEnabled)
{
- setCursor(Qt::ArrowCursor);
m_vScrollSpeed = 0;
m_hScrollSpeed = 0;
m_autoScrollTimer->stop();
m_isAutoScrollEnabled = false;
+ update();
return;
}
@@ -384,9 +385,9 @@ void WebView::mousePressEvent(QMouseEvent *event)
if (!page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).isNull()
|| !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).isNull())
{
- setCursor(KIcon("transform-move").pixmap(32));
m_clickPos = event->pos();
m_isAutoScrollEnabled = true;
+ update();
}
}
break;
@@ -430,15 +431,6 @@ void WebView::mouseMoveEvent(QMouseEvent *event)
}
-void WebView::enterEvent(QEvent *event)
-{
- if (m_isAutoScrollEnabled)
- setCursor(KIcon("transform-move").pixmap(32));
-
- KWebView::enterEvent(event);
-}
-
-
void WebView::dropEvent(QDropEvent *event)
{
bool isEditable = page()->frameAt(event->pos())->hitTestContent(event->pos()).isContentEditable();
@@ -475,6 +467,24 @@ void WebView::dropEvent(QDropEvent *event)
}
}
+
+void WebView::paintEvent(QPaintEvent* event)
+{
+ KWebView::paintEvent(event);
+
+ if (m_isAutoScrollEnabled)
+ {
+ QPoint centeredPoint = m_clickPos;
+ centeredPoint.setX(centeredPoint.x() - m_autoScrollIndicator.width() / 2);
+ centeredPoint.setY(centeredPoint.y() - m_autoScrollIndicator.height() / 2);
+
+ QPainter painter(this);
+ painter.setOpacity(0.8);
+ painter.drawPixmap(centeredPoint, m_autoScrollIndicator);
+ }
+}
+
+
void WebView::search()
{
KAction *a = qobject_cast<KAction*>(sender());