diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-06 01:00:05 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-06 01:00:05 +0200 |
commit | 369f3e57b87682e006f5b171f6e2e73daf4208b8 (patch) | |
tree | c49cd0eafff470ddd6a68dd4b4278f8521c3773e | |
parent | 1aa4eab4a68e19702b5b3ab9b831efdc35266e66 (diff) | |
parent | b1e9bc580adc1e7b3b1398f392016880dc5201ba (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I59cb196ab17ed8504b33db01d827052eb6891efa
-rw-r--r-- | src/qml/doc/snippets/qml/componentCreation.js | 4 | ||||
-rw-r--r-- | src/qml/parser/qqmljs.g | 45 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm | bin | 0 -> 102 bytes | |||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp | 27 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlparser/tst_qqmlparser.cpp | 10 | ||||
-rw-r--r-- | tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 8 |
13 files changed, 121 insertions, 11 deletions
diff --git a/src/qml/doc/snippets/qml/componentCreation.js b/src/qml/doc/snippets/qml/componentCreation.js index 7364139d3d..ea45f18c37 100644 --- a/src/qml/doc/snippets/qml/componentCreation.js +++ b/src/qml/doc/snippets/qml/componentCreation.js @@ -17,7 +17,7 @@ function createSpriteObjects() { //![local] component = Qt.createComponent("Sprite.qml"); - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); + sprite = component.createObject(appWindow, {x: 100, y: 100}); if (sprite == null) { // Error Handling @@ -32,7 +32,7 @@ function createSpriteObjects() { //![finishCreation] function finishCreation() { if (component.status == Component.Ready) { - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); + sprite = component.createObject(appWindow, {x: 100, y: 100}); if (sprite == null) { // Error Handling console.log("Error creating object"); diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 71b0b11c97..4ad9057ced 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -1110,6 +1110,23 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T } break; ./ +UiObjectMember: T_READONLY T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_AUTOMATIC_SEMICOLON; +UiObjectMember: T_READONLY T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_SEMICOLON; +/. + case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7)); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->typeModifier = stringRef(3); + node->propertyToken = loc(2); + node->typeModifierToken = loc(3); + node->typeToken = loc(5); + node->identifierToken = loc(7); + node->semicolonToken = loc(8); + sym(1).Node = node; + } break; +./ + UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_AUTOMATIC_SEMICOLON; UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_SEMICOLON; /. @@ -1221,6 +1238,34 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T } break; ./ +UiObjectMember: T_READONLY T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET; +/. + case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7)); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->typeModifier = stringRef(3); + node->propertyToken = loc(2); + node->typeModifierToken = loc(3); + node->typeToken = loc(5); + node->identifierToken = loc(7); + node->semicolonToken = loc(8); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(7)); + propertyName->identifierToken = loc(7); + propertyName->next = 0; + + AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(10).UiArrayMemberList->finish()); + binding->colonToken = loc(8); + binding->lbracketToken = loc(9); + binding->rbracketToken = loc(11); + + node->binding = binding; + + sym(1).Node = node; + } break; +./ + UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer; /. case $rule_number: { diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index 1b7a433a84..facd79d211 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -76,7 +76,7 @@ void QQmlApplicationEnginePrivate::init() &QCoreApplication::exit, Qt::QueuedConnection); #if QT_CONFIG(translation) QTranslator* qtTranslator = new QTranslator; - if (qtTranslator->load(QLocale(), QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + if (qtTranslator->load(QLocale(), QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath), QLatin1String(".qm"))) QCoreApplication::installTranslator(qtTranslator); translators << qtTranslator; #endif @@ -90,10 +90,10 @@ void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile) if (rootFile.scheme() != QLatin1String("file") && rootFile.scheme() != QLatin1String("qrc")) return; - QFileInfo fi(rootFile.toLocalFile()); + QFileInfo fi(QQmlFile::urlToLocalFileOrQrc(rootFile)); QTranslator *translator = new QTranslator; - if (translator->load(QLocale(), QLatin1String("qml"), QLatin1String("_"), fi.path() + QLatin1String("/i18n"))) { + if (translator->load(QLocale(), QLatin1String("qml"), QLatin1String("_"), fi.path() + QLatin1String("/i18n"), QLatin1String(".qm"))) { QCoreApplication::installTranslator(translator); translators << translator; } else { @@ -180,6 +180,9 @@ void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) \list \li Connecting Qt.quit() to QCoreApplication::quit() \li Automatically loads translation files from an i18n directory adjacent to the main QML file. + \list + \li Translation files must have "qml_" prefix e.g. qml_ja_JP.qm. + \endlist \li Automatically sets an incubation controller if the scene contains a QQuickWindow. \li Automatically sets a \c QQmlFileSelector as the url interceptor, applying file selectors to all QML files and assets. diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 57ea685a5d..a23a322df9 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1207,7 +1207,7 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent) \js var component = Qt.createComponent("Button.qml"); if (component.status == Component.Ready) - component.createObject(parent, {"x": 100, "y": 100}); + component.createObject(parent, {x: 100, y: 100}); \endjs Dynamically created instances can be deleted with the \c destroy() method. diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp index c7f8ec1118..f08f3c1da7 100644 --- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp +++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp @@ -322,7 +322,7 @@ void tst_QQmlPreview::zoom() for (auto testZoomFactor : {2.0f, 1.5f, 0.5f}) { m_client->triggerZoom(testZoomFactor); - verifyZoomFactor(m_process, baseZoomFactor * testZoomFactor); + verifyZoomFactor(m_process, testZoomFactor); } m_client->triggerZoom(-1.0f); diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm Binary files differnew file mode 100644 index 0000000000..8e3c4967c2 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts new file mode 100644 index 0000000000..51a204be3e --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="" sourcelanguage="en"> +<context> + <name>loadTranslation</name> + <message> + <source>translate it</source> + <translation>translated</translation> + </message> +</context> +</TS> diff --git a/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml new file mode 100644 index 0000000000..bba4cab8d6 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + property string translation: qsTr('translate it') +} diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index ce654dc45e..a9c28a0911 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -50,6 +50,9 @@ private slots: void application(); void applicationProperties(); void removeObjectsWhenDestroyed(); + void loadTranslation_data(); + void loadTranslation(); + private: QString buildDir; QString srcDir; @@ -241,6 +244,30 @@ void tst_qqmlapplicationengine::removeObjectsWhenDestroyed() QCOMPARE(test->rootObjects().size(), 0); } +void tst_qqmlapplicationengine::loadTranslation_data() +{ + QTest::addColumn<QUrl>("qmlUrl"); + QTest::addColumn<QString>("translation"); + + QTest::newRow("local file") << testFileUrl("loadTranslation.qml") + << QStringLiteral("translated"); + QTest::newRow("qrc") << QUrl(QLatin1String("qrc:///data/loadTranslation.qml")) + << QStringLiteral("translated"); +} + +void tst_qqmlapplicationengine::loadTranslation() +{ + QFETCH(QUrl, qmlUrl); + QFETCH(QString, translation); + + QQmlApplicationEngine test(qmlUrl); + QVERIFY(!test.rootObjects().isEmpty()); + + QObject *rootObject = test.rootObjects().first(); + QVERIFY(rootObject); + + QCOMPARE(rootObject->property("translation").toString(), translation); +} QTEST_MAIN(tst_qqmlapplicationengine) diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro index 18c38a80b6..88d07f2b62 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro @@ -5,6 +5,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qqmlapplicationengine.cpp TESTDATA += data/* +RESOURCES += tst_qqmlapplicationengine.qrc include (../../shared/util.pri) QT += core-private gui-private qml-private network testlib + +TRANSLATIONS = data/i18n/qml_ja.ts diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc new file mode 100644 index 0000000000..de79d665a3 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>data/loadTranslation.qml</file> + <file>data/i18n/qml.qm</file> + </qresource> +</RCC> diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index fead8c4ebc..f16e96a385 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -54,6 +54,7 @@ private slots: void noSubstitutionTemplateLiteral(); void templateLiteral(); void leadingSemicolonInClass(); + void templatedReadonlyProperty(); private: QStringList excludedDirs; @@ -289,6 +290,15 @@ void tst_qqmlparser::leadingSemicolonInClass() QVERIFY(parser.parseProgram()); } +void tst_qqmlparser::templatedReadonlyProperty() +{ + QQmlJS::Engine engine; + QQmlJS::Lexer lexer(&engine); + lexer.setCode(QLatin1String("A { readonly property list<B> listfoo: [ C{} ] }"), 1); + QQmlJS::Parser parser(&engine); + QVERIFY(parser.parse()); +} + QTEST_MAIN(tst_qqmlparser) #include "tst_qqmlparser.moc" diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 1a5ce39318..e3dc0434b1 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1491,11 +1491,11 @@ void tst_QQuickPathView::undefinedPath() // QPainterPath warnings are only received if QT_NO_DEBUG is not defined if (QLibraryInfo::isDebugBuild()) { - QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1)); + QRegularExpression warning1("^QPainterPath::moveTo:.*ignoring call$"); + QTest::ignoreMessage(QtWarningMsg, warning1); - QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2)); + QRegularExpression warning2("^QPainterPath::lineTo:.*ignoring call$"); + QTest::ignoreMessage(QtWarningMsg, warning2); } QQmlComponent c(&engine, testFileUrl("undefinedpath.qml")); |