forward hover events, so the a:hover properties and such works

accept keyboard focus->forms works :)

svn path=/trunk/KDE/kdelibs/; revision=886923
This commit is contained in:
Marco Martin 2008-11-20 15:38:51 +00:00
parent dff168ecf6
commit 069dc43c79
2 changed files with 20 additions and 1 deletions

View File

@ -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()<<event;
if (!event->isAccepted()) {
QGraphicsWidget::keyPressEvent(event);
}

View File

@ -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);