summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapani Mikola <tapani.mikola@nokia.com>2009-08-12 14:46:31 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-08-13 05:08:54 (GMT)
commit8a27eaaa9ca35e1a7ad3ac92c75b6541b7c9db00 (patch)
tree35c3b80f4230fd24d03dbe7db48043ce6683d2c2
parent6fa540ef8c3ae4c920a02b7fc7dfb28309ef5722 (diff)
downloadQt-8a27eaaa9ca35e1a7ad3ac92c75b6541b7c9db00.zip
Qt-8a27eaaa9ca35e1a7ad3ac92c75b6541b7c9db00.tar.gz
Qt-8a27eaaa9ca35e1a7ad3ac92c75b6541b7c9db00.tar.bz2
Change QFxWebView to support hoverMove events (and send them to WebKit as mouseMove:s).
Also sending all the events up as accepted if interactive is on. E.g. push button is not working, if not done so. removed the odd timer based event sending that put e.g. moves and presses in wrong order. Now, the webbrowser is working quite ok!
-rw-r--r--src/declarative/fx/qfxwebview.cpp80
-rw-r--r--src/declarative/fx/qfxwebview.h1
2 files changed, 74 insertions, 7 deletions
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index a80152c..797e6cb 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -247,6 +247,7 @@ void QFxWebView::init()
{
Q_D(QFxWebView);
+ setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);
setFlag(QGraphicsItem::ItemHasNoContents, false);
@@ -632,6 +633,15 @@ static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
return me;
}
+static QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e)
+{
+ QEvent::Type t = QEvent::MouseMove;
+
+ QMouseEvent *me = new QMouseEvent(t, e->pos().toPoint(), Qt::NoButton, Qt::NoButton, 0);
+
+ return me;
+}
+
void QFxWebView::timerEvent(QTimerEvent *event)
{
@@ -692,27 +702,56 @@ void QFxWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxWebView);
if (d->interactive) {
- d->lastPress = sceneMouseEventToMouseEvent(event);
- event->setAccepted(true);
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+ if (d->lastPress) delete d->lastPress;
+ d->lastPress = me;
+ page()->event(me);
+ event->setAccepted(
+ /*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraohucsScene will not send the release event at all to WebKit
+ Might be a bug in WebKit, though
+ */
+#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
} else {
event->setAccepted(false);
}
- if (!event->isAccepted())
+ if (!event->isAccepted()) {
QFxPaintedItem::mousePressEvent(event);
+ }
}
void QFxWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxWebView);
if (d->interactive) {
- d->lastRelease = sceneMouseEventToMouseEvent(event);
+ QMouseEvent *me = sceneMouseEventToMouseEvent(event);
+ if (d->lastRelease) delete d->lastRelease;
+ d->lastRelease = me;
+ page()->event(me);
d->dcTimer.start(MAX_DOUBLECLICK_TIME,this);
- event->setAccepted(true);
+ event->setAccepted(
+ /*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraphicsScene will not send all the events to WebKit
+ */
+#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
} else {
event->setAccepted(false);
}
- if (!event->isAccepted())
+ if (!event->isAccepted()) {
QFxPaintedItem::mouseReleaseEvent(event);
+ }
}
void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -722,7 +761,12 @@ void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QMouseEvent *me = sceneMouseEventToMouseEvent(event);
page()->event(me);
event->setAccepted(
-#if QT_VERSION <= 0x040500 // XXX see bug 230835
+ /*
+ It is not correct to send the press event upwards, if it is not accepted by WebKit
+ e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
+ Might be a bug in WebKit, though
+ */
+#if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835
true
#else
me->isAccepted()
@@ -734,6 +778,28 @@ void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
if (!event->isAccepted())
QFxPaintedItem::mouseMoveEvent(event);
+
+}
+void QFxWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event)
+{
+ Q_D(const QFxWebView);
+ if (d->interactive) {
+ QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event);
+ page()->event(me);
+ event->setAccepted(
+#if QT_VERSION <= 0x040500 // XXX see bug 230835
+ true
+#else
+ me->isAccepted()
+#endif
+ );
+ delete me;
+ }
+ else {
+ event->setAccepted(false);
+ }
+ if (!event->isAccepted())
+ QFxPaintedItem::hoverMoveEvent(event);
}
void QFxWebView::keyPressEvent(QKeyEvent* event)
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 8df3d18..9003377 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -205,6 +205,7 @@ protected:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ void hoverMoveEvent (QGraphicsSceneHoverEvent * event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
void timerEvent(QTimerEvent *event);