diff --git a/widgets/webview.cpp b/widgets/webview.cpp index 11ab7b14d..8066baa65 100644 --- a/widgets/webview.cpp +++ b/widgets/webview.cpp @@ -57,6 +57,8 @@ WebView::WebView(QGraphicsItem *parent) d->page = 0; d->loaded = false; setPage(new QWebPage(this)); + setAcceptsHoverEvents(true); + setFlags(QGraphicsItem::ItemIsFocusable); } WebView::~WebView() @@ -160,6 +162,20 @@ void WebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } +void WebView::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + if (!d->page) { + QGraphicsWidget::hoverMoveEvent(event); + return; + } + + QMouseEvent me(QEvent::MouseMove, event->pos().toPoint(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + d->page->event(&me); + if (me.isAccepted()) { + event->accept(); + } +} + void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (!d->page) { @@ -167,6 +183,8 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event) return; } + setFocus(); + QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(), event->button(), event->buttons(), event->modifiers()); d->page->event(&me); @@ -247,7 +265,7 @@ void WebView::keyPressEvent(QKeyEvent * event) } d->page->event(event); - +kWarning()<isAccepted()) { QGraphicsWidget::keyPressEvent(event); } diff --git a/widgets/webview.h b/widgets/webview.h index 745cbe746..5ff7d82c5 100644 --- a/widgets/webview.h +++ b/widgets/webview.h @@ -129,6 +129,7 @@ class PLASMA_EXPORT WebView : public QGraphicsWidget */ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);