Merge remote-tracking branch 'origin/5.12' into 5.13

Change-Id: I59cb196ab17ed8504b33db01d827052eb6891efa
This commit is contained in:
Qt Forward Merge Bot 2019-06-06 01:00:05 +02:00
commit 369f3e57b8
13 changed files with 121 additions and 11 deletions

View File

@ -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");

View File

@ -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: {

View File

@ -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.

View File

@ -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.

View File

@ -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);

Binary file not shown.

View File

@ -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>

View File

@ -0,0 +1,5 @@
import QtQml 2.0
QtObject {
property string translation: qsTr('translate it')
}

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>data/loadTranslation.qml</file>
<file>data/i18n/qml.qm</file>
</qresource>
</RCC>

View File

@ -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"

View File

@ -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"));