From b9029c12e143048c7eaef1adec0a554449b052c0 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 12:35:32 +1000 Subject: Fix TextEdit alignment. Vertical never worked. Horizontal broke at 633b4b0655bf47b6f5100ee9a6c2f692b0aeb081. Task-number: QTBUG-10895 --- .../graphicsitems/qdeclarativetextedit.cpp | 45 +++++++++++++--------- .../graphicsitems/qdeclarativetextedit_p_p.h | 4 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 40d37a2970..7b00d2fc46 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -523,7 +523,7 @@ void QDeclarativeTextEdit::setCursorVisible(bool on) QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut); if (!on && !d->persistentSelection) d->control->setCursorIsFocusIndicator(true); - d->control->processEvent(&focusEvent, QPointF(0, 0)); + d->control->processEvent(&focusEvent, QPointF(0, -d->yoff)); emit cursorVisibleChanged(d->cursorVisible); } @@ -860,7 +860,7 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const QRect QDeclarativeTextEdit::cursorRect() const { Q_D(const QDeclarativeTextEdit); - return d->control->cursorRect().toRect(); + return d->control->cursorRect().toRect().translated(0,-d->yoff); } @@ -872,7 +872,7 @@ bool QDeclarativeTextEdit::event(QEvent *event) { Q_D(QDeclarativeTextEdit); if (event->type() == QEvent::ShortcutOverride) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); return event->isAccepted(); } return QDeclarativePaintedItem::event(event); @@ -887,7 +887,7 @@ void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event) Q_D(QDeclarativeTextEdit); keyPressPreHandler(event); if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::keyPressEvent(event); } @@ -901,7 +901,7 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) Q_D(QDeclarativeTextEdit); keyReleasePreHandler(event); if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::keyReleaseEvent(event); } @@ -942,7 +942,7 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) if (!hadFocus && hasFocus()) d->clickCausedFocus = true; if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse) - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mousePressEvent(event); } @@ -959,7 +959,7 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); d->clickCausedFocus = false; - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseReleaseEvent(event); } @@ -972,7 +972,7 @@ void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event { Q_D(QDeclarativeTextEdit); if (d->selectByMouse) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseDoubleClickEvent(event); } else { @@ -988,7 +988,7 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); if (d->selectByMouse) { - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) QDeclarativePaintedItem::mouseMoveEvent(event); event->setAccepted(true); @@ -1004,7 +1004,7 @@ Handles the given input method \a event. void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); + d->control->processEvent(event, QPointF(0, -d->yoff)); } /*! @@ -1026,13 +1026,20 @@ void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds) Q_D(QDeclarativeTextEdit); painter->setRenderHint(QPainter::TextAntialiasing, true); + painter->translate(0,d->yoff); - d->control->drawContents(painter, bounds); + d->control->drawContents(painter, bounds.translated(0,-d->yoff)); + + painter->translate(0,-d->yoff); } -void QDeclarativeTextEdit::updateImgCache(const QRectF &r) +void QDeclarativeTextEdit::updateImgCache(const QRectF &rf) { - dirtyCache(r.toRect()); + Q_D(const QDeclarativeTextEdit); + QRect r = rf.toRect(); + if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything" + r = r.translated(0,d->yoff); + dirtyCache(r); emit update(); } @@ -1141,18 +1148,20 @@ void QDeclarativeTextEdit::updateSize() d->document->setTextWidth(width()); dy -= (int)d->document->size().height(); - int yoff = 0; if (heightValid()) { if (d->vAlign == AlignBottom) - yoff = dy; + d->yoff = dy; else if (d->vAlign == AlignVCenter) - yoff = dy/2; + d->yoff = dy/2; + } else { + d->yoff = 0; } - setBaselineOffset(fm.ascent() + yoff + d->textMargin); + setBaselineOffset(fm.ascent() + d->yoff + d->textMargin); //### need to comfirm cost of always setting these int newWidth = qCeil(d->document->idealWidth()); - d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well? + if (!widthValid()) + d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug) int cursorWidth = 1; if(d->cursor) cursorWidth = d->cursor->width(); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h index 885620d404..d96796cdad 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h @@ -73,7 +73,8 @@ public: persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap), - selectByMouse(false) + selectByMouse(false), + yoff(0) { } @@ -112,6 +113,7 @@ public: QTextControl *control; QDeclarativeTextEdit::WrapMode wrapMode; bool selectByMouse; + int yoff; }; QT_END_NAMESPACE -- cgit v1.2.3 From ff27b0e6a7161db17335dc4aa8724cae75cec39c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 13:09:43 +1000 Subject: Check QML files for license headers too. (but not test data - no test data has license headers) --- tests/auto/headers/tst_headers.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 12c5843740..0538607498 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -64,7 +64,8 @@ private: const QStringList dirFilters, const QRegExp &exclude); static QStringList getHeaders(const QString &path); - static QStringList getSourceFiles(const QString &path); + static QStringList getQmlFiles(const QString &path); + static QStringList getCppFiles(const QString &path); static QStringList getQDocFiles(const QString &path); void allSourceFilesData(); @@ -107,11 +108,16 @@ QStringList tst_Headers::getHeaders(const QString &path) return getFiles(path, QStringList("*.h"), QRegExp("^(?!ui_)")); } -QStringList tst_Headers::getSourceFiles(const QString &path) +QStringList tst_Headers::getCppFiles(const QString &path) { return getFiles(path, QStringList("*.cpp"), QRegExp("^(?!(moc_|qrc_))")); } +QStringList tst_Headers::getQmlFiles(const QString &path) +{ + return getFiles(path, QStringList("*.qml"), QRegExp(".")); +} + QStringList tst_Headers::getQDocFiles(const QString &path) { return getFiles(path, QStringList("*.qdoc"), QRegExp(".")); @@ -153,7 +159,9 @@ void tst_Headers::allSourceFilesData() }; for (int i = 0; i < sizeof(subdirs) / sizeof(subdirs[0]); ++i) { - sourceFiles << getSourceFiles(qtSrcDir + subdirs[i]); + sourceFiles << getCppFiles(qtSrcDir + subdirs[i]); + if (subdirs[i] != QLatin1String("/tests")) + sourceFiles << getQmlFiles(qtSrcDir + subdirs[i]); sourceFiles << getHeaders(qtSrcDir + subdirs[i]); sourceFiles << getQDocFiles(qtSrcDir + subdirs[i]); } -- cgit v1.2.3 From 79446ca4e047e68bea68aef902a5d48478bcc9cc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 14:35:17 +1000 Subject: Don't polish QDeclarativeItems. Avoids unnecessary processing and assumptions we would not want to preserve in the future. Task-number: QTBUG-10217 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 8 +++++++- src/gui/graphicsview/qgraphicsscene.cpp | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 95478844bd..2841ac395c 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2681,7 +2681,13 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) } } -/*! \internal */ +/*! + \reimp + + Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called + during initial widget polishing. Items wishing to optimize start-up construction + should instead consider using componentComplete(). +*/ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, const QVariant &value) { diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 344df3067b..ae0abf9467 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2545,12 +2545,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } - if (d->unpolishedItems.isEmpty()) { - QMetaMethod method = metaObject()->method(d->polishItemsIndex); - method.invoke(this, Qt::QueuedConnection); + // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete + // function allows far more opportunity for delayed-construction optimization. + if (!item->d_ptr->isDeclarativeItem) { + if (d->unpolishedItems.isEmpty()) { + QMetaMethod method = metaObject()->method(d->polishItemsIndex); + method.invoke(this, Qt::QueuedConnection); + } + d->unpolishedItems.append(item); + item->d_ptr->pendingPolish = true; } - d->unpolishedItems.append(item); - item->d_ptr->pendingPolish = true; // Detach this item from its parent if the parent's scene is different // from this scene. -- cgit v1.2.3 From 61bd72461b2f02bdcd316b32de7749eca8692212 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 15:31:15 +1000 Subject: Do not attempt to setParent of object in a different thread QNetworkAccessManager::setCookieJar used to give an error message, now it documents the behavior and avoids the warning. Task-number: QTBUG-10554 --- src/network/access/qnetworkaccessmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 1c7661d5c9..b7539daf5c 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -595,8 +595,9 @@ QNetworkCookieJar *QNetworkAccessManager::cookieJar() const \note QNetworkAccessManager takes ownership of the \a cookieJar object. - QNetworkAccessManager will set the parent of the \a cookieJar - passed to itself, so that the cookie jar is deleted when this + If \a cookieJar is in the same thread as this QNetworkAccessManager, + it will set the parent of the \a cookieJar + so that the cookie jar is deleted when this object is deleted as well. If you want to share cookie jars between different QNetworkAccessManager objects, you may want to set the cookie jar's parent to 0 after calling this function. @@ -621,7 +622,8 @@ void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar) if (d->cookieJar && d->cookieJar->parent() == this) delete d->cookieJar; d->cookieJar = cookieJar; - d->cookieJar->setParent(this); + if (thread() == cookieJar->thread()) + d->cookieJar->setParent(this); } } -- cgit v1.2.3 From 06fbba775078def95f28139483f8645a00941fe5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:14:41 +1000 Subject: Fix visual tests after rename of the qml executable. --- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index f105692c52..71dc451619 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -81,11 +81,11 @@ QString tst_qmlvisual::viewer() QString qmlruntime; #if defined(Q_WS_MAC) - qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml"); + qmlruntime = QDir(binaries).absoluteFilePath("QMLViewer.app/Contents/MacOS/QMLViewer"); #elif defined(Q_WS_WIN) || defined(Q_WS_S60) - qmlruntime = QDir(binaries).absoluteFilePath("qml.exe"); + qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer.exe"); #else - qmlruntime = QDir(binaries).absoluteFilePath("qml"); + qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer"); #endif return qmlruntime; -- cgit v1.2.3 From 8cc8faa6d989b8eb7cd4e78b4a51bbdc3af6ba99 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:16:22 +1000 Subject: Get rid of 'noise' when using GL and the top-level item is an Item. Task-number: QTBUG-10911 --- tools/qml/qmlruntime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 8df250f58d..5136872530 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -1240,7 +1240,8 @@ void QDeclarativeViewer::setUseGL(bool useGL) #endif QGLWidget *glWidget = new QGLWidget(format); - glWidget->setAutoFillBackground(false); + //### potentially faster, but causes junk to appear if top-level is Item, not Rectangle + //glWidget->setAutoFillBackground(false); canvas->setViewport(glWidget); } -- cgit v1.2.3 From 180e2ce2cca53f2c395e8dc9213d714c396c4555 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 24 May 2010 15:40:29 +1000 Subject: Don't crash when assigning a Behavior to a grouped property. Task-number: QTBUG-10799 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativecompiler.cpp | 17 +++++++++++++++++ src/declarative/qml/qdeclarativevmemetaobject.cpp | 2 +- .../qdeclarativebehaviors/data/groupedPropertyCrash.qml | 10 ++++++++++ .../qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 10 ++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index b5bf97204d..d27aceda7d 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1089,6 +1089,23 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj) fetch.line = prop->location.start.line; output->bytecode << fetch; + if (!prop->value->metadata.isEmpty()) { + QDeclarativeInstruction meta; + meta.type = QDeclarativeInstruction::StoreMetaObject; + meta.line = 0; + meta.storeMeta.data = output->indexForByteArray(prop->value->metadata); + meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata); + meta.storeMeta.propertyCache = output->propertyCaches.count(); + // ### Surely the creation of this property cache could be more efficient + QDeclarativePropertyCache *propertyCache = + enginePrivate->cache(prop->value->metaObject()->superClass())->copy(); + propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags, + QDeclarativePropertyCache::Data::IsVMEFunction); + + output->propertyCaches << propertyCache; + output->bytecode << meta; + } + genObjectBody(prop->value); QDeclarativeInstruction pop; diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 13e9c26a5b..7aea7cba41 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -381,7 +381,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *meta, QDeclarativeCompiledData *cdata) -: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext), +: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj, true)->outerContext), metaData(meta), data(0), methods(0), parent(0) { compiledData->addref(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml new file mode 100644 index 0000000000..c052366717 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml @@ -0,0 +1,10 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + Text { + Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } + text: "Hello World" + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 1dc4b533d8..45e53042b6 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -72,6 +72,7 @@ private slots: void disabled(); void dontStart(); void startup(); + void groupedPropertyCrash(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -351,6 +352,15 @@ void tst_qdeclarativebehaviors::startup() } } +//QTBUG-10799 +void tst_qdeclarativebehaviors::groupedPropertyCrash() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml")); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); //don't crash +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" -- cgit v1.2.3 From 56f0ab34eff5282fc0444b95fa359535a96e5c1e Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 24 May 2010 16:19:37 +1000 Subject: Doc fixes --- doc/src/declarative/examples.qdoc | 6 +++--- examples/declarative/README | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index a355f9f10e..6e0426ca09 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -56,17 +56,17 @@ sub-directory that show how to use various aspects of QML. In addition, the applications. These demos are intended to show integrated functionality rather than being instructive on specific elements. -To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qml} +To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qmlviewer} command-line application. It has some useful options, revealed by: \code - bin/qml -help + bin/qmlviewer -help \endcode For example, from your build directory, run: \code - bin/qml $QTDIR/demos/declarative/samegame/samegame.qml + bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml \endcode \section1 Examples diff --git a/examples/declarative/README b/examples/declarative/README index 9e0f4c4266..578c2458a6 100644 --- a/examples/declarative/README +++ b/examples/declarative/README @@ -1,5 +1,5 @@ The Qt Declarative module provides the ability to specify and implement -your UI declaratively, using the Qt Meta-Object Language(QML). This +your user interface declaratively, using the Qt Meta-Object Language (QML). This language is very expressive and human readable, and can be used by designers to actually implement their UI vision. QML UIs can integrate with C++ code in many ways, including being loaded as a part of a C++ UI @@ -9,7 +9,7 @@ The example launcher provided with Qt can be used to explore each of the examples in this directory. But most can also be viewed directly with the QML viewer utility, without requiring compilation. -Documentation for these examples can be found via the Tutorial and Examples +Documentation for these examples can be found via the Tutorials and Examples link in the main Qt documentation. -- cgit v1.2.3 From 82e5ad18fdde7fba4146f28dec897328ec331dff Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 24 May 2010 16:36:56 +1000 Subject: Be slightly more verbose on assigning undefined in binding. Task-number: QTBUG-10303 --- src/declarative/qml/qdeclarativebinding.cpp | 4 +++- .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 10 +++++----- .../declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 823094195c..7385728c43 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -191,7 +191,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) data->error.setUrl(url); data->error.setLine(line); data->error.setColumn(-1); - data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType()))); + data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + + QLatin1String(QMetaType::typeName(data->property.propertyType())) + + QLatin1String(" ") + data->property.name()); } else if (!scriptValue.isRegExp() && scriptValue.isFunction()) { diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 9a8ad647fe..e75abacc11 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -564,7 +564,7 @@ void tst_qdeclarativeecmascript::deferredPropertiesErrors() QVERIFY(object->objectProperty() == 0); QVERIFY(object->objectProperty2() == 0); - QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*"; + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject* objectProperty"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); qmlExecuteDeferred(object); @@ -642,8 +642,8 @@ void tst_qdeclarativeecmascript::enums() { QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml")); - QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int"; - QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int"; + QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int a"; + QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int b"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -754,7 +754,7 @@ void tst_qdeclarativeecmascript::nonExistantAttachedObject() { QDeclarativeComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml")); - QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString"; + QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString stringProperty"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QObject *object = component.create(); @@ -1001,7 +1001,7 @@ void tst_qdeclarativeecmascript::scriptErrors() QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning6 = url + ":7: Unable to assign [undefined] to int"; + QString warning6 = url + ":7: Unable to assign [undefined] to int x"; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index b0db7710b4..0aebea1bdb 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -266,7 +266,7 @@ void tst_qdeclarativeengine::outputWarningsToStandardError() delete o; QCOMPARE(warnings.count(), 1); - QCOMPARE(warnings.at(0), QLatin1String(":1: Unable to assign [undefined] to int")); + QCOMPARE(warnings.at(0), QLatin1String(":1: Unable to assign [undefined] to int a")); warnings.clear(); -- cgit v1.2.3 From 034641277fa71825470f1300f6950b97fdfd6098 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 24 May 2010 17:00:03 +1000 Subject: Remove incorrect ASSERT QTBUG-10832 --- src/declarative/qml/qdeclarativebinding.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 7385728c43..882e981555 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -355,8 +355,6 @@ void QDeclarativeAbstractBinding::removeFromObject() if (m_prevBinding) { int index = propertyIndex(); - Q_ASSERT(m_object); - *m_prevBinding = m_nextBinding; if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding; m_prevBinding = 0; @@ -365,7 +363,7 @@ void QDeclarativeAbstractBinding::removeFromObject() if (index & 0xFF000000) { // Value type - we don't remove the proxy from the object. It will sit their happily // doing nothing for ever more. - } else { + } else if (m_object) { QDeclarativeData *data = QDeclarativeData::get(m_object, false); if (data) data->clearBindingBit(index); } -- cgit v1.2.3 From 4c975ee19b9671fbf76b546fc8ca2eff5bc69303 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 24 May 2010 17:11:00 +1000 Subject: Compiler warning QTBUG-10816 --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 8b64e0e77e..aca01b2ace 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -623,7 +623,7 @@ private: inline void cleanup(); - void *data[4]; + char data[4 * sizeof(void *)]; int type; }; } -- cgit v1.2.3 From 1079096a57112d9615812771adba18d2e9297320 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 24 May 2010 20:02:57 +1000 Subject: Added autotest for Component.createObject() without Qt.createComponent() Also augmented the docs for both functions a little. Task-number: QTBUG-10926 --- doc/src/declarative/declarativeui.qdoc | 2 +- doc/src/declarative/dynamicobjects.qdoc | 4 ++-- doc/src/snippets/declarative/Sprite.qml | 2 ++ doc/src/snippets/declarative/createComponent.qml | 2 ++ src/declarative/qml/qdeclarativecomponent.cpp | 10 +++++--- src/declarative/qml/qdeclarativeengine.cpp | 4 ++-- .../qdeclarativecomponent/data/createObject.qml | 16 +++++++++++++ .../tst_qdeclarativecomponent.cpp | 28 ++++++++++++++++++++++ 8 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativecomponent/data/createObject.qml diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 5283ba80c3..1199b264ac 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -98,7 +98,7 @@ application or to build completely new applications. QML is fully \l \o \l {qdeclarativemodules.html}{Modules} \o \l {qdeclarativefocus.html}{Keyboard Focus} \o \l {Extending types from QML} -\o \l {Dynamic Object Creation} +\o \l {qdeclarativedynamicobjects.html}{Dynamic Object Creation} \o \l {qmlruntime.html}{The Qt Declarative Runtime} \endlist diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 2688ee511d..633489bcc0 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -75,12 +75,12 @@ the parent later you can safely pass null to this function. Here is an example. Here is a \c Sprite.qml, which defines a simple QML component: -\quotefile doc/src/snippets/declarative/Sprite.qml +\snippet doc/src/snippets/declarative/Sprite.qml 0 Our main application file, \c main.qml, imports a \c componentCreation.js JavaScript file that will create \c Sprite objects: -\quotefile doc/src/snippets/declarative/createComponent.qml +\snippet doc/src/snippets/declarative/createComponent.qml 0 Here is \c componentCreation.js. Remember that QML files that might be loaded over the network cannot be expected to be ready immediately: diff --git a/doc/src/snippets/declarative/Sprite.qml b/doc/src/snippets/declarative/Sprite.qml index b306cb084d..5f32b0ae80 100644 --- a/doc/src/snippets/declarative/Sprite.qml +++ b/doc/src/snippets/declarative/Sprite.qml @@ -39,6 +39,8 @@ ** ****************************************************************************/ +//![0] import Qt 4.7 Rectangle { width: 80; height: 50; color: "red" } +//![0] diff --git a/doc/src/snippets/declarative/createComponent.qml b/doc/src/snippets/declarative/createComponent.qml index 910ea95ef5..3686188c45 100644 --- a/doc/src/snippets/declarative/createComponent.qml +++ b/doc/src/snippets/declarative/createComponent.qml @@ -39,6 +39,7 @@ ** ****************************************************************************/ +//![0] import Qt 4.7 import "componentCreation.js" as MyModule @@ -48,3 +49,4 @@ Rectangle { Component.onCompleted: MyModule.createSpriteObjects(); } +//![0] diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 3b782e71d2..7aa17e8e6b 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -549,15 +549,19 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q Returns an object instance from this component, or null if object creation fails. The object will be created in the same context as the one in which the component - was created. + was created. This function will always return null when called on components + which were not created in QML. Note that if the returned object is to be displayed, its \c parent must be set to - an existing item in a scene, or else the object will not be visible. + an existing item in a scene, or else the object will not be visible. The parent + argument is required to help you avoid this, you must explicitly pass in null if + you wish to create an object without setting a parent. */ /*! \internal - A version of create which returns a scriptObject, for use in script + A version of create which returns a scriptObject, for use in script. + This function will only work on components created in QML. Sets graphics object parent because forgetting to do this is a frequent and serious problem. diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index df9aa593fb..a7384a95a6 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1049,9 +1049,9 @@ If you are certain the files will be local, you could simplify to: \snippet doc/src/snippets/declarative/componentCreation.js 2 -The methods and properties of the Component element are defined in its own +The methods and properties of the \l {Component} element are defined in its own page, but when using it dynamically only two methods are usually used. -\c Component.createObject() returns the created object or \c null if there is an error. + \l {Component::createObject()}{Component.createObject()} returns the created object or \c null if there is an error. If there is an error, \l {Component::errorString()}{Component.errorString()} describes the error that occurred. Note that createObject() takes exactly one argument, which is set to the parent of the created object. Graphical objects without a parent will not appear diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml new file mode 100644 index 0000000000..4ee1e75c89 --- /dev/null +++ b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Item{ + id: root + property QtObject qobject : null + property QtObject declarativeitem : null + property QtObject graphicswidget: null + Component{id: a; QtObject{} } + Component{id: b; Item{} } + Component{id: c; QGraphicsWidget{} } + Component.onCompleted: { + root.qobject = a.createObject(root); + root.declarativeitem = b.createObject(root); + root.graphicswidget = c.createObject(root); + } +} diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index c9e304cc26..faa1c212cd 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -39,7 +39,9 @@ ** ****************************************************************************/ #include +#include +#include #include #include @@ -51,6 +53,7 @@ public: private slots: void loadEmptyUrl(); + void qmlCreateObject(); private: QDeclarativeEngine engine; @@ -70,6 +73,31 @@ void tst_qdeclarativecomponent::loadEmptyUrl() QCOMPARE(error.description(), QLatin1String("Invalid empty URL")); } +void tst_qdeclarativecomponent::qmlCreateObject() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/createObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *testObject1 = object->property("qobject").value(); + QVERIFY(testObject1); + QVERIFY(testObject1->parent() == object); + + QObject *testObject2 = object->property("declarativeitem").value(); + QVERIFY(testObject2); + QVERIFY(testObject2->parent() == object); + QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem"); + + //Note that QGraphicsObjects are not exposed to QML for instantiation, and so can't be used in a component directly + //Also this is actually the extended type QDeclarativeGraphicsWidget, but it still doesn't inherit QDeclarativeItem + QGraphicsObject *testObject3 = qobject_cast(object->property("graphicswidget").value()); + QVERIFY(testObject3); + QVERIFY(testObject3->parent() == object); + QVERIFY(testObject3->parentItem() == qobject_cast(object)); + QCOMPARE(testObject3->metaObject()->className(), "QDeclarativeGraphicsWidget"); +} + QTEST_MAIN(tst_qdeclarativecomponent) #include "tst_qdeclarativecomponent.moc" -- cgit v1.2.3 From af84e21c40d3441546b22f631fc2d34a48580740 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 24 May 2010 15:49:43 +0200 Subject: Fix typo --- examples/declarative/animation/easing/easing.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml index 939d43bf49..6d30cf4502 100644 --- a/examples/declarative/animation/easing/easing.qml +++ b/examples/declarative/animation/easing/easing.qml @@ -36,7 +36,7 @@ Rectangle { ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.InElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } -- cgit v1.2.3 From 3af5a362a034fe7f9085a202adfdf13252de1715 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 24 May 2010 21:02:51 +0200 Subject: Integrate some QML examples and demos into qtdemo Includes minor changes and additions to the existing doc and examples, so that they follow Qt conventions better. Note that while blurring the background was part of the plan for the embedded QML viewer I could not get it to perform well enough. In the future, when blur is fast enough (or someone else can get it to perform better than I) -use-blur should become the default, and -no-blur the option. Task-number: QTBUG-10582 --- demos/qtdemo/MagicAnim.qml | 19 ++++ demos/qtdemo/colors.cpp | 4 + demos/qtdemo/colors.h | 1 + demos/qtdemo/mainwindow.cpp | 23 +++- demos/qtdemo/mainwindow.h | 3 + demos/qtdemo/menumanager.cpp | 110 +++++++++++++++++-- demos/qtdemo/menumanager.h | 9 +- demos/qtdemo/qmlShell.qml | 117 +++++++++++++++++++++ demos/qtdemo/qtdemo.pro | 5 +- demos/qtdemo/qtdemo.qrc | 18 ++-- demos/qtdemo/xml/examples.xml | 36 +++++-- doc/src/examples/qml-examples.qdoc | 41 ++++++-- doc/src/examples/qml-flickr.qdoc | 2 +- doc/src/examples/qml-minehunt.qdoc | 5 +- doc/src/examples/qml-photoviewer.qdoc | 2 +- doc/src/examples/qml-rssnews.qdoc | 2 +- doc/src/examples/qml-samegame.qdoc | 5 +- doc/src/examples/qml-snake.qdoc | 5 +- doc/src/examples/qml-twitter.qdoc | 50 +++++++++ doc/src/images/qml-clocks-example.png | Bin 0 -> 40742 bytes doc/src/images/qml-corkboards-example.png | Bin 0 -> 179625 bytes doc/src/images/qml-dialcontrol-example.png | Bin 0 -> 33569 bytes doc/src/images/qml-dynamicscene-example.png | Bin 0 -> 65247 bytes doc/src/images/qml-flickr-demo.png | Bin 0 -> 280730 bytes doc/src/images/qml-flickr-example.png | Bin 280730 -> 0 bytes doc/src/images/qml-flipable-example.png | Bin 0 -> 13301 bytes doc/src/images/qml-minehunt-demo.png | Bin 0 -> 170648 bytes doc/src/images/qml-minehunt-example.png | Bin 170648 -> 0 bytes doc/src/images/qml-photoviewer-demo.png | Bin 0 -> 473306 bytes doc/src/images/qml-photoviewer-example.png | Bin 473306 -> 0 bytes doc/src/images/qml-progressbar-example.png | Bin 0 -> 15188 bytes doc/src/images/qml-rssnews-demo.png | Bin 0 -> 143314 bytes doc/src/images/qml-rssnews-example.png | Bin 143314 -> 0 bytes doc/src/images/qml-samegame-demo.png | Bin 0 -> 285415 bytes doc/src/images/qml-samegame-example.png | Bin 285415 -> 0 bytes doc/src/images/qml-searchbox-example.png | Bin 0 -> 8170 bytes doc/src/images/qml-slideswitch-example.png | Bin 0 -> 8298 bytes doc/src/images/qml-snake-demo.png | Bin 0 -> 105053 bytes doc/src/images/qml-snake-example.png | Bin 105053 -> 0 bytes doc/src/images/qml-spinner-example.png | Bin 0 -> 5637 bytes doc/src/images/qml-tabwidget-example.png | Bin 0 -> 6487 bytes doc/src/images/qml-tic-tac-toe-example.png | Bin 0 -> 24275 bytes doc/src/images/qml-tvtennis-example.png | Bin 0 -> 2070 bytes doc/src/images/qml-twitter-demo.png | Bin 0 -> 95812 bytes examples/declarative/toys/README | 2 +- .../declarative/toys/dial-example/content/Dial.qml | 83 --------------- .../toys/dial-example/content/background.png | Bin 35876 -> 0 bytes .../toys/dial-example/content/needle.png | Bin 342 -> 0 bytes .../toys/dial-example/content/needle_shadow.png | Bin 632 -> 0 bytes .../toys/dial-example/content/overlay.png | Bin 3564 -> 0 bytes .../declarative/toys/dial-example/dial-example.qml | 90 ---------------- .../declarative/toys/dial-example/dial.qmlproject | 16 --- .../declarative/toys/tic-tac-toe/tic-tac-toe.qml | 1 - examples/declarative/ui-components/README | 39 +++++++ .../ui-components/dialcontrol/content/Dial.qml | 83 +++++++++++++++ .../dialcontrol/content/background.png | Bin 0 -> 35876 bytes .../ui-components/dialcontrol/content/needle.png | Bin 0 -> 342 bytes .../dialcontrol/content/needle_shadow.png | Bin 0 -> 632 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 0 -> 3564 bytes .../ui-components/dialcontrol/dial.qmlproject | 16 +++ .../ui-components/dialcontrol/dialcontrol.qml | 90 ++++++++++++++++ .../ui-components/flipable/flipable-example.qml | 55 ---------- .../ui-components/flipable/flipable.qml | 55 ++++++++++ .../declarative/ui-components/progressbar/main.qml | 73 +++++++++++++ .../ui-components/progressbar/progressbars.qml | 73 ------------- .../ui-components/scrollbar/display.qml | 94 ----------------- .../declarative/ui-components/scrollbar/main.qml | 94 +++++++++++++++++ .../declarative/ui-components/tabwidget/main.qml | 99 +++++++++++++++++ .../declarative/ui-components/tabwidget/tabs.qml | 99 ----------------- 69 files changed, 962 insertions(+), 557 deletions(-) create mode 100644 demos/qtdemo/MagicAnim.qml create mode 100644 demos/qtdemo/qmlShell.qml create mode 100644 doc/src/examples/qml-twitter.qdoc create mode 100644 doc/src/images/qml-clocks-example.png create mode 100644 doc/src/images/qml-corkboards-example.png create mode 100644 doc/src/images/qml-dialcontrol-example.png create mode 100644 doc/src/images/qml-dynamicscene-example.png create mode 100644 doc/src/images/qml-flickr-demo.png delete mode 100644 doc/src/images/qml-flickr-example.png create mode 100644 doc/src/images/qml-flipable-example.png create mode 100644 doc/src/images/qml-minehunt-demo.png delete mode 100644 doc/src/images/qml-minehunt-example.png create mode 100644 doc/src/images/qml-photoviewer-demo.png delete mode 100644 doc/src/images/qml-photoviewer-example.png create mode 100644 doc/src/images/qml-progressbar-example.png create mode 100644 doc/src/images/qml-rssnews-demo.png delete mode 100644 doc/src/images/qml-rssnews-example.png create mode 100644 doc/src/images/qml-samegame-demo.png delete mode 100644 doc/src/images/qml-samegame-example.png create mode 100644 doc/src/images/qml-searchbox-example.png create mode 100644 doc/src/images/qml-slideswitch-example.png create mode 100644 doc/src/images/qml-snake-demo.png delete mode 100644 doc/src/images/qml-snake-example.png create mode 100644 doc/src/images/qml-spinner-example.png create mode 100644 doc/src/images/qml-tabwidget-example.png create mode 100644 doc/src/images/qml-tic-tac-toe-example.png create mode 100644 doc/src/images/qml-tvtennis-example.png create mode 100644 doc/src/images/qml-twitter-demo.png delete mode 100644 examples/declarative/toys/dial-example/content/Dial.qml delete mode 100644 examples/declarative/toys/dial-example/content/background.png delete mode 100644 examples/declarative/toys/dial-example/content/needle.png delete mode 100644 examples/declarative/toys/dial-example/content/needle_shadow.png delete mode 100644 examples/declarative/toys/dial-example/content/overlay.png delete mode 100644 examples/declarative/toys/dial-example/dial-example.qml delete mode 100644 examples/declarative/toys/dial-example/dial.qmlproject create mode 100644 examples/declarative/ui-components/README create mode 100644 examples/declarative/ui-components/dialcontrol/content/Dial.qml create mode 100644 examples/declarative/ui-components/dialcontrol/content/background.png create mode 100644 examples/declarative/ui-components/dialcontrol/content/needle.png create mode 100644 examples/declarative/ui-components/dialcontrol/content/needle_shadow.png create mode 100644 examples/declarative/ui-components/dialcontrol/content/overlay.png create mode 100644 examples/declarative/ui-components/dialcontrol/dial.qmlproject create mode 100644 examples/declarative/ui-components/dialcontrol/dialcontrol.qml delete mode 100644 examples/declarative/ui-components/flipable/flipable-example.qml create mode 100644 examples/declarative/ui-components/flipable/flipable.qml create mode 100644 examples/declarative/ui-components/progressbar/main.qml delete mode 100644 examples/declarative/ui-components/progressbar/progressbars.qml delete mode 100644 examples/declarative/ui-components/scrollbar/display.qml create mode 100644 examples/declarative/ui-components/scrollbar/main.qml create mode 100644 examples/declarative/ui-components/tabwidget/main.qml delete mode 100644 examples/declarative/ui-components/tabwidget/tabs.qml diff --git a/demos/qtdemo/MagicAnim.qml b/demos/qtdemo/MagicAnim.qml new file mode 100644 index 0000000000..f2ee80630f --- /dev/null +++ b/demos/qtdemo/MagicAnim.qml @@ -0,0 +1,19 @@ +import Qt 4.7 + +//Emulates the in animation of the menu elements +SequentialAnimation{ + id: main; + property Item target + property int from: 0 + property int to: 100 + property int duration: 1000 + property string properties: "y" + PauseAnimation { duration: main.duration*0.20 } + NumberAnimation { target: main.target; properties: main.properties; from: main.from; to: main.to + 40; duration: main.duration*0.30 } + NumberAnimation { target: main.target; properties: main.properties; from: main.to + 40; to: main.to; duration: main.duration*0.10 } + NumberAnimation { target: main.target; properties: main.properties; from: main.to; to: main.to + 20; duration: main.duration*0.10 } + NumberAnimation { target: main.target; properties: main.properties; from: main.to + 20; to: main.to; duration: main.duration*0.10 } + NumberAnimation { target: main.target; properties: main.properties; from: main.to; to: main.to + 8; duration: main.duration*0.10 } + NumberAnimation { target: main.target; properties: main.properties; from: main.to + 8; to: main.to; duration: main.duration*0.10 } +} + diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp index 802d77d232..07cf1627ed 100644 --- a/demos/qtdemo/colors.cpp +++ b/demos/qtdemo/colors.cpp @@ -81,6 +81,7 @@ bool Colors::noRescale = false; bool Colors::noAnimations = false; bool Colors::noBlending = false; bool Colors::noScreenSync = false; +bool Colors::noBlur = true; bool Colors::fullscreen = false; bool Colors::usePixmaps = false; bool Colors::useLoop = false; @@ -232,6 +233,8 @@ void Colors::parseArgs(int argc, char *argv[]) Colors::showFps = true; else if (s == "-no-blending") Colors::noBlending = true; + else if (s == "-use-blur") + Colors::noBlur = false; else if (s == "-no-sync") Colors::noScreenSync = true; else if (s.startsWith("-menu")) @@ -295,6 +298,7 @@ void Colors::setLowSettings() Colors::usePixmaps = true; Colors::noAnimations = true; Colors::noBlending = true; + Colors::noBlur = true; } void Colors::detectSystemResources() diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h index 1e0b795970..2d58058e7a 100644 --- a/demos/qtdemo/colors.h +++ b/demos/qtdemo/colors.h @@ -91,6 +91,7 @@ public: static bool noAnimations; static bool noBlending; static bool noScreenSync; + static bool noBlur; static bool useLoop; static bool noWindowMask; static bool usePixmaps; diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp index a679c4f505..45ec9a6d43 100644 --- a/demos/qtdemo/mainwindow.cpp +++ b/demos/qtdemo/mainwindow.cpp @@ -270,8 +270,10 @@ void MainWindow::setupSceneItems() this->fpsLabel->setPos(Colors::stageStartX, 600 - QFontMetricsF(Colors::buttonFont()).height() - 5); } - this->companyLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, 0, true, 0.5f); - this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, 0, true, 0.5f); + this->mainSceneRoot = new QGraphicsWidget(); + this->scene->addItem(mainSceneRoot); + this->companyLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, mainSceneRoot, true, 0.5f); + this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, mainSceneRoot, true, 0.5f); this->companyLogo->setZValue(100); this->qtLogo->setZValue(100); this->pausedLabel = new DemoTextItem(QString("PAUSED"), Colors::buttonFont(), Qt::white, -1, this->scene, 0); @@ -308,6 +310,20 @@ void MainWindow::checkAdapt() qDebug() << "- benchmark adaption: removed ticker (fps < 30)"; } + //Note: Because we don't adapt later in the program, if blur makes FPS plummet then we won't catch it + if (!Colors::noBlur && MenuManager::instance()->mainSceneBlur && this->mainSceneRoot){ + Colors::noBlur = true; + this->mainSceneRoot->setGraphicsEffect(0); + MenuManager::instance()->mainSceneBlur = 0; + if(MenuManager::instance()->qmlRoot){ + MenuManager::instance()->qmlRoot->setGraphicsEffect(0); + MenuManager::instance()->declarativeEngine->rootContext()->setContextProperty("realBlur", 0); + } + MenuManager::instance()->qmlShadow = 0; + if (Colors::verbose) + qDebug() << "- benchmark adaption: removed blur (fps < 30)"; + } + if (this->fpsMedian < 20){ Colors::noAnimations = true; if (Colors::verbose) @@ -376,7 +392,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) this->loop = false; QApplication::quit(); } - else if (event->key() == Qt::Key_1){ + else if (event->key() == Qt::Key_F1){ QString s(""); s += "Rendering system: "; if (Colors::openGlRendering) @@ -415,6 +431,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) s += Colors::noScreenSync ? "no" : "yes"; QMessageBox::information(0, QString("Current configuration"), s); } + QGraphicsView::keyPressEvent(event); } void MainWindow::focusInEvent(QFocusEvent *) diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h index edcc14695d..e61326827f 100644 --- a/demos/qtdemo/mainwindow.h +++ b/demos/qtdemo/mainwindow.h @@ -43,6 +43,7 @@ #define MAIN_WINDOW_H #include +#include #include class DemoTextItem; @@ -62,6 +63,8 @@ public: void start(); QGraphicsScene *scene; + QGraphicsWidget* mainSceneRoot; + bool loop; // FPS stuff: diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 40af30fed0..9eb5664317 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -59,6 +59,8 @@ MenuManager::MenuManager() this->tickerInAnim = 0; this->upButton = 0; this->downButton = 0; + this->mainSceneBlur = 0; + this->qmlShadow = 0; this->helpEngine = 0; this->score = new Score(); this->currentMenu = QLatin1String("[no menu visible]"); @@ -152,6 +154,9 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) case LAUNCH: this->launchExample(this->currentInfo); break; + case LAUNCH_QML: + this->launchQmlExample(this->currentInfo); + break; case DOCUMENTATION: this->showDocInAssistant(this->currentInfo); break; @@ -169,6 +174,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) this->score->queueMovie(this->currentInfo + " -out"); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie("back -out", Score::ONLY_IF_VISIBLE); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = ROOT; this->currentMenu = menuName + " -menu1"; @@ -191,6 +198,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS); this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS); this->score->queueMovie(this->currentInfo + " -out"); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU1; this->currentCategory = menuName; @@ -208,6 +217,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) // out: this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU2; this->currentInfo = menuName; @@ -242,6 +253,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) // out: this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU1; this->currentMenuButtons = this->currentCategory + " -buttons"; @@ -343,6 +356,35 @@ void MenuManager::launchExample(const QString &name) #endif } +void MenuManager::launchQmlExample(const QString &name) +{ + if(!qmlRoot){ + exampleError(QProcess::UnknownError); + return; + } + //resolveQmlFilename - refactor to separate fn? + QString dirName = this->info[name]["dirname"]; + QString category = this->info[name]["category"]; + QString fileName = this->info[name]["filename"]; + QDir dir; + if (category == "demos") + dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath)); + else + dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath)); + QFile file(dir.path() + "/" + dirName + "/" + fileName + "/" + fileName.split('/').last() + ".qml"); + if(!file.exists()){ + //try main.qml as well + file.setFileName(dir.path() + "/" + dirName + "/" + fileName + "/" + "main.qml"); + if(!file.exists()){ + exampleError(QProcess::UnknownError); + return; + } + } + + qmlRoot->setProperty("show", QVariant(true)); + qmlRoot->setProperty("source", file.fileName()); +} + void MenuManager::exampleFinished() { } @@ -359,6 +401,15 @@ void MenuManager::init(MainWindow *window) { this->window = window; + //Create blur for later use + // Note that blur is DISABLED by default because it's too slow, even on Desktop machines + if(!Colors::noBlur){ + this->mainSceneBlur = new QGraphicsBlurEffect(this); + this->mainSceneBlur->setEnabled(false); + this->mainSceneBlur->setBlurRadius(0); + this->window->mainSceneRoot->setGraphicsEffect(mainSceneBlur); + } + // Create div: this->createTicker(); this->createUpnDownButtons(); @@ -385,6 +436,37 @@ void MenuManager::init(MainWindow *window) level2MenuNode = level2MenuNode.nextSibling(); } + + // Create QML Loader + qmlRegisterType("Effects", 1, 0, "Blur"); + declarativeEngine = new QDeclarativeEngine(this); + MenuManager::instance()->declarativeEngine->rootContext()->setContextProperty("realBlur", this->mainSceneBlur); + QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); + qmlRoot = 0; + if(component.isReady()) + qmlRoot = qobject_cast(component.create()); + else + qDebug() << component.status() << component.errorString(); + if(qmlRoot){ + qmlRoot->setHeight(this->window->scene->sceneRect().height()); + qmlRoot->setWidth(this->window->scene->sceneRect().width()); + qmlRoot->setZValue(1000);//Above other items + qmlRoot->setCursor(Qt::ArrowCursor); + window->scene->addItem(qmlRoot); + if(!Colors::noBlur){ + qmlShadow = new QGraphicsDropShadowEffect(this); + qmlShadow->setOffset(4); + qmlRoot->setGraphicsEffect(qmlShadow); + } + + //Note that QML adds key handling to the app. + window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling + window->setFocusPolicy(Qt::StrongFocus); + window->scene->setStickyFocus(true); + window->setFocus(); + }else{ + qDebug() << "Error intializing QML subsystem, Declarative examples will not work"; + } } void MenuManager::readInfoAboutExample(const QDomElement &example) @@ -392,13 +474,14 @@ void MenuManager::readInfoAboutExample(const QDomElement &example) QString name = example.attribute("name"); if (this->info.contains(name)) qWarning() << "__WARNING: MenuManager::readInfoAboutExample: Demo/example with name" - << name << "appears twize in the xml-file!__"; + << name << "appears twice in the xml-file!__"; this->info[name]["filename"] = example.attribute("filename"); this->info[name]["category"] = example.parentNode().toElement().tagName(); this->info[name]["dirname"] = example.parentNode().toElement().attribute("dirname"); this->info[name]["changedirectory"] = example.attribute("changedirectory"); this->info[name]["image"] = example.attribute("image"); + this->info[name]["qml"] = example.attribute("qml"); } QString MenuManager::resolveDataDir(const QString &name) @@ -454,7 +537,7 @@ QString MenuManager::resolveDocUrl(const QString &name) QString fileName = this->info[name]["filename"]; if (category == "demos") - return this->helpRootUrl + "demos-" + fileName + ".html"; + return this->helpRootUrl + "demos-" + fileName.replace("/", "-") + ".html"; else return this->helpRootUrl + dirName.replace("/", "-") + "-" + fileName + ".html"; } @@ -474,6 +557,9 @@ QByteArray MenuManager::getImage(const QString &name) QString imageName = this->info[name]["image"]; QString category = this->info[name]["category"]; QString fileName = this->info[name]["filename"]; + bool qml = (this->info[name]["qml"] == QLatin1String("true")); + if(qml) + fileName = QLatin1String("qml-") + fileName.split('/').last(); if (imageName.isEmpty()){ if (category == "demos") @@ -493,7 +579,7 @@ void MenuManager::createRootMenu(const QDomElement &el) { QString name = el.attribute("name"); createMenu(el, MENU1); - createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info"); + createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info"); Movie *menuButtonsIn = this->score->insertMovie(name + " -buttons"); Movie *menuButtonsOut = this->score->insertMovie(name + " -buttons -out"); @@ -505,19 +591,21 @@ void MenuManager::createSubMenu(const QDomElement &el) { QString name = el.attribute("name"); createMenu(el, MENU2); - createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info"); + createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info"); } void MenuManager::createLeafMenu(const QDomElement &el) { QString name = el.attribute("name"); - createInfo(new ExampleContent(name, this->window->scene, 0), name); + createInfo(new ExampleContent(name, this->window->scene, this->window->mainSceneRoot), name); Movie *infoButtonsIn = this->score->insertMovie(name + " -buttons"); Movie *infoButtonsOut = this->score->insertMovie(name + " -buttons -out"); createLowRightLeafButton("Documentation", 600, DOCUMENTATION, infoButtonsIn, infoButtonsOut, 0); if (el.attribute("executable") != "false") createLowRightLeafButton("Launch", 405, LAUNCH, infoButtonsIn, infoButtonsOut, 0); + else if(el.attribute("qml") == "true") + createLowRightLeafButton("Display", 405, LAUNCH_QML, infoButtonsIn, infoButtonsOut, 0); } void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) @@ -546,7 +634,7 @@ void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) // create normal menu button QString label = currentNode.toElement().attribute("name"); - item = new TextButton(label, TextButton::LEFT, type, this->window->scene, 0); + item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot); currentNode = currentNode.nextSibling(); #ifndef QT_OPENGL_SUPPORT @@ -646,7 +734,7 @@ void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString) { - TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); if (!menuString.isNull()) button->setMenuString(menuString); button->setRecursiveVisible(false); @@ -688,7 +776,7 @@ void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type, void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/) { - TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); @@ -715,7 +803,7 @@ void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, M void MenuManager::createLowRightLeafButton(const QString &label, int xOffset, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/) { - TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); @@ -831,12 +919,12 @@ void MenuManager::createUpnDownButtons() float xOffset = 15.0f; float yOffset = 450.0f; - this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, 0, TextButton::UP); + this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, this->window->mainSceneRoot, TextButton::UP); this->upButton->prepare(); this->upButton->setPos(xOffset, yOffset); this->upButton->setState(TextButton::DISABLED); - this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, 0, TextButton::DOWN); + this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, this->window->mainSceneRoot, TextButton::DOWN); this->downButton->prepare(); this->downButton->setPos(xOffset + 10 + this->downButton->sceneBoundingRect().width(), yOffset); diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index ff98341426..3524081ff0 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -61,7 +61,7 @@ class MenuManager : public QObject Q_OBJECT public: - enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK}; + enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK, LAUNCH_QML}; // singleton pattern: static MenuManager *instance(); @@ -83,6 +83,11 @@ public: Score *score; int currentMenuCode; + QDeclarativeEngine* declarativeEngine; + QDeclarativeItem *qmlRoot; + QGraphicsBlurEffect *mainSceneBlur; + QGraphicsDropShadowEffect *qmlShadow; + private slots: void exampleFinished(); void exampleError(QProcess::ProcessError error); @@ -100,6 +105,7 @@ private: void readInfoAboutExample(const QDomElement &example); void showDocInAssistant(const QString &docFile); void launchExample(const QString &uniqueName); + void launchQmlExample(const QString &uniqueName); void createMenu(const QDomElement &category, BUTTON_TYPE type); void createLowLeftButton(const QString &label, BUTTON_TYPE type, @@ -128,6 +134,7 @@ private: TextButton *upButton; TextButton *downButton; + }; #endif // MENU_MANAGER_H diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml new file mode 100644 index 0000000000..8c20cf4c99 --- /dev/null +++ b/demos/qtdemo/qmlShell.qml @@ -0,0 +1,117 @@ +import Qt 4.7 +import Effects 1.0 + +Item { + id: main + property alias source: loader.source + property bool show: false + x: 0 + y: -500 //height and width set by program + opacity: 0 + property QtObject blurEffect: realBlur == null ? dummyBlur : realBlur //Is there a better way to lose those error messages? + Loader{//Automatic FocusScope + focus: true + clip: true + id: loader //source set by program + anchors.centerIn: parent + onStatusChanged: if(status == Loader.Ready) { + if(loader.item.width > 640) + loader.item.width = 640; + if(loader.item.height > 480) + loader.item.height = 480; + } + + } + Rectangle{ + z: -1 + anchors.fill: loader.status == Loader.Ready ? loader : errorTxt + anchors.margins: -10 + radius: 12 + smooth: true + gradient: Gradient{ + GradientStop{ position: 0.0; color: "#14FFFFFF" } + GradientStop{ position: 1.0; color: "#5AFFFFFF" } + } + MouseArea{ + anchors.fill: parent + onClicked: loader.focus=true;/* and don't propogate to the 'exit' area*/ + } + + } + + MouseArea{ + z: -2 + hoverEnabled: true //To steal from the buttons + anchors.fill: parent + onClicked: main.show=false; + } + + Text{ + id: errorTxt + anchors.centerIn: parent + color: 'white' + smooth: true + visible: loader.status == Loader.Error + textFormat: Text.RichText //includes link for bugreport + //Note that if loader is Error, it is because the file was found but there was an error creating the component + //This means either we have a bug in our demos, or the required modules (which ship with Qt) did not deploy correctly + text: 'The example has failed to load. This is a bug!
' + +'Report it at http://bugreports.qt.nokia.com'; + onLinkActivated: Qt.openUrlExternally(link); + } + + + states: [ + State { + name: "show" + when: show == true + PropertyChanges { + target: main + opacity: 1 + y: 0 + } + PropertyChanges { + target: blurEffect + enabled: true + blurRadius: 8 + blurHints: Blur.AnimationHint | Blur.PerformanceHint + } + } + ] + MagicAnim{ id: magicAnim; target: main; from: -500; to: 0 } + transitions: [ + Transition { from: ""; to: "show" + SequentialAnimation{ + ScriptAction{ script: magicAnim.start() } + NumberAnimation{ properties: "opacity,blurRadius"; easing.type: Easing.OutCubic; duration: 1000} + PropertyAnimation{ target: main; property: "y"} + } + + }, + Transition { from: "show"; to: "" //Addtionally, unload the item + SequentialAnimation{ + NumberAnimation{ properties: "y,opacity,blurRadius";duration: 500 } + ScriptAction{ script: loader.source = ''; } + } + /*Attempt to copy the exeunt animation. Looks bad + SequentialAnimation{ + ParallelAnimation{ + NumberAnimation{ properties: "opacity,blurRadius"; easing.type: Easing.InCubic; duration: 1000 } + SequentialAnimation{ + NumberAnimation{ target: main; property: 'y'; to: 3.2*height/5; duration: 500} + ParallelAnimation{ + NumberAnimation{ target: main; property: 'y'; to: 3.0*height/5; duration: 100} + NumberAnimation{ target: main; property: 'x'; to: 3.0*width/5; duration: 100} + } + NumberAnimation{ target: main; property: 'x'; to: 700; duration: 400} + } + } + ScriptAction{ script: loader.source = ''; } + PropertyAction{ properties: "x,y";} + } + */ + } + ] + Item{ Blur{id: dummyBlur } } + +} diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 2a776ace1d..5e64e1c097 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -6,7 +6,7 @@ DESTDIR = $$DEMO_DESTDIR/bin INSTALLS += target sources -QT += xml network +QT += xml network declarative contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT @@ -74,3 +74,6 @@ target.path = $$[QT_INSTALL_BINS] sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES qtdemo.pro images xml *.ico *.icns *.rc *.plist sources.path = $$[QT_INSTALL_DEMOS]/qtdemo +OTHER_FILES += \ + qmlShell.qml \ + MagicAnim.qml diff --git a/demos/qtdemo/qtdemo.qrc b/demos/qtdemo/qtdemo.qrc index b30dd5894e..7682ab5148 100644 --- a/demos/qtdemo/qtdemo.qrc +++ b/demos/qtdemo/qtdemo.qrc @@ -1,8 +1,12 @@ - - - xml/examples.xml - images/qtlogo_small.png - images/trolltech-logo.png - images/demobg.png - + + + xml/examples.xml + images/qtlogo_small.png + images/trolltech-logo.png + images/demobg.png + + + qmlShell.qml + MagicAnim.qml + diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 91218611a8..0ab048e0a1 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -1,25 +1,32 @@ + + - - - - - - + + + + + + + + + + + @@ -35,6 +42,13 @@ + + + + + + + @@ -116,6 +130,16 @@ + + + + + + + + + + diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index c2237d685e..56ba1c70a7 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -271,6 +271,8 @@ This example displays a set of clocks with different times for different cities. Each clock is created by combining \l Image elements with \l Rotation transforms and \l SpringFollow animations. + + \image qml-clocks-example.png */ /*! @@ -280,14 +282,8 @@ This example presents a flickable set of interactive corkboards. It is created through a combination of elements like \l ListModel, \l Repeater and \l TextEdit together with rotation and scaling transforms, animation and mouse interaction. -*/ - -/*! - \title Toys: Dial - \example declarative/toys/dial - This example presents an interactive speedometer-type dial by combining - \l Image elements with \l Rotation transforms and \l SpringFollow animations. + \image qml-corkboards-example.png */ /*! @@ -297,6 +293,8 @@ This example presents an interactive drag-and-drop scene. It demonstrates how to use QML's \l{Dynamic Object Creation} support to dynamically create and destroy objects. + + \image qml-dynamicscene-example.png */ /*! @@ -304,6 +302,8 @@ \example declarative/toys/tic-tac-toe This example presents a simple implementation of Tic Tac Toe. + + \image qml-tic-tac-toe-example.png */ /*! @@ -312,6 +312,8 @@ This example shows how to use animation components such as \l SpringFollow, \l SequentialAnimation and \l PropertyAction to create a game of TV tennis. + + \image qml-tvtennis-example.png */ /*! @@ -328,11 +330,24 @@ This example shows how to use the MouseArea element. */ +/*! + \title UI Components: Dial + \example declarative/ui-components/dialcontrol + + This example presents an interactive speedometer-type dial by combining + \l Image elements with \l Rotation transforms and \l SpringFollow animations. + + \image qml-dialcontrol-example.png +*/ + + /*! \title UI Components: Flipable \example declarative/ui-components/flipable This example shows how to use the Flipable element. + + \image qml-flipable-example.png */ /*! @@ -340,6 +355,8 @@ \example declarative/ui-components/progressbar This example shows how to create a progress bar. + + \image qml-progressbar-example.png */ /*! @@ -349,6 +366,8 @@ This example shows how to create scroll bars for a Flickable element using the \l {Flickable::visibleArea.xPosition}{Flickable::visibleArea} properties. + + \image qml-scrollbar-example.png */ /*! @@ -356,6 +375,8 @@ \example declarative/ui-components/searchbox This example shows how to create a search box. + + \image qml-searchbox-example.png */ /*! @@ -363,6 +384,8 @@ \example declarative/ui-components/slideswitch This example shows how to create a slide switch. + + \image qml-slideswitch-example.png */ /*! @@ -370,6 +393,8 @@ \example declarative/ui-components/spinner This example shows how to create a spinner-type component. + + \image qml-spinner-example.png */ /*! @@ -377,6 +402,8 @@ \example declarative/ui-components/tabwidget This example shows how to create a tab widget. + + \image qml-tabwidget-example.png */ /*! diff --git a/doc/src/examples/qml-flickr.qdoc b/doc/src/examples/qml-flickr.qdoc index ebf3250f0b..43fcf1f6cf 100644 --- a/doc/src/examples/qml-flickr.qdoc +++ b/doc/src/examples/qml-flickr.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a mobile Flickr browser application in QML. - \image qml-flickr-example.png + \image qml-flickr-demo.png */ diff --git a/doc/src/examples/qml-minehunt.qdoc b/doc/src/examples/qml-minehunt.qdoc index 773f21646d..b2c662d91f 100644 --- a/doc/src/examples/qml-minehunt.qdoc +++ b/doc/src/examples/qml-minehunt.qdoc @@ -43,7 +43,8 @@ \title Minehunt \example demos/declarative/minehunt - This demo shows how to create a simple Minehunt game with QML and C++. + This demo shows how to create a simple Minehunt game, using QML for the + UI and a C++ plugin for the game logic. - \image qml-minehunt-example.png + \image qml-minehunt-demo.png */ diff --git a/doc/src/examples/qml-photoviewer.qdoc b/doc/src/examples/qml-photoviewer.qdoc index d1c3da287e..d2114b90f9 100644 --- a/doc/src/examples/qml-photoviewer.qdoc +++ b/doc/src/examples/qml-photoviewer.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a Flickr photo viewer application in QML. - \image qml-photoviewer-example.png + \image qml-photoviewer-demo.png */ diff --git a/doc/src/examples/qml-rssnews.qdoc b/doc/src/examples/qml-rssnews.qdoc index 0e7bdef9f6..801efd9ab1 100644 --- a/doc/src/examples/qml-rssnews.qdoc +++ b/doc/src/examples/qml-rssnews.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a RSS news reader in QML. - \image qml-rssnews-example.png + \image qml-rssnews-demo.png */ diff --git a/doc/src/examples/qml-samegame.qdoc b/doc/src/examples/qml-samegame.qdoc index d9a9c7c433..5b78b0cf42 100644 --- a/doc/src/examples/qml-samegame.qdoc +++ b/doc/src/examples/qml-samegame.qdoc @@ -43,7 +43,8 @@ \title Same Game \example demos/declarative/samegame - This demo shows how to write a Same Game in QML. + This demo shows how to write a 'Same Game' game in QML, using Javascript + for all the game logic. - \image qml-samegame-example.png + \image qml-samegame-demo.png */ diff --git a/doc/src/examples/qml-snake.qdoc b/doc/src/examples/qml-snake.qdoc index 373ca133af..3125f2d939 100644 --- a/doc/src/examples/qml-snake.qdoc +++ b/doc/src/examples/qml-snake.qdoc @@ -43,7 +43,8 @@ \title Snake \example demos/declarative/snake - This demo shows how to write a Snake game in QML. + This demo shows how to write a Snake game in QML, controlled by the + keyboard as well as the mouse. - \image qml-snake-example.png + \image qml-snake-demo.png */ diff --git a/doc/src/examples/qml-twitter.qdoc b/doc/src/examples/qml-twitter.qdoc new file mode 100644 index 0000000000..0e663606f0 --- /dev/null +++ b/doc/src/examples/qml-twitter.qdoc @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title Twitter Mobile + \example demos/declarative/twitter + + This demo shows how to write a mobile Twitter client in QML. Use it to + tweet us(@qtbynokia) how much you like our demos! + + \image qml-twitter-demo.png +*/ diff --git a/doc/src/images/qml-clocks-example.png b/doc/src/images/qml-clocks-example.png new file mode 100644 index 0000000000..1b352b589b Binary files /dev/null and b/doc/src/images/qml-clocks-example.png differ diff --git a/doc/src/images/qml-corkboards-example.png b/doc/src/images/qml-corkboards-example.png new file mode 100644 index 0000000000..8acffa7b64 Binary files /dev/null and b/doc/src/images/qml-corkboards-example.png differ diff --git a/doc/src/images/qml-dialcontrol-example.png b/doc/src/images/qml-dialcontrol-example.png new file mode 100644 index 0000000000..74cd645d3a Binary files /dev/null and b/doc/src/images/qml-dialcontrol-example.png differ diff --git a/doc/src/images/qml-dynamicscene-example.png b/doc/src/images/qml-dynamicscene-example.png new file mode 100644 index 0000000000..1f725d1b09 Binary files /dev/null and b/doc/src/images/qml-dynamicscene-example.png differ diff --git a/doc/src/images/qml-flickr-demo.png b/doc/src/images/qml-flickr-demo.png new file mode 100644 index 0000000000..71ea567929 Binary files /dev/null and b/doc/src/images/qml-flickr-demo.png differ diff --git a/doc/src/images/qml-flickr-example.png b/doc/src/images/qml-flickr-example.png deleted file mode 100644 index 71ea567929..0000000000 Binary files a/doc/src/images/qml-flickr-example.png and /dev/null differ diff --git a/doc/src/images/qml-flipable-example.png b/doc/src/images/qml-flipable-example.png new file mode 100644 index 0000000000..dd68a66cef Binary files /dev/null and b/doc/src/images/qml-flipable-example.png differ diff --git a/doc/src/images/qml-minehunt-demo.png b/doc/src/images/qml-minehunt-demo.png new file mode 100644 index 0000000000..3b6956936f Binary files /dev/null and b/doc/src/images/qml-minehunt-demo.png differ diff --git a/doc/src/images/qml-minehunt-example.png b/doc/src/images/qml-minehunt-example.png deleted file mode 100644 index 3b6956936f..0000000000 Binary files a/doc/src/images/qml-minehunt-example.png and /dev/null differ diff --git a/doc/src/images/qml-photoviewer-demo.png b/doc/src/images/qml-photoviewer-demo.png new file mode 100644 index 0000000000..be6f1bf1f9 Binary files /dev/null and b/doc/src/images/qml-photoviewer-demo.png differ diff --git a/doc/src/images/qml-photoviewer-example.png b/doc/src/images/qml-photoviewer-example.png deleted file mode 100644 index be6f1bf1f9..0000000000 Binary files a/doc/src/images/qml-photoviewer-example.png and /dev/null differ diff --git a/doc/src/images/qml-progressbar-example.png b/doc/src/images/qml-progressbar-example.png new file mode 100644 index 0000000000..3ddd6c64ad Binary files /dev/null and b/doc/src/images/qml-progressbar-example.png differ diff --git a/doc/src/images/qml-rssnews-demo.png b/doc/src/images/qml-rssnews-demo.png new file mode 100644 index 0000000000..948ef4d87c Binary files /dev/null and b/doc/src/images/qml-rssnews-demo.png differ diff --git a/doc/src/images/qml-rssnews-example.png b/doc/src/images/qml-rssnews-example.png deleted file mode 100644 index 948ef4d87c..0000000000 Binary files a/doc/src/images/qml-rssnews-example.png and /dev/null differ diff --git a/doc/src/images/qml-samegame-demo.png b/doc/src/images/qml-samegame-demo.png new file mode 100644 index 0000000000..c17b4e0775 Binary files /dev/null and b/doc/src/images/qml-samegame-demo.png differ diff --git a/doc/src/images/qml-samegame-example.png b/doc/src/images/qml-samegame-example.png deleted file mode 100644 index c17b4e0775..0000000000 Binary files a/doc/src/images/qml-samegame-example.png and /dev/null differ diff --git a/doc/src/images/qml-searchbox-example.png b/doc/src/images/qml-searchbox-example.png new file mode 100644 index 0000000000..97d12bba89 Binary files /dev/null and b/doc/src/images/qml-searchbox-example.png differ diff --git a/doc/src/images/qml-slideswitch-example.png b/doc/src/images/qml-slideswitch-example.png new file mode 100644 index 0000000000..17cb3eb36b Binary files /dev/null and b/doc/src/images/qml-slideswitch-example.png differ diff --git a/doc/src/images/qml-snake-demo.png b/doc/src/images/qml-snake-demo.png new file mode 100644 index 0000000000..d3c077d1f8 Binary files /dev/null and b/doc/src/images/qml-snake-demo.png differ diff --git a/doc/src/images/qml-snake-example.png b/doc/src/images/qml-snake-example.png deleted file mode 100644 index d3c077d1f8..0000000000 Binary files a/doc/src/images/qml-snake-example.png and /dev/null differ diff --git a/doc/src/images/qml-spinner-example.png b/doc/src/images/qml-spinner-example.png new file mode 100644 index 0000000000..ed381f8aa7 Binary files /dev/null and b/doc/src/images/qml-spinner-example.png differ diff --git a/doc/src/images/qml-tabwidget-example.png b/doc/src/images/qml-tabwidget-example.png new file mode 100644 index 0000000000..05887f3d1a Binary files /dev/null and b/doc/src/images/qml-tabwidget-example.png differ diff --git a/doc/src/images/qml-tic-tac-toe-example.png b/doc/src/images/qml-tic-tac-toe-example.png new file mode 100644 index 0000000000..5a5cc8262b Binary files /dev/null and b/doc/src/images/qml-tic-tac-toe-example.png differ diff --git a/doc/src/images/qml-tvtennis-example.png b/doc/src/images/qml-tvtennis-example.png new file mode 100644 index 0000000000..ac2b5276bd Binary files /dev/null and b/doc/src/images/qml-tvtennis-example.png differ diff --git a/doc/src/images/qml-twitter-demo.png b/doc/src/images/qml-twitter-demo.png new file mode 100644 index 0000000000..63d6486a5a Binary files /dev/null and b/doc/src/images/qml-twitter-demo.png differ diff --git a/examples/declarative/toys/README b/examples/declarative/toys/README index 7fd7eb0bbc..ff4d0242d7 100644 --- a/examples/declarative/toys/README +++ b/examples/declarative/toys/README @@ -1,4 +1,4 @@ -These pure QML examples create complete components to demonstrate +These pure QML examples demonstrate some of what can be easily done using just a few QML files. The example launcher provided with Qt can be used to explore each of the diff --git a/examples/declarative/toys/dial-example/content/Dial.qml b/examples/declarative/toys/dial-example/content/Dial.qml deleted file mode 100644 index 2b421bf7c8..0000000000 --- a/examples/declarative/toys/dial-example/content/Dial.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 93 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 11; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 95; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 7; origin.y: 65 - angle: -130 - SpringFollow on angle { - spring: 1.4 - damping: .15 - to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - } - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/declarative/toys/dial-example/content/background.png b/examples/declarative/toys/dial-example/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/declarative/toys/dial-example/content/background.png and /dev/null differ diff --git a/examples/declarative/toys/dial-example/content/needle.png b/examples/declarative/toys/dial-example/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/declarative/toys/dial-example/content/needle.png and /dev/null differ diff --git a/examples/declarative/toys/dial-example/content/needle_shadow.png b/examples/declarative/toys/dial-example/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/declarative/toys/dial-example/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/toys/dial-example/content/overlay.png b/examples/declarative/toys/dial-example/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/declarative/toys/dial-example/content/overlay.png and /dev/null differ diff --git a/examples/declarative/toys/dial-example/dial-example.qml b/examples/declarative/toys/dial-example/dial-example.qml deleted file mode 100644 index 95df68c638..0000000000 --- a/examples/declarative/toys/dial-example/dial-example.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import "content" - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } -} -//! [0] \ No newline at end of file diff --git a/examples/declarative/toys/dial-example/dial.qmlproject b/examples/declarative/toys/dial-example/dial.qmlproject deleted file mode 100644 index d4909f8685..0000000000 --- a/examples/declarative/toys/dial-example/dial.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml index 707add774c..76a6a3bdc4 100644 --- a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml @@ -50,7 +50,6 @@ Item { width: 440 height: 480 - anchors.fill: parent Image { id: boardimage diff --git a/examples/declarative/ui-components/README b/examples/declarative/ui-components/README new file mode 100644 index 0000000000..7eecec104a --- /dev/null +++ b/examples/declarative/ui-components/README @@ -0,0 +1,39 @@ +With Qt Declarative, it is easy to implement the UI components that you need +in exactly the way that you want. These examples demonstrate this by creating +a selection of user interface components where the look and feel has been +completely defined in a QML file. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. But most can also be viewed directly with the +QML viewer utility, without requiring compilation. + +Documentation for these examples can be found via the Tutorials and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/declarative/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/ui-components/dialcontrol/content/Dial.qml new file mode 100644 index 0000000000..2b421bf7c8 --- /dev/null +++ b/examples/declarative/ui-components/dialcontrol/content/Dial.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 93 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 11; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 95; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 7; origin.y: 65 + angle: -130 + SpringFollow on angle { + spring: 1.4 + damping: .15 + to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + } + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/declarative/ui-components/dialcontrol/content/background.png b/examples/declarative/ui-components/dialcontrol/content/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/declarative/ui-components/dialcontrol/content/background.png differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle.png b/examples/declarative/ui-components/dialcontrol/content/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/declarative/ui-components/dialcontrol/content/needle.png differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png b/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png differ diff --git a/examples/declarative/ui-components/dialcontrol/content/overlay.png b/examples/declarative/ui-components/dialcontrol/content/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/declarative/ui-components/dialcontrol/content/overlay.png differ diff --git a/examples/declarative/ui-components/dialcontrol/dial.qmlproject b/examples/declarative/ui-components/dialcontrol/dial.qmlproject new file mode 100644 index 0000000000..d4909f8685 --- /dev/null +++ b/examples/declarative/ui-components/dialcontrol/dial.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml new file mode 100644 index 0000000000..95df68c638 --- /dev/null +++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 +import "content" + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } +} +//! [0] \ No newline at end of file diff --git a/examples/declarative/ui-components/flipable/flipable-example.qml b/examples/declarative/ui-components/flipable/flipable-example.qml deleted file mode 100644 index 479e35b413..0000000000 --- a/examples/declarative/ui-components/flipable/flipable-example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/ui-components/flipable/flipable.qml b/examples/declarative/ui-components/flipable/flipable.qml new file mode 100644 index 0000000000..479e35b413 --- /dev/null +++ b/examples/declarative/ui-components/flipable/flipable.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/declarative/ui-components/progressbar/main.qml b/examples/declarative/ui-components/progressbar/main.qml new file mode 100644 index 0000000000..22f8dbdd4b --- /dev/null +++ b/examples/declarative/ui-components/progressbar/main.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/declarative/ui-components/progressbar/progressbars.qml b/examples/declarative/ui-components/progressbar/progressbars.qml deleted file mode 100644 index 22f8dbdd4b..0000000000 --- a/examples/declarative/ui-components/progressbar/progressbars.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/declarative/ui-components/scrollbar/display.qml b/examples/declarative/ui-components/scrollbar/display.qml deleted file mode 100644 index 1f7992b542..0000000000 --- a/examples/declarative/ui-components/scrollbar/display.qml +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - from: "*"; to: "*" - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/ui-components/scrollbar/main.qml b/examples/declarative/ui-components/scrollbar/main.qml new file mode 100644 index 0000000000..1f7992b542 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/main.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + from: "*"; to: "*" + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/declarative/ui-components/tabwidget/main.qml b/examples/declarative/ui-components/tabwidget/main.qml new file mode 100644 index 0000000000..e11902a516 --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/main.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/declarative/ui-components/tabwidget/tabs.qml b/examples/declarative/ui-components/tabwidget/tabs.qml deleted file mode 100644 index e11902a516..0000000000 --- a/examples/declarative/ui-components/tabwidget/tabs.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} -- cgit v1.2.3 From b1fc72462f178d70d6eaae8b649c5dda2040fdd5 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 25 May 2010 09:11:57 +1000 Subject: Fix TextEdit implicit height. --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 7b00d2fc46..55843c17dc 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1170,7 +1170,7 @@ void QDeclarativeTextEdit::updateSize() newWidth += 3;// ### Need a better way of accounting for space between char and cursor // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. setImplicitWidth(newWidth); - setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height()); + setImplicitHeight(d->document->isEmpty() ? fm.height() : (int)d->document->size().height()); setContentsSize(QSize(width(), height())); } else { -- cgit v1.2.3 From 84c21a090765a4060ba84d1c6e9a3cb956535e81 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 25 May 2010 09:29:26 +1000 Subject: Fix benchmark warnings on symbian. --- tests/benchmarks/declarative/binding/testtypes.h | 10 +++++----- tests/benchmarks/declarative/creation/tst_creation.cpp | 4 ++-- tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h | 10 +++++----- tests/benchmarks/declarative/qmltime/qmltime.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h index 523f94dd09..0cbaa42aef 100644 --- a/tests/benchmarks/declarative/binding/testtypes.h +++ b/tests/benchmarks/declarative/binding/testtypes.h @@ -47,11 +47,11 @@ class MyQmlObject : public QObject { Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult); - Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); - Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); - Q_PROPERTY(QDeclarativeListProperty data READ data); - Q_CLASSINFO("DefaultProperty", "data"); + Q_PROPERTY(int result READ result WRITE setResult) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) + Q_PROPERTY(QDeclarativeListProperty data READ data) + Q_CLASSINFO("DefaultProperty", "data") public: MyQmlObject() : m_result(0), m_value(0), m_object(0) {} diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 83f66de9a8..94a67fd455 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -91,8 +91,8 @@ private: class TestType : public QObject { Q_OBJECT -Q_PROPERTY(QDeclarativeListProperty resources READ resources); -Q_CLASSINFO("DefaultProperty", "resources"); +Q_PROPERTY(QDeclarativeListProperty resources READ resources) +Q_CLASSINFO("DefaultProperty", "resources") public: TestType(QObject *parent = 0) : QObject(parent) {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h index 523f94dd09..0cbaa42aef 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h @@ -47,11 +47,11 @@ class MyQmlObject : public QObject { Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult); - Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); - Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); - Q_PROPERTY(QDeclarativeListProperty data READ data); - Q_CLASSINFO("DefaultProperty", "data"); + Q_PROPERTY(int result READ result WRITE setResult) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) + Q_PROPERTY(QDeclarativeListProperty data READ data) + Q_CLASSINFO("DefaultProperty", "data") public: MyQmlObject() : m_result(0), m_value(0), m_object(0) {} diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp index 3932e010cb..e1b73ca84b 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.cpp +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -50,7 +50,7 @@ class Timer : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent); + Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent) public: Timer(); -- cgit v1.2.3 From 956c9635d969d81ca954ea91aa4ccc1afbf3abcc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 25 May 2010 10:13:23 +1000 Subject: Example of a simple TextEditor look-and-feel. Task-number: QTBUG-10940 --- doc/src/snippets/declarative/texteditor.qml | 71 ++++++++++++++++++++++ .../graphicsitems/qdeclarativetextedit.cpp | 21 +++++-- .../graphicsitems/qdeclarativetextedit_p.h | 4 +- 3 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 doc/src/snippets/declarative/texteditor.qml diff --git a/doc/src/snippets/declarative/texteditor.qml b/doc/src/snippets/declarative/texteditor.qml new file mode 100644 index 0000000000..0bd79b5b78 --- /dev/null +++ b/doc/src/snippets/declarative/texteditor.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +//![0] +Flickable { + id: flick + + width: 300; height: 200; + contentHeight: edit.height + clip: true + + function ensureVisible(r) + { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + TextEdit { + id: edit + width: parent.width + focus: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + } +} +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 55843c17dc..e34bb3d5fe 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -80,6 +80,14 @@ TextEdit { \image declarative-textedit.gif + Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific + to a look-and-feel. For example, to add flickable scrolling that follows the cursor: + + \snippet snippets/declarative/texteditor.qml 0 + + A particular look-and-feel might use smooth scrolling (eg. using SmoothedFollow), might have a visible + scrollbar, or a scrollbar that fades in to show location, etc. + \sa Text */ @@ -574,7 +582,7 @@ void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c) disconnect(d->control, SIGNAL(cursorPositionChanged()), this, SLOT(moveCursorDelegate())); d->control->setCursorWidth(-1); - dirtyCache(cursorRect()); + dirtyCache(cursorRectangle()); delete d->cursor; d->cursor = 0; } @@ -601,7 +609,7 @@ void QDeclarativeTextEdit::loadCursorDelegate() connect(d->control, SIGNAL(cursorPositionChanged()), this, SLOT(moveCursorDelegate())); d->control->setCursorWidth(0); - dirtyCache(cursorRect()); + dirtyCache(cursorRectangle()); QDeclarative_setParent_noEvent(d->cursor, this); d->cursor->setParentItem(this); d->cursor->setHeight(QFontMetrics(d->font).height()); @@ -854,10 +862,12 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const } /*! - Returns the rectangle where the text cursor is rendered - within the text edit. + \qmlproperty rectangle TextEdit::cursorRectangle + + The rectangle where the text cursor is rendered + within the text edit. Read-only. */ -QRect QDeclarativeTextEdit::cursorRect() const +QRect QDeclarativeTextEdit::cursorRectangle() const { Q_D(const QDeclarativeTextEdit); return d->control->cursorRect().toRect().translated(0,-d->yoff); @@ -1076,6 +1086,7 @@ void QDeclarativeTextEditPrivate::init() QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers())); QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers())); QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); + QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorRectangleChanged())); document = control->document(); document->setDefaultFont(font); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 8848d47996..891b868657 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -78,6 +78,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) + Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) @@ -180,13 +181,14 @@ public: void setTextInteractionFlags(Qt::TextInteractionFlags flags); Qt::TextInteractionFlags textInteractionFlags() const; - QRect cursorRect() const; + QRect cursorRectangle() const; QVariant inputMethodQuery(Qt::InputMethodQuery property) const; Q_SIGNALS: void textChanged(const QString &); void cursorPositionChanged(); + void cursorRectangleChanged(); void selectionStartChanged(); void selectionEndChanged(); void selectionChanged(); -- cgit v1.2.3 From 38b329ae7dd7471b08e75b2f0f4615c4b787ece4 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 25 May 2010 10:16:19 +1000 Subject: License header. --- demos/qtdemo/MagicAnim.qml | 41 +++++++++++++++++++++++++++++++++++++++++ demos/qtdemo/qmlShell.qml | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/demos/qtdemo/MagicAnim.qml b/demos/qtdemo/MagicAnim.qml index f2ee80630f..7ac3e1ca5b 100644 --- a/demos/qtdemo/MagicAnim.qml +++ b/demos/qtdemo/MagicAnim.qml @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import Qt 4.7 //Emulates the in animation of the menu elements diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index 8c20cf4c99..eb155c45c3 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import Qt 4.7 import Effects 1.0 -- cgit v1.2.3 From cc9c08cad3648fd9525a0b7c3897ae22d5632c84 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 25 May 2010 11:26:04 +1000 Subject: Fixed compile with xlC. When given `flags |= foo | bar;', where `flags' is a bitfield, xlC says: The bit-field "flags" cannot be bound to a non-const reference `flags |= foo; flags |= bar;' works. --- src/gui/graphicsview/qgraphicswidget_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 076e8626b2..28070da86c 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -79,7 +79,8 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl resolveLayoutDirection(); q->unsetWindowFrameMargins(); - flags |= QGraphicsItem::ItemUsesExtendedStyleOption | QGraphicsItem::ItemSendsGeometryChanges; + flags |= QGraphicsItem::ItemUsesExtendedStyleOption; + flags |= QGraphicsItem::ItemSendsGeometryChanges; if (windowFlags & Qt::Window) flags |= QGraphicsItem::ItemIsPanel; } -- cgit v1.2.3 From 468ed48e8a98b674c23c493968a421a6fc70f3c9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 25 May 2010 12:02:42 +1000 Subject: Doc --- src/declarative/util/qdeclarativestateoperations.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 80ae5f5985..99f163e507 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1128,8 +1128,8 @@ void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target) \qml AnchorChanges { target: myItem - left: undefined //remove myItem's left anchor - right: otherItem.right + anchors.left: undefined //remove myItem's left anchor + anchors.right: otherItem.right } \endqml */ -- cgit v1.2.3 From 7a405bb1b318d69d70e3fe61b0e26714ad4748e2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 25 May 2010 12:09:54 +1000 Subject: geolocation (untested) --- examples/declarative/modelviews/webview/content/Mapping/map.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/declarative/modelviews/webview/content/Mapping/map.html b/examples/declarative/modelviews/webview/content/Mapping/map.html index a8726fd654..a98da5430f 100755 --- a/examples/declarative/modelviews/webview/content/Mapping/map.html +++ b/examples/declarative/modelviews/webview/content/Mapping/map.html @@ -25,6 +25,14 @@ } else { goToLatLng(new google.maps.LatLng(window.qml.lat,window.qml.lng)); } + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function(position) { + initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); + window.qml.lat = initialLocation.lat; + window.qml.lng = initialLocation.lng; + goToLatLng(initialLocation); + }); + } } function goToAddress() { if (geocoder) { -- cgit v1.2.3 From 9d8bf1b8b7eec4202d54dd472be625214ea9c6fc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 25 May 2010 13:26:26 +1000 Subject: Fix --- .../declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 4befc4c0c8..b07849dc59 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -676,12 +676,12 @@ void tst_qdeclarativetextedit::cursorDelegate() //Test Delegate gets moved for(int i=0; i<= textEditObject->text().length(); i++){ textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); } textEditObject->setCursorPosition(0); - QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); //Test Delegate gets deleted textEditObject->setCursorDelegate(0); QVERIFY(!textEditObject->findChild("cursorInstance")); -- cgit v1.2.3 From 2b3e7706f4459569520c77b9fb3ff2bc006e60f1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 25 May 2010 14:31:40 +1000 Subject: Reading/writing a non-existent property throws an exception QTBUG-10659 --- .../qml/qdeclarativeglobalscriptclass.cpp | 23 +++------------------- .../qml/qdeclarativeglobalscriptclass_p.h | 2 -- .../qml/qdeclarativeobjectscriptclass.cpp | 14 +++++++++---- .../qml/qdeclarativeobjectscriptclass_p.h | 1 + .../qdeclarativeecmascript/data/eval.qml | 2 +- .../qdeclarativeecmascript/data/function.qml | 3 ++- .../data/libraryScriptAssert.js | 2 +- .../tst_qdeclarativeecmascript.cpp | 15 +++++++++----- 8 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp index 6e107fb685..35cb2b47bc 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp @@ -98,7 +98,9 @@ QDeclarativeGlobalScriptClass::property(const QScriptValue &object, Q_UNUSED(object); Q_UNUSED(name); Q_UNUSED(id); - return engine()->undefinedValue(); + QString error = QLatin1String("Cannot access non-existent property \"") + + name.toString() + QLatin1Char('\"'); + return engine()->currentContext()->throwError(error); } void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, @@ -113,24 +115,5 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, engine()->currentContext()->throwError(error); } -/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */ -void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value) -{ - QScriptValue globalObject = engine()->globalObject(); - - QScriptValue v = engine()->newObject(); - - QScriptValueIterator iter(v); - while (iter.hasNext()) { - iter.next(); - v.setProperty(iter.scriptName(), iter.value()); - } - - v.setProperty(name, value); - v.setScriptClass(this); - - engine()->setGlobalObject(v); -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h index 7690eddbcb..3fe766f443 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h @@ -73,8 +73,6 @@ public: virtual void setProperty(QScriptValue &object, const QScriptString &name, uint id, const QScriptValue &value); - void explicitSetProperty(const QString &, const QScriptValue &); - const QScriptValue &globalObject() const { return m_globalObject; } const QSet &illegalNames() const { return m_illegalNames; } diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index aca01b2ace..be2be8b5a8 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -93,6 +93,7 @@ QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(QDeclarativeEngine m_destroyId = createPersistentIdentifier(QLatin1String("destroy")); m_toString = scriptEngine->newFunction(tostring); m_toStringId = createPersistentIdentifier(QLatin1String("toString")); + m_valueOfId = createPersistentIdentifier(QLatin1String("valueOf")); } QDeclarativeObjectScriptClass::~QDeclarativeObjectScriptClass() @@ -157,7 +158,8 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam lastTNData = 0; if (name == m_destroyId.identifier || - name == m_toStringId.identifier) + name == m_toStringId.identifier || + name == m_valueOfId.identifier) return QScriptClass::HandlesReadAccess; if (!obj) @@ -211,11 +213,15 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) if (name == m_destroyId.identifier) return Value(scriptEngine, m_destroy); - else if (name == m_toStringId.identifier) + else if (name == m_toStringId.identifier || + name == m_valueOfId.identifier) return Value(scriptEngine, m_toString); - if (lastData && !lastData->isValid()) - return Value(); + if (lastData && !lastData->isValid()) { + QString error = QLatin1String("Cannot access non-existent property \"") + + toString(name) + QLatin1Char('\"'); + return Value(scriptEngine, context()->throwError(error)); + } Q_ASSERT(obj); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h index 4b27e531a4..34c71a03bb 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h @@ -139,6 +139,7 @@ private: PersistentIdentifier m_destroyId; PersistentIdentifier m_toStringId; + PersistentIdentifier m_valueOfId; QScriptValue m_destroy; QScriptValue m_toString; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml index bc2df98964..faa510680a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -16,7 +16,7 @@ QtObject { test1 = (eval("a") == 7); test2 = (eval("b") == 9); - test3 = (eval("c") == undefined); + try { eval("c") } catch(e) { test3 = true; } test4 = (eval("console") == console); test5 = (eval("Qt") == Qt); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml index b435f5812e..e524189ca7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -14,6 +14,7 @@ QtObject { test1 = (func1(4) == 11); test2 = (func2("Hello World!") == Qt.atob("Hello World!")); - test3 = (func3() == undefined); + + try { func3(); } catch(e) { test3 = true; } } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js index 3ffdb339ad..a20fc2855b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js @@ -2,5 +2,5 @@ function test(target) { - var a = target.a; + try { var a = target.a; } catch(e) {} } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index e75abacc11..217ed11883 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -997,11 +997,11 @@ void tst_qdeclarativeecmascript::scriptErrors() QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; - QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning2 = url + ":5: Error: Cannot access non-existent property \"a\""; QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; - QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning6 = url + ":7: Unable to assign [undefined] to int x"; + QString warning4 = url + ":10: Error: Cannot access non-existent property \"a\""; + QString warning5 = url + ":8: Error: Cannot access non-existent property \"a\""; + QString warning6 = url + ":7: Error: Cannot access non-existent property \"undefinedObject\""; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; @@ -1317,7 +1317,12 @@ void tst_qdeclarativeecmascript::callQtInvokables() QDeclarativeEngine qmlengine; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine); QScriptEngine *engine = &ep->scriptEngine; - ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); + scriptContext->pushScope(ep->globalClass->globalObject()); + QScriptValue scope = engine->newObject(); + scope.setProperty("object", ep->objectClass->newQObject(&o)); + scriptContext->setActivationObject(scope); + scriptContext->pushScope(scope); // Non-existent methods o.reset(); -- cgit v1.2.3 From d982ded10a3dd5219ae40a5a3574b63ac7bdda3f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 25 May 2010 14:47:02 +1000 Subject: Always pass context to QObject script class QTBUG-10659 --- src/declarative/qml/qdeclarativecontextscriptclass.cpp | 2 +- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 8 +++++--- src/declarative/qml/qdeclarativeobjectscriptclass_p.h | 3 ++- src/declarative/qml/qdeclarativetypenamescriptclass.cpp | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 1ebedbb0af..03a1f6ab10 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -270,7 +270,7 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) if (lastScopeObject) { - return ep->objectClass->property(lastScopeObject, name); + return ep->objectClass->property(lastScopeObject, name, context()); } else if (lastData) { diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index be2be8b5a8..7c818a68a2 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -203,12 +203,14 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam QDeclarativeObjectScriptClass::Value QDeclarativeObjectScriptClass::property(Object *object, const Identifier &name) { - return property(toQObject(object), name); + return property(toQObject(object), name, context()); } QDeclarativeObjectScriptClass::Value -QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) +QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name, QScriptContext *context) { + Q_ASSERT(context); + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); if (name == m_destroyId.identifier) @@ -220,7 +222,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) if (lastData && !lastData->isValid()) { QString error = QLatin1String("Cannot access non-existent property \"") + toString(name) + QLatin1Char('\"'); - return Value(scriptEngine, context()->throwError(error)); + return Value(scriptEngine, context->throwError(error)); } Q_ASSERT(obj); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h index 34c71a03bb..61fa58661f 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h @@ -113,10 +113,11 @@ public: QDeclarativeContextData *evalContext, QueryHints hints = 0); - Value property(QObject *, const Identifier &); + Value property(QObject *, const Identifier &, QScriptContext *context); void setProperty(QObject *, const Identifier &name, const QScriptValue &, QScriptContext *context, QDeclarativeContextData *evalContext = 0); + virtual QStringList propertyNames(Object *); virtual bool compare(Object *, Object *); diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp index 2a3417aeb1..b512387dfa 100644 --- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp +++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp @@ -147,7 +147,7 @@ QDeclarativeTypeNameScriptClass::property(Object *obj, const Identifier &name) if (type) { return Value(scriptEngine, newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode)); } else if (object) { - return ep->objectClass->property(object, name); + return ep->objectClass->property(object, name, context()); } else { return Value(scriptEngine, enumValue); } -- cgit v1.2.3 From a32987d32033a07e5a7440d7928cc8234db144bb Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 25 May 2010 16:23:27 +1000 Subject: Revert "Always pass context to QObject script class" This reverts commit d982ded10a3dd5219ae40a5a3574b63ac7bdda3f. --- src/declarative/qml/qdeclarativecontextscriptclass.cpp | 2 +- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 8 +++----- src/declarative/qml/qdeclarativeobjectscriptclass_p.h | 3 +-- src/declarative/qml/qdeclarativetypenamescriptclass.cpp | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 03a1f6ab10..1ebedbb0af 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -270,7 +270,7 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) if (lastScopeObject) { - return ep->objectClass->property(lastScopeObject, name, context()); + return ep->objectClass->property(lastScopeObject, name); } else if (lastData) { diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 7c818a68a2..be2be8b5a8 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -203,14 +203,12 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam QDeclarativeObjectScriptClass::Value QDeclarativeObjectScriptClass::property(Object *object, const Identifier &name) { - return property(toQObject(object), name, context()); + return property(toQObject(object), name); } QDeclarativeObjectScriptClass::Value -QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name, QScriptContext *context) +QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) { - Q_ASSERT(context); - QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); if (name == m_destroyId.identifier) @@ -222,7 +220,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name, QS if (lastData && !lastData->isValid()) { QString error = QLatin1String("Cannot access non-existent property \"") + toString(name) + QLatin1Char('\"'); - return Value(scriptEngine, context->throwError(error)); + return Value(scriptEngine, context()->throwError(error)); } Q_ASSERT(obj); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h index 61fa58661f..34c71a03bb 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h @@ -113,11 +113,10 @@ public: QDeclarativeContextData *evalContext, QueryHints hints = 0); - Value property(QObject *, const Identifier &, QScriptContext *context); + Value property(QObject *, const Identifier &); void setProperty(QObject *, const Identifier &name, const QScriptValue &, QScriptContext *context, QDeclarativeContextData *evalContext = 0); - virtual QStringList propertyNames(Object *); virtual bool compare(Object *, Object *); diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp index b512387dfa..2a3417aeb1 100644 --- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp +++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp @@ -147,7 +147,7 @@ QDeclarativeTypeNameScriptClass::property(Object *obj, const Identifier &name) if (type) { return Value(scriptEngine, newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode)); } else if (object) { - return ep->objectClass->property(object, name, context()); + return ep->objectClass->property(object, name); } else { return Value(scriptEngine, enumValue); } -- cgit v1.2.3 From b02bf4ef805e33a763d86ec8ff496a27fddc8ad8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 25 May 2010 16:23:40 +1000 Subject: Revert "Reading/writing a non-existent property throws an exception" This reverts commit 2b3e7706f4459569520c77b9fb3ff2bc006e60f1. --- .../qml/qdeclarativeglobalscriptclass.cpp | 23 +++++++++++++++++++--- .../qml/qdeclarativeglobalscriptclass_p.h | 2 ++ .../qml/qdeclarativeobjectscriptclass.cpp | 14 ++++--------- .../qml/qdeclarativeobjectscriptclass_p.h | 1 - .../qdeclarativeecmascript/data/eval.qml | 2 +- .../qdeclarativeecmascript/data/function.qml | 3 +-- .../data/libraryScriptAssert.js | 2 +- .../tst_qdeclarativeecmascript.cpp | 15 +++++--------- 8 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp index 35cb2b47bc..6e107fb685 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp @@ -98,9 +98,7 @@ QDeclarativeGlobalScriptClass::property(const QScriptValue &object, Q_UNUSED(object); Q_UNUSED(name); Q_UNUSED(id); - QString error = QLatin1String("Cannot access non-existent property \"") + - name.toString() + QLatin1Char('\"'); - return engine()->currentContext()->throwError(error); + return engine()->undefinedValue(); } void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, @@ -115,5 +113,24 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, engine()->currentContext()->throwError(error); } +/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */ +void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value) +{ + QScriptValue globalObject = engine()->globalObject(); + + QScriptValue v = engine()->newObject(); + + QScriptValueIterator iter(v); + while (iter.hasNext()) { + iter.next(); + v.setProperty(iter.scriptName(), iter.value()); + } + + v.setProperty(name, value); + v.setScriptClass(this); + + engine()->setGlobalObject(v); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h index 3fe766f443..7690eddbcb 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h @@ -73,6 +73,8 @@ public: virtual void setProperty(QScriptValue &object, const QScriptString &name, uint id, const QScriptValue &value); + void explicitSetProperty(const QString &, const QScriptValue &); + const QScriptValue &globalObject() const { return m_globalObject; } const QSet &illegalNames() const { return m_illegalNames; } diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index be2be8b5a8..aca01b2ace 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -93,7 +93,6 @@ QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(QDeclarativeEngine m_destroyId = createPersistentIdentifier(QLatin1String("destroy")); m_toString = scriptEngine->newFunction(tostring); m_toStringId = createPersistentIdentifier(QLatin1String("toString")); - m_valueOfId = createPersistentIdentifier(QLatin1String("valueOf")); } QDeclarativeObjectScriptClass::~QDeclarativeObjectScriptClass() @@ -158,8 +157,7 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam lastTNData = 0; if (name == m_destroyId.identifier || - name == m_toStringId.identifier || - name == m_valueOfId.identifier) + name == m_toStringId.identifier) return QScriptClass::HandlesReadAccess; if (!obj) @@ -213,15 +211,11 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) if (name == m_destroyId.identifier) return Value(scriptEngine, m_destroy); - else if (name == m_toStringId.identifier || - name == m_valueOfId.identifier) + else if (name == m_toStringId.identifier) return Value(scriptEngine, m_toString); - if (lastData && !lastData->isValid()) { - QString error = QLatin1String("Cannot access non-existent property \"") + - toString(name) + QLatin1Char('\"'); - return Value(scriptEngine, context()->throwError(error)); - } + if (lastData && !lastData->isValid()) + return Value(); Q_ASSERT(obj); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h index 34c71a03bb..4b27e531a4 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h @@ -139,7 +139,6 @@ private: PersistentIdentifier m_destroyId; PersistentIdentifier m_toStringId; - PersistentIdentifier m_valueOfId; QScriptValue m_destroy; QScriptValue m_toString; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml index faa510680a..bc2df98964 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -16,7 +16,7 @@ QtObject { test1 = (eval("a") == 7); test2 = (eval("b") == 9); - try { eval("c") } catch(e) { test3 = true; } + test3 = (eval("c") == undefined); test4 = (eval("console") == console); test5 = (eval("Qt") == Qt); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml index e524189ca7..b435f5812e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -14,7 +14,6 @@ QtObject { test1 = (func1(4) == 11); test2 = (func2("Hello World!") == Qt.atob("Hello World!")); - - try { func3(); } catch(e) { test3 = true; } + test3 = (func3() == undefined); } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js index a20fc2855b..3ffdb339ad 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js @@ -2,5 +2,5 @@ function test(target) { - try { var a = target.a; } catch(e) {} + var a = target.a; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 217ed11883..e75abacc11 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -997,11 +997,11 @@ void tst_qdeclarativeecmascript::scriptErrors() QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; - QString warning2 = url + ":5: Error: Cannot access non-existent property \"a\""; + QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object."; QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; - QString warning4 = url + ":10: Error: Cannot access non-existent property \"a\""; - QString warning5 = url + ":8: Error: Cannot access non-existent property \"a\""; - QString warning6 = url + ":7: Error: Cannot access non-existent property \"undefinedObject\""; + QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning6 = url + ":7: Unable to assign [undefined] to int x"; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; @@ -1317,12 +1317,7 @@ void tst_qdeclarativeecmascript::callQtInvokables() QDeclarativeEngine qmlengine; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine); QScriptEngine *engine = &ep->scriptEngine; - QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); - scriptContext->pushScope(ep->globalClass->globalObject()); - QScriptValue scope = engine->newObject(); - scope.setProperty("object", ep->objectClass->newQObject(&o)); - scriptContext->setActivationObject(scope); - scriptContext->pushScope(scope); + ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); // Non-existent methods o.reset(); -- cgit v1.2.3 From 10b28224afeabb388d21c32aac5f51f5ecea58ed Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 25 May 2010 16:44:42 +1000 Subject: Remove old symbian specific IAP initialization. --- tools/qml/qml.pri | 5 ----- tools/qml/qmlruntime.cpp | 26 -------------------------- tools/qml/qmlruntime.h | 1 - 3 files changed, 32 deletions(-) diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 5e3e74bf1d..cff65be9b9 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -23,10 +23,5 @@ maemo5 { SOURCES += $$PWD/deviceorientation.cpp } -symbian { - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -lconnmon -linsock -} - FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 8df250f58d..d00d7d9908 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -92,19 +92,6 @@ #include -#if defined (Q_OS_SYMBIAN) -#define SYMBIAN_NETWORK_INIT -#endif - -#if defined (SYMBIAN_NETWORK_INIT) -#include -#include -#include -#include -#include -#include "sym_iap_util.h" -#endif - QT_BEGIN_NAMESPACE class Runtime : public QObject @@ -522,12 +509,6 @@ void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); fileMenu->addAction(reloadAction); -#if defined(Q_OS_SYMBIAN) - QAction *networkAction = new QAction(tr("Start &Network"), parent); - connect(networkAction, SIGNAL(triggered()), this, SLOT(startNetwork())); - fileMenu->addAction(networkAction); -#endif - #if !defined(Q_OS_SYMBIAN) if (flatmenu) flatmenu->addSeparator(); @@ -930,13 +911,6 @@ bool QDeclarativeViewer::open(const QString& file_or_url) return true; } -void QDeclarativeViewer::startNetwork() -{ -#if defined(SYMBIAN_NETWORK_INIT) - qt_SetDefaultIap(); -#endif -} - void QDeclarativeViewer::setAutoRecord(int from, int to) { if (from==0) from=1; // ensure resized diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 0416b32a4d..5086e02e24 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -142,7 +142,6 @@ private slots: void pickRecordingFile(); void setPortrait(); void setLandscape(); - void startNetwork(); void toggleFullScreen(); void orientationChanged(); -- cgit v1.2.3 From 3501614b3797272dcbd683adcca4fdacc5b319e9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 26 May 2010 09:19:10 +1000 Subject: Add inherits Item to TextEdit and TextInput docs. Task-number: QTBUG-10969 --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 3 ++- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index e34bb3d5fe..f41cdd051f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -61,8 +61,9 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextEdit QDeclarativeTextEdit - \since 4.7 + \since 4.7 \brief The TextEdit item allows you to add editable formatted text to a scene. + \inherits Item It can display both plain and rich text. For example: diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 2e7715fa71..b624c5b7b1 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -54,8 +54,9 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextInput QDeclarativeTextInput - \since 4.7 + \since 4.7 \brief The TextInput item allows you to add an editable line of text to a scene. + \inherits Item TextInput can only display a single line of text, and can only display plain text. However it can provide addition input constraints on the text. -- cgit v1.2.3 From 291dce4ceba88a6cada0415524e3466621ac1612 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 26 May 2010 09:24:07 +1000 Subject: Mention TextInput/Edit::selectByMouse property in QmlChanges. --- src/declarative/QmlChanges.txt | 1 + src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 +- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 25c2417899..3eed8d6d80 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -15,6 +15,7 @@ QList models no longer provide properties in model object. The properties are now updated when the object changes. An object's property "foo" may now be accessed as "foo", modelData.foo" or model.modelData.foo" component.createObject has gained a mandatory "parent" argument +TextEdit and TextInput now have a "selectByMouse" property that defaults to false. C++ API ------- diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index f41cdd051f..a154d53f7d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -782,7 +782,7 @@ void QDeclarativeTextEdit::componentComplete() } /*! - \qmlproperty string TextEdit::selectByMouse + \qmlproperty bool TextEdit::selectByMouse Defaults to false. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index b624c5b7b1..1ac1b4e667 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1121,7 +1121,7 @@ QString QDeclarativeTextInput::displayText() const } /*! - \qmlproperty string TextInput::selectByMouse + \qmlproperty bool TextInput::selectByMouse Defaults to false. -- cgit v1.2.3