diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-12-08 05:37:49 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-12-08 05:37:49 (GMT) |
commit | cb745eacdb1c1e009f7f115d88dd03bdb9c16180 (patch) | |
tree | cec2e4daa2cef16ff246669cae7f6bc92a404090 /src/declarative | |
parent | d29c53d7d3a69ef1d43be8b77713a970200b8c39 (diff) | |
download | Qt-cb745eacdb1c1e009f7f115d88dd03bdb9c16180.zip Qt-cb745eacdb1c1e009f7f115d88dd03bdb9c16180.tar.gz Qt-cb745eacdb1c1e009f7f115d88dd03bdb9c16180.tar.bz2 |
Use QApplication::startDragDistance() instead of pressDragLength
Make pressTime settable (especially useful to turn it off).
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview.cpp | 36 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p.h | 5 |
2 files changed, 36 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index 1fdf557..85fd0d7 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -103,8 +103,7 @@ public: QBasicTimer pressTimer; QPoint pressPoint; - int pressTime; // milliseconds before it's a "hold" XXX not currently settable - static const int pressDragLength = 15; // XXX #pixels before it's no longer a "hold"; device-specific + int pressTime; // milliseconds before it's a "hold" void updateWindowObjects(); class WindowObjectList : public QmlConcreteList<QObject *> @@ -612,6 +611,28 @@ bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) } } +/*! + \qmlproperty int WebView::pressGrabTime + + The number of milliseconds the user must press before the WebView + starts passing move events through to the web engine (rather than + letting other QML elements such as a Flickable take them). + + Defaults to 400ms. Set to 0 to always grab and pass move events to + the web engine. +*/ +int QmlGraphicsWebView::pressGrabTime() const +{ + Q_D(const QmlGraphicsWebView); + return d->pressTime; +} + +void QmlGraphicsWebView::setPressGrabTime(int ms) +{ + Q_D(QmlGraphicsWebView); + d->pressTime = ms; +} + void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QmlGraphicsWebView); @@ -620,8 +641,13 @@ void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) QMouseEvent *me = sceneMouseEventToMouseEvent(event); d->pressPoint = me->pos(); - d->pressTimer.start(d->pressTime,this); - setKeepMouseGrab(false); + if (d->pressTime) { + d->pressTimer.start(d->pressTime,this); + setKeepMouseGrab(false); + } else { + grabMouse(); + setKeepMouseGrab(true); + } page()->event(me); event->setAccepted( @@ -684,7 +710,7 @@ void QmlGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QMouseEvent *me = sceneMouseEventToMouseEvent(event); if (d->pressTimer.isActive()) { - if ((me->pos() - d->pressPoint).manhattanLength() > d->pressDragLength) { + if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) { d->pressTimer.stop(); } } diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 0b2ba07..f5edb7a 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -99,6 +99,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem Q_PROPERTY(QString html READ html WRITE setHtml) + Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime) + Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged) Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) @@ -135,6 +137,9 @@ public: Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom); QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; + int pressGrabTime() const; + void setPressGrabTime(int); + int preferredWidth() const; void setPreferredWidth(int); int preferredHeight() const; |