From 708e090aef81c59904c483a2ea46b275ef21c7e4 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 19 Apr 2011 12:01:17 +1000 Subject: Fix excessive scrolling in TextInput with mid string pre-edit text. Don't emit text or cursor position changed signals until all the state changes from the input method event are made. Otherwise properties like horizontal scroll are updated based on invalid intermediate data. Change-Id: If543dbe58dc571aeda495152d99be95645eea140 Task-number: QTBUG-18789 Reviewed-by: Martin Jones --- src/gui/widgets/qlinecontrol.cpp | 2 +- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 5a281ad..d03e5de 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -435,7 +435,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) removeSelectedText(); } if (!event->commitString().isEmpty()) { - insert(event->commitString()); + internalInsert(event->commitString()); cursorPositionChanged = true; } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index ef32ee3..943b1fa 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -2285,6 +2285,20 @@ void tst_qdeclarativetextinput::preeditAutoScroll() ic.sendPreeditText(preeditText.mid(0, 3), 1); QCOMPARE(input.positionAt(0), 0); QCOMPARE(input.positionAt(input.width()), 5); + + ic.sendEvent(QInputMethodEvent()); + input.setAutoScroll(true); + // Test committing pre-edit text at the start of the string. QTBUG-18789 + input.setCursorPosition(0); + ic.sendPreeditText(input.text(), 5); + QCOMPARE(input.positionAt(0), 0); + + QInputMethodEvent event; + event.setCommitString(input.text()); + ic.sendEvent(event); + + QCOMPARE(input.positionAt(0), 0); + QCOMPARE(input.positionAt(input.width()), 5); } void tst_qdeclarativetextinput::preeditMicroFocus() -- cgit v0.12 From c6e6a35aeb8794d68a3ca0c4e27a3a1181c066b5 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 20 Apr 2011 08:08:41 +1000 Subject: Make QMLViewer startup animation stop after a while Task-number: QTBUG-18621 --- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 16 ++++++++++++++++ src/declarative/graphicsitems/qdeclarativemousearea_p.h | 3 +++ .../graphicsitems/qdeclarativemousearea_p_p.h | 17 +++++++++++++++++ tools/qml/startup/startup.qml | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index da11b00..47d8f94 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -496,6 +496,9 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) d->pressAndHoldTimer.start(PressAndHoldDelay, this); setKeepMouseGrab(d->stealMouse); event->setAccepted(setPressed(true)); + + if(!event->isAccepted() && d->forwardToList.count()) + d->forwardEvent(event); } } @@ -573,6 +576,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) me.setX(d->lastPos.x()); me.setY(d->lastPos.y()); emit positionChanged(&me); + + if(!event->isAccepted() && d->forwardToList.count()) + d->forwardEvent(event); } @@ -594,6 +600,9 @@ void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (s && s->mouseGrabberItem() == this) ungrabMouse(); setKeepMouseGrab(false); + + if(!event->isAccepted() && d->forwardToList.count()) + d->forwardEvent(event); } d->doubleClick = false; } @@ -959,4 +968,11 @@ QDeclarativeDrag *QDeclarativeMouseArea::drag() */ +QDeclarativeListProperty QDeclarativeMouseArea::forwardTo() +{ + Q_D(QDeclarativeMouseArea); + return d->forwardTo; +} + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h index 985f27e..351d4de 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h @@ -130,6 +130,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged) Q_PROPERTY(QDeclarativeDrag *drag READ drag CONSTANT) //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ??? Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1) + Q_PROPERTY(QDeclarativeListProperty forwardTo READ forwardTo); public: QDeclarativeMouseArea(QDeclarativeItem *parent=0); @@ -157,6 +158,8 @@ public: bool preventStealing() const; void setPreventStealing(bool prevent); + QDeclarativeListProperty forwardTo(); + Q_SIGNALS: void hoveredChanged(); void pressedChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h index 67694fb..7248c92 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h @@ -70,6 +70,8 @@ public: : absorb(true), hovered(false), pressed(false), longPress(false), moved(false), stealMouse(false), doubleClick(false), preventStealing(false), drag(0) { + Q_Q(QDeclarativeMouseArea); + forwardTo = QDeclarativeListProperty(q, forwardToList); } ~QDeclarativeMouseAreaPrivate(); @@ -89,6 +91,18 @@ public: lastModifiers = event->modifiers(); } + void forwardEvent(QGraphicsSceneMouseEvent* event) + { + Q_Q(QDeclarativeMouseArea); + for(int i=0; i < forwardToList.count(); i++){ + event->setPos(forwardToList[i]->mapFromScene(event->scenePos())); + forwardToList[i]->scene()->sendEvent(forwardToList[i], event); + if(event->isAccepted()) + break; + } + event->setPos(q->mapFromScene(event->scenePos())); + } + bool isPressAndHoldConnected() { Q_Q(QDeclarativeMouseArea); static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarativeMouseEvent*)"); @@ -121,6 +135,9 @@ public: Qt::MouseButtons lastButtons; Qt::KeyboardModifiers lastModifiers; QBasicTimer pressAndHoldTimer; + + QDeclarativeListProperty forwardTo; + QList forwardToList; }; QT_END_NAMESPACE diff --git a/tools/qml/startup/startup.qml b/tools/qml/startup/startup.qml index fae7401..a216ac6 100644 --- a/tools/qml/startup/startup.qml +++ b/tools/qml/startup/startup.qml @@ -90,7 +90,7 @@ Rectangle { NumberAnimation on rotation { from: 0 to: 360 - loops: NumberAnimation.Infinite + loops: 3 running: true duration: 2000 } -- cgit v0.12 From e684cfbe8a873040f1e6b0f7fe4bae76a6c1c5de Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 20 Apr 2011 14:01:25 +0200 Subject: Fix Symbian/Linux compilation breakage in plugins/qmltooling use QIODevice header file instead of (wrongly capitablized) QIODevice.h Reviewed-by: Tom Sutcliffe Task-number: QTBUG-18869 --- src/plugins/qmltooling/qmldbg_ost/qostdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h index ba1f443..2c26ff7 100644 --- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h +++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h @@ -42,7 +42,7 @@ #ifndef QOSTDEVICE_H #define QOSTDEVICE_H -#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 5184d55d434296710041812976656ed6825447ec Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 20 Apr 2011 14:16:03 +0200 Subject: QDeclarativeDebug: Fix endless loop for property with SCRITABLE false Trying to read a property marked as non-scriptable results in an endless loop in QDeclarativePropertyCache::create . Task-number: QTBUG-18758 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeenginedebug.cpp | 12 +++++++++--- .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 31fd516..b2a05c3 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -249,10 +249,16 @@ void QDeclarativeEngineDebugServer::buildObjectDump(QDataStream &message, return; } - message << (object->metaObject()->propertyCount() + fakeProperties.count()); + QList propertyIndexes; + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { + if (object->metaObject()->property(ii).isScriptable()) + propertyIndexes << ii; + } + + message << propertyIndexes.size() + fakeProperties.count(); - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) - message << propertyData(object, ii); + for (int ii = 0; ii < propertyIndexes.size(); ++ii) + message << propertyData(object, propertyIndexes.at(ii)); for (int ii = 0; ii < fakeProperties.count(); ++ii) message << fakeProperties[ii]; diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index d01463e..69f9732 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -66,7 +66,6 @@ Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State) - class tst_QDeclarativeDebug : public QObject { Q_OBJECT @@ -118,6 +117,18 @@ private slots: void setBindingInStates(); }; +class NonScriptProperty : public QObject { + Q_OBJECT + Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false) +public: + int nonScriptProp() const { return 0; } + void setNonScriptProp(int) {} +signals: + void nonScriptPropChanged(); +}; +QML_DECLARE_TYPE(NonScriptProperty) + + QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int context, bool recursive) { QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); @@ -282,6 +293,7 @@ void tst_QDeclarativeDebug::compareProperties(const QDeclarativeDebugPropertyRef void tst_QDeclarativeDebug::initTestCase() { qRegisterMetaType(); + qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); QDeclarativeDebugHelper::enableDebugging(); @@ -291,7 +303,8 @@ void tst_QDeclarativeDebug::initTestCase() QList qml; qml << "import QtQuick 1.0\n" - "Item {" + "import Test 1.0\n" + "Item {" "id: root\n" "width: 10; height: 20; scale: blueRect.scale;" "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" @@ -307,6 +320,8 @@ void tst_QDeclarativeDebug::initTestCase() "list[0] = blueRect;\n" "varObjList = list;\n" "}\n" + "NonScriptPropertyElement {\n" + "}\n" "}"; // add second component to test multiple root contexts @@ -725,7 +740,7 @@ void tst_QDeclarativeDebug::queryObject() // check source as defined in main() QDeclarativeDebugFileReference source = obj.source(); QCOMPARE(source.url(), QUrl::fromLocalFile("")); - QCOMPARE(source.lineNumber(), 2); + QCOMPARE(source.lineNumber(), 3); QCOMPARE(source.columnNumber(), 1); // generically test all properties, children and childrens' properties -- cgit v0.12