From 5994577c403d8622c535fa5d7fd3fd2d8b364043 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 2 Sep 2009 16:15:35 +1000 Subject: SameGame score XSLT now sorts by score. --- demos/declarative/samegame/highscores/score_style.xsl | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/declarative/samegame/highscores/score_style.xsl b/demos/declarative/samegame/highscores/score_style.xsl index 7dcf07e..670354c 100755 --- a/demos/declarative/samegame/highscores/score_style.xsl +++ b/demos/declarative/samegame/highscores/score_style.xsl @@ -13,6 +13,7 @@ Time, s + -- cgit v0.12 From 8ba41d00ff13c92e09d66321c5598a3855059060 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 2 Sep 2009 16:41:51 +1000 Subject: Slightly better name dialog for SameGame --- demos/declarative/samegame/SameGame.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index 877c1cc..ede4362 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -44,7 +44,8 @@ Rectangle { scoreName.forceClose(); } anchors.verticalCenter: parent.verticalCenter - x:160; width: 200; height:20; focus: true + width: 72; focus: true + anchors.right: scoreName.right } } -- cgit v0.12 From 9260c597cc45e15943ad851f934ebb6e5ac1010a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 2 Sep 2009 17:41:47 +1000 Subject: Add an assert before we dereference a null pointer Reviewed-by: Aaron Kennedy --- src/declarative/qml/qmlvme.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 7907195..a49cbd3 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -175,6 +175,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData } QmlDeclarativeData *ddata = QmlDeclarativeData::get(o); + Q_ASSERT(ddata); ddata->outerContext = ctxt; ddata->lineNumber = instr.line; ddata->columnNumber = instr.create.column; -- cgit v0.12 From ed417f18023f1bbd0636c9724b8f79e08c77d51a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 3 Sep 2009 09:06:46 +1000 Subject: Add basic autotests for state handling. --- .../auto/declarative/states/data/basicBinding.qml | 12 + .../auto/declarative/states/data/basicBinding2.qml | 12 + .../auto/declarative/states/data/basicBinding3.qml | 13 + .../auto/declarative/states/data/basicBinding4.qml | 17 ++ .../auto/declarative/states/data/basicChanges.qml | 10 + .../auto/declarative/states/data/basicChanges2.qml | 15 ++ .../auto/declarative/states/data/basicChanges3.qml | 15 ++ .../declarative/states/data/basicExtension.qml | 16 ++ .../auto/declarative/states/data/fakeExtension.qml | 16 ++ tests/auto/declarative/states/states.pro | 6 + tests/auto/declarative/states/tst_states.cpp | 267 +++++++++++++++++++++ 11 files changed, 399 insertions(+) create mode 100644 tests/auto/declarative/states/data/basicBinding.qml create mode 100644 tests/auto/declarative/states/data/basicBinding2.qml create mode 100644 tests/auto/declarative/states/data/basicBinding3.qml create mode 100644 tests/auto/declarative/states/data/basicBinding4.qml create mode 100644 tests/auto/declarative/states/data/basicChanges.qml create mode 100644 tests/auto/declarative/states/data/basicChanges2.qml create mode 100644 tests/auto/declarative/states/data/basicChanges3.qml create mode 100644 tests/auto/declarative/states/data/basicExtension.qml create mode 100644 tests/auto/declarative/states/data/fakeExtension.qml create mode 100644 tests/auto/declarative/states/states.pro create mode 100644 tests/auto/declarative/states/tst_states.cpp diff --git a/tests/auto/declarative/states/data/basicBinding.qml b/tests/auto/declarative/states/data/basicBinding.qml new file mode 100644 index 0000000..930a6b2 --- /dev/null +++ b/tests/auto/declarative/states/data/basicBinding.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: MyRectangle; color: sourceColor } + } +} diff --git a/tests/auto/declarative/states/data/basicBinding2.qml b/tests/auto/declarative/states/data/basicBinding2.qml new file mode 100644 index 0000000..6bfaf5a --- /dev/null +++ b/tests/auto/declarative/states/data/basicBinding2.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + + property color sourceColor: "red" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/states/data/basicBinding3.qml b/tests/auto/declarative/states/data/basicBinding3.qml new file mode 100644 index 0000000..344bfae --- /dev/null +++ b/tests/auto/declarative/states/data/basicBinding3.qml @@ -0,0 +1,13 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + + property color sourceColor: "red" + property color sourceColor2: "blue" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: MyRectangle; color: sourceColor2 } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/states/data/basicBinding4.qml b/tests/auto/declarative/states/data/basicBinding4.qml new file mode 100644 index 0000000..f0b72bd --- /dev/null +++ b/tests/auto/declarative/states/data/basicBinding4.qml @@ -0,0 +1,17 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: MyRectangle; color: sourceColor } + }, + State { + name: "green" + PropertyChanges { target: MyRectangle; color: "green" } + }] +} diff --git a/tests/auto/declarative/states/data/basicChanges.qml b/tests/auto/declarative/states/data/basicChanges.qml new file mode 100644 index 0000000..8d560c6 --- /dev/null +++ b/tests/auto/declarative/states/data/basicChanges.qml @@ -0,0 +1,10 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/states/data/basicChanges2.qml b/tests/auto/declarative/states/data/basicChanges2.qml new file mode 100644 index 0000000..0f8783a --- /dev/null +++ b/tests/auto/declarative/states/data/basicChanges2.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + }, + State { + name: "green" + PropertyChanges { target: MyRectangle; color: "green" } + }] +} \ No newline at end of file diff --git a/tests/auto/declarative/states/data/basicChanges3.qml b/tests/auto/declarative/states/data/basicChanges3.qml new file mode 100644 index 0000000..2a5ca5d --- /dev/null +++ b/tests/auto/declarative/states/data/basicChanges3.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + }, + State { + name: "bordered" + PropertyChanges { target: MyRectangle; border.width: 2 } + }] +} diff --git a/tests/auto/declarative/states/data/basicExtension.qml b/tests/auto/declarative/states/data/basicExtension.qml new file mode 100644 index 0000000..230e00b --- /dev/null +++ b/tests/auto/declarative/states/data/basicExtension.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + }, + State { + name: "bordered" + extend: "blue" + PropertyChanges { target: MyRectangle; border.width: 2 } + }] +} \ No newline at end of file diff --git a/tests/auto/declarative/states/data/fakeExtension.qml b/tests/auto/declarative/states/data/fakeExtension.qml new file mode 100644 index 0000000..3d85c4f --- /dev/null +++ b/tests/auto/declarative/states/data/fakeExtension.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +Rectangle { + id: MyRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: MyRectangle; color: "blue" } + }, + State { + name: "green" + extend: "blue" + PropertyChanges { target: MyRectangle; color: "green" } + }] +} \ No newline at end of file diff --git a/tests/auto/declarative/states/states.pro b/tests/auto/declarative/states/states.pro new file mode 100644 index 0000000..0474ea5 --- /dev/null +++ b/tests/auto/declarative/states/states.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_states.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp new file mode 100644 index 0000000..3a61bd6 --- /dev/null +++ b/tests/auto/declarative/states/tst_states.cpp @@ -0,0 +1,267 @@ +#include +#include +#include +#include + +class tst_states : public QObject +{ + Q_OBJECT +public: + tst_states() {} + +private slots: + void basicChanges(); + void basicExtension(); + void basicBinding(); +}; + +void tst_states::basicChanges() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rect->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) + + rect->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + } +} + +void tst_states::basicExtension() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rect->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rect->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } +} + +void tst_states::basicBinding() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("red")); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor2", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor2", QColor("green")); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); + QFxRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("purple")); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("purple")); + + rect->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rect->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } +} + +QTEST_MAIN(tst_states) + +#include "tst_states.moc" -- cgit v0.12 From 48b47f9d242f76e944986df08a16c083bce47bef Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 3 Sep 2009 09:32:38 +1000 Subject: Make it easier to test examples with EGL. Currently -graphicssystem opengl is not very reliable with EGL, so we've added a -opengl option to qmlviewer which sets the viewport of the view to a QGLWidget and allows for GL testing. --- tools/qmlviewer/main.cpp | 5 +++++ tools/qmlviewer/qmlviewer.cpp | 18 ++++++++++++++++++ tools/qmlviewer/qmlviewer.h | 1 + tools/qmlviewer/qmlviewer.pro | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index a4ed054..87d1232 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -41,6 +41,7 @@ void usage() qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -translation ........... set the language to run in"); qWarning(" -L ........................... prepend to the library search path"); + qWarning(" -opengl .................................. use a QGLWidget for the viewport"); qWarning(" "); qWarning(" Press F1 for interactive help"); exit(1); @@ -79,6 +80,7 @@ int main(int argc, char ** argv) bool devkeys = false; int cache = 0; QString translationFile; + bool useGL = false; for (int i = 1; i < argc; ++i) { QString arg = argv[i]; @@ -114,6 +116,8 @@ int main(int argc, char ** argv) usage(); translationFile = argv[i + 1]; ++i; + } else if (arg == "-opengl") { + useGL = true; } else if (arg == "-L") { libraries << QString(argv[++i]); } else if (arg[0] != '-') { @@ -130,6 +134,7 @@ int main(int argc, char ** argv) } QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget); + viewer.setUseGL(useGL); foreach (QString lib, libraries) viewer.addLibraryPath(lib); viewer.setNetworkCacheSize(cache); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 272ebcb..3ae9a97 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -45,6 +45,10 @@ #include #include "proxysettings.h" +#ifdef GL_SUPPORTED +#include +#endif + QT_BEGIN_NAMESPACE class PreviewDeviceSkin : public DeviceSkin @@ -1003,6 +1007,20 @@ void QmlViewer::setNetworkCacheSize(int size) } } +void QmlViewer::setUseGL(bool useGL) +{ +#ifdef GL_SUPPORTED + if (useGL) { + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(false); + + QGLWidget *glWidget = new QGLWidget(format); + glWidget->setAutoFillBackground(false); + canvas->setViewport(glWidget); + } +#endif +} + QT_END_NAMESPACE #include "qmlviewer.moc" diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index c03c09f..e85acfa 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -43,6 +43,7 @@ public: void setDeviceKeys(bool); void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); + void setUseGL(bool use); QStringList builtinSkins() const; diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index bcf361e..77cae97 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -7,6 +7,11 @@ QT += declarative \ network \ sql +contains(QT_CONFIG, opengl) { + QT += opengl + DEFINES += GL_SUPPORTED +} + # Input HEADERS += qmlviewer.h \ proxysettings.h -- cgit v0.12