diff options
Diffstat (limited to 'src/declarative')
9 files changed, 63 insertions, 44 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 3eed8d6..142920c 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,9 @@ ============================================================================= The changes below are pre Qt 4.7.0 RC +TextInput and TextEdit: + - showInputPanelOnFocus property added + - openSoftwareInputPanel() and closeSoftwareInputPanel() functions added Flickable: - overShoot is replaced by boundsBehavior enumeration - flickingHorizontally and flickingVertically properties added diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 1dde510..10dc0f8 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -160,6 +160,7 @@ void QDeclarativeFlickablePrivate::init() q->setFiltersChildEvents(true); QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(viewport)); viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + lastPosTime.invalidate(); } /* @@ -656,7 +657,7 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_Q(QDeclarativeFlickable); - if (!interactive || lastPosTime.isNull()) + if (!interactive || !lastPosTime.isValid()) return; bool rejectY = false; bool rejectX = false; @@ -752,7 +753,7 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv stealMouse = false; q->setKeepMouseGrab(false); pressed = false; - if (lastPosTime.isNull()) + if (!lastPosTime.isValid()) return; if (QDeclarativeItemPrivate::elapsed(lastPosTime) > 100) { @@ -780,7 +781,7 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv fixupX(); } - lastPosTime = QTime(); + lastPosTime.invalidate(); if (!timeline.isActive()) q->movementEnding(); @@ -1218,8 +1219,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) } return stealThisEvent || d->delayedPressEvent; - } else if (!d->lastPosTime.isNull()) { - d->lastPosTime = QTime(); + } else if (d->lastPosTime.isValid()) { + d->lastPosTime.invalidate(); } if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { d->clearDelayedPress(); diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index b467ed2..66d2678 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -140,13 +140,13 @@ public: bool stealMouse : 1; bool pressed : 1; bool interactive : 1; - QTime lastPosTime; + QElapsedTimer lastPosTime; QPointF lastPos; QPointF pressPos; - QTime pressTime; + QElapsedTimer pressTime; qreal deceleration; qreal maxVelocity; - QTime velocityTime; + QElapsedTimer velocityTime; QPointF lastFlickablePosition; qreal reportedVelocitySmoothing; QGraphicsSceneMouseEvent *delayedPressEvent; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 2841ac3..7bd08ce 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -3145,41 +3145,56 @@ QDebug operator<<(QDebug debug, QDeclarativeItem *item) return debug; } -int QDeclarativeItemPrivate::consistentTime = -1; -void QDeclarativeItemPrivate::setConsistentTime(int t) +qint64 QDeclarativeItemPrivate::consistentTime = -1; +void QDeclarativeItemPrivate::setConsistentTime(qint64 t) { consistentTime = t; } -QTime QDeclarativeItemPrivate::currentTime() +class QElapsedTimerConsistentTimeHack { - if (consistentTime == -1) - return QTime::currentTime(); - else - return QTime(0, 0).addMSecs(consistentTime); -} +public: + void start() { + t1 = QDeclarativeItemPrivate::consistentTime; + t2 = 0; + } + qint64 elapsed() { + return QDeclarativeItemPrivate::consistentTime - t1; + } + qint64 restart() { + qint64 val = QDeclarativeItemPrivate::consistentTime - t1; + t1 = QDeclarativeItemPrivate::consistentTime; + t2 = 0; + return val; + } -void QDeclarativeItemPrivate::start(QTime &t) +private: + qint64 t1; + qint64 t2; +}; + +void QDeclarativeItemPrivate::start(QElapsedTimer &t) { - t = currentTime(); + if (QDeclarativeItemPrivate::consistentTime == -1) + t.start(); + else + ((QElapsedTimerConsistentTimeHack*)&t)->start(); } -int QDeclarativeItemPrivate::elapsed(QTime &t) +qint64 QDeclarativeItemPrivate::elapsed(QElapsedTimer &t) { - int n = t.msecsTo(currentTime()); - if (n < 0) // passed midnight - n += 86400 * 1000; - return n; + if (QDeclarativeItemPrivate::consistentTime == -1) + return t.elapsed(); + else + return ((QElapsedTimerConsistentTimeHack*)&t)->elapsed(); } -int QDeclarativeItemPrivate::restart(QTime &t) +qint64 QDeclarativeItemPrivate::restart(QElapsedTimer &t) { - QTime time = currentTime(); - int n = t.msecsTo(time); - if (n < 0) // passed midnight - n += 86400*1000; - t = time; - return n; + if (QDeclarativeItemPrivate::consistentTime == -1) + return t.restart(); + else + return ((QElapsedTimerConsistentTimeHack*)&t)->restart(); } QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 15b34f0..184d6f1 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -305,12 +305,11 @@ public: virtual void focusChanged(bool); - static int consistentTime; - static QTime currentTime(); - static void setConsistentTime(int t); - static void start(QTime &); - static int elapsed(QTime &); - static int restart(QTime &); + static qint64 consistentTime; + static void setConsistentTime(qint64 t); + static void start(QElapsedTimer &); + static qint64 elapsed(QElapsedTimer &); + static qint64 restart(QElapsedTimer &); }; /* diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 3a69f44..448ec06 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -948,7 +948,7 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativePathView); - if (!d->interactive || d->lastPosTime.isNull()) + if (!d->interactive || !d->lastPosTime.isValid()) return; if (!d->stealMouse) { @@ -982,7 +982,7 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) Q_D(QDeclarativePathView); d->stealMouse = false; setKeepMouseGrab(false); - if (!d->interactive || d->lastPosTime.isNull()) + if (!d->interactive || !d->lastPosTime.isValid()) return; qreal elapsed = qreal(d->lastElapsed + QDeclarativeItemPrivate::elapsed(d->lastPosTime)) / 1000.; @@ -1017,7 +1017,7 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) d->fixOffset(); } - d->lastPosTime = QTime(); + d->lastPosTime.invalidate(); ungrabMouse(); } @@ -1059,8 +1059,8 @@ bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) grabMouse(); return d->stealMouse; - } else if (!d->lastPosTime.isNull()) { - d->lastPosTime = QTime(); + } else if (d->lastPosTime.isValid()) { + d->lastPosTime.invalidate(); } return false; } diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index 3abb2f4..a0d2610 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -97,6 +97,7 @@ public: q->setFlag(QGraphicsItem::ItemIsFocusScope); q->setFiltersChildEvents(true); q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); + lastPosTime.invalidate(); } void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { @@ -154,7 +155,7 @@ public: bool autoHighlight : 1; bool highlightUp : 1; bool layoutScheduled : 1; - QTime lastPosTime; + QElapsedTimer lastPosTime; QPointF lastPos; qreal dragMargin; qreal deceleration; diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 167db77..9ccb8d2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1335,7 +1335,7 @@ void QDeclarativeTextEdit::setShowInputPanelOnFocus(bool showOnFocus) void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextEdit); - if (d->showInputPanelOnFocus && !isReadOnly()) { + if (d->showInputPanelOnFocus && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { openSoftwareInputPanel(); } QDeclarativePaintedItem::focusInEvent(event); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 18e3595..9c70ea9 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1282,7 +1282,7 @@ void QDeclarativeTextInput::setShowInputPanelOnFocus(bool showOnFocus) void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextInput); - if (d->showInputPanelOnFocus && !isReadOnly()) { + if (d->showInputPanelOnFocus && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { openSoftwareInputPanel(); } QDeclarativePaintedItem::focusInEvent(event); |