diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-06-08 16:04:15 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-06-08 16:04:15 +0200 |
commit | c644e7c80aa752c6154fa36fdc3ce47e0e17e758 (patch) | |
tree | 7aea6f2d15477c7dc0b0e4aa9e00156920c65b1d /tests/auto | |
parent | bfcd1149eb688707a5495ce63f39e93bcf0c0a54 (diff) | |
parent | 42cad8970819c650c73f5daa4b6ea2f775ff7ad0 (diff) |
Merge remote-tracking branch 'origin/qds-1.59'
Conflicts:
src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp
Change-Id: Ifa7c66330c1995378280cdb4c57c30015dc11b68
Diffstat (limited to 'tests/auto')
37 files changed, 2948 insertions, 15 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro index 8a86681e62..dd0f071b0e 100644 --- a/tests/auto/qml/qmldesigner/coretests/coretests.pro +++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro @@ -61,8 +61,10 @@ SOURCES += \ ../testview.cpp \ testrewriterview.cpp \ tst_testcore.cpp + HEADERS += \ ../testview.h \ testrewriterview.h \ tst_testcore.h + RESOURCES += ../data/testfiles.qrc diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index 266dc92508..52fa6f519f 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -28,6 +28,7 @@ #include <QScopedPointer> #include <QLatin1String> #include <QGraphicsObject> +#include <QQueue> #include <QTest> #include <QVariant> @@ -42,6 +43,7 @@ #include <nodeinstanceview.h> #include <nodeinstance.h> #include <subcomponentmanager.h> +#include <stylesheetmerger.h> #include <QDebug> #include "../testview.h" @@ -3704,6 +3706,132 @@ void tst_TestCore::testCopyModelRewriter1() QCOMPARE(textEdit1.toPlainText(), expected); } +static QString readQmlFromFile(const QString& fileName) +{ + QFile qmlFile(fileName); + qmlFile.open(QIODevice::ReadOnly | QIODevice::Text); + QString qmlFileContents = QString::fromUtf8(qmlFile.readAll()); + return qmlFileContents; +} + +void tst_TestCore::testMergeModelRewriter1_data() +{ + QTest::addColumn<QString>("qmlTemplateString"); + QTest::addColumn<QString>("qmlStyleString"); + QTest::addColumn<QString>("qmlExpectedString"); + + QString simpleTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SimpleTemplate.qml"); + QString simpleStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SimpleStyle.qml"); + QString simpleExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SimpleExpected.qml"); + + QString complexTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ComplexTemplate.qml"); + QString complexStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ComplexStyle.qml"); + QString complexExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ComplexExpected.qml"); + + QString emptyTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/EmptyTemplate.qml"); + QString emptyStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/EmptyStyle.qml"); + QString emptyExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/EmptyExpected.qml"); + + QString rootReplacementTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/RootReplacementTemplate.qml"); + QString rootReplacementStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/RootReplacementStyle.qml"); + QString rootReplacementExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/RootReplacementExpected.qml"); + + QString switchTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SwitchTemplate.qml"); + QString switchStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SwitchStyle.qml"); + QString switchExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SwitchExpected.qml"); + + QString sliderTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SliderTemplate.qml"); + QString sliderStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SliderStyle.qml"); + QString sliderExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/SliderExpected.qml"); + + QString listViewTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ListViewTemplate.qml"); + QString listViewStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ListViewStyle.qml"); + QString listViewExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ListViewExpected.qml"); + + QString buttonTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonTemplate.qml"); + QString buttonInlineStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyleInline.qml"); + QString buttonInlineExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonInlineExpected.qml"); + + QString buttonAbsoluteTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonAbsoluteTemplate.qml"); + QString buttonOutlineStyleQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyleOutline.qml"); + QString buttonOutlineExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonOutlineExpected.qml"); + + QString buttonStyleUiQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyle.ui.qml"); + QString buttonStyleUiExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyle.ui.Expected.qml"); + + QString buttonAbsoluteTemplateWithOptionsQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonAbsoluteTemplateWithOptions.qml"); + QString buttonStyleUiWithOptionsExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyleWithOptions.ui.Expected.qml"); + + QString testExportButtonTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_template.ui.qml"); + QString testExportButtonStylesheetQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_stylesheet.ui.qml"); + QString testExportButtonExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_expected.ui.qml"); + + + QTest::newRow("Simple style replacement") << simpleTemplateQmlContents << simpleStyleQmlContents << simpleExpectedQmlContents; + QTest::newRow("Complex style replacement") << complexTemplateQmlContents << complexStyleQmlContents << complexExpectedQmlContents; + QTest::newRow("Empty stylesheet") << emptyTemplateQmlContents << emptyStyleQmlContents << emptyExpectedQmlContents; + QTest::newRow("Root node replacement") << rootReplacementTemplateQmlContents << rootReplacementStyleQmlContents << rootReplacementExpectedQmlContents; + QTest::newRow("Switch styling") << switchTemplateQmlContents << switchStyleQmlContents << switchExpectedQmlContents; + QTest::newRow("Slider styling") << sliderTemplateQmlContents << sliderStyleQmlContents << sliderExpectedQmlContents; + QTest::newRow("List View styling") << listViewTemplateQmlContents << listViewStyleQmlContents << listViewExpectedQmlContents; + QTest::newRow("Button Inline styling") << buttonTemplateQmlContents << buttonInlineStyleQmlContents << buttonInlineExpectedQmlContents; + + QTest::newRow("Button Outline styling") << buttonAbsoluteTemplateQmlContents << buttonOutlineStyleQmlContents << buttonOutlineExpectedQmlContents; + QTest::newRow("Button Designer styling") << buttonAbsoluteTemplateQmlContents << buttonStyleUiQmlContents << buttonStyleUiExpectedQmlContents; + + QTest::newRow("Button Designer styling with options") << buttonAbsoluteTemplateWithOptionsQmlContents << buttonStyleUiQmlContents << buttonStyleUiWithOptionsExpectedQmlContents; + QTest::newRow("Button styling with info screen test case ") << testExportButtonTemplateQmlContents << testExportButtonStylesheetQmlContents << testExportButtonExpectedQmlContents; + +} + +void tst_TestCore::testMergeModelRewriter1() +{ + QFETCH(QString, qmlTemplateString); + QFETCH(QString, qmlStyleString); + QFETCH(QString, qmlExpectedString); + + QPlainTextEdit textEdit1; + textEdit1.setPlainText(qmlTemplateString); + NotIndentingTextEditModifier textModifier1(&textEdit1); + + QScopedPointer<Model> templateModel(Model::create("QtQuick.Item", 2, 1)); + QVERIFY(templateModel.data()); + + QScopedPointer<TestView> templateView(new TestView(templateModel.data())); + templateModel->attachView(templateView.data()); + + // read in 1 + QScopedPointer<TestRewriterView> templateRewriterView(new TestRewriterView()); + templateRewriterView->setTextModifier(&textModifier1); + templateModel->attachView(templateRewriterView.data()); + + ModelNode templateRootNode = templateView->rootModelNode(); + QVERIFY(templateRootNode.isValid()); + + QPlainTextEdit textEdit2; + textEdit2.setPlainText(qmlStyleString); + NotIndentingTextEditModifier textModifier2(&textEdit2); + + QScopedPointer<Model> styleModel(Model::create("QtQuick.Item", 2, 1)); + QVERIFY(styleModel.data()); + + QScopedPointer<TestView> styleView(new TestView(styleModel.data())); + styleModel->attachView(styleView.data()); + + // read in 2 + QScopedPointer<TestRewriterView> styleRewriterView(new TestRewriterView()); + styleRewriterView->setTextModifier(&textModifier2); + styleModel->attachView(styleRewriterView.data()); + + StylesheetMerger merger(templateView.data(), styleView.data()); + merger.merge(); + + QString trimmedActual = textEdit1.toPlainText().trimmed(); + QString trimmedExpected = qmlExpectedString.trimmed(); + + QCOMPARE(trimmedActual, trimmedExpected); +} + void tst_TestCore::testCopyModelRewriter2() { const QLatin1String qmlString1("\n" @@ -3756,37 +3884,35 @@ void tst_TestCore::testCopyModelRewriter2() textEdit1.setPlainText(qmlString1); NotIndentingTextEditModifier textModifier1(&textEdit1); - QScopedPointer<Model> model1(Model::create("QtQuick.Item", 2, 1)); - QVERIFY(model1.data()); + QScopedPointer<Model> templateModel(Model::create("QtQuick.Item", 2, 1)); + QVERIFY(templateModel.data()); - QScopedPointer<TestView> view1(new TestView(model1.data())); - model1->attachView(view1.data()); + QScopedPointer<TestView> view1(new TestView(templateModel.data())); + templateModel->attachView(view1.data()); // read in 1 QScopedPointer<TestRewriterView> testRewriterView1(new TestRewriterView()); testRewriterView1->setTextModifier(&textModifier1); - model1->attachView(testRewriterView1.data()); + templateModel->attachView(testRewriterView1.data()); ModelNode rootNode1 = view1->rootModelNode(); QVERIFY(rootNode1.isValid()); QCOMPARE(rootNode1.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); - - // read in 2 - + // read in 2 QPlainTextEdit textEdit2; textEdit2.setPlainText(qmlString2); NotIndentingTextEditModifier textModifier2(&textEdit2); - QScopedPointer<Model> model2(Model::create("QtQuick.Item", 2, 1)); - QVERIFY(model2.data()); + QScopedPointer<Model> styleModel(Model::create("QtQuick.Item", 2, 1)); + QVERIFY(styleModel.data()); - QScopedPointer<TestView> view2(new TestView(model2.data())); - model2->attachView(view2.data()); + QScopedPointer<TestView> view2(new TestView(styleModel.data())); + styleModel->attachView(view2.data()); - QScopedPointer<TestRewriterView> testRewriterView2(new TestRewriterView()); - testRewriterView2->setTextModifier(&textModifier2); - model2->attachView(testRewriterView2.data()); + QScopedPointer<TestRewriterView> styleRewriterView(new TestRewriterView()); + styleRewriterView->setTextModifier(&textModifier2); + styleModel->attachView(styleRewriterView.data()); ModelNode rootNode2 = view2->rootModelNode(); QVERIFY(rootNode2.isValid()); diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h index 92f3b17161..92d4ac00aa 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h @@ -184,6 +184,8 @@ private slots: void testRewriterTransactionRewriter(); void testCopyModelRewriter1(); void testCopyModelRewriter2(); + void testMergeModelRewriter1_data(); + void testMergeModelRewriter1(); void testSubComponentManager(); void testAnchorsAndRewriting(); void testAnchorsAndRewritingCenter(); diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplate.qml new file mode 100644 index 0000000000..88d66014ac --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplate.qml @@ -0,0 +1,104 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Rectangle { + + id: buttonNormal + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + id: normalText + x: 26 + y: 14 //id only required to preserve binding + text: control.text //binding has to be preserved + //anchors.fill: parent + color: "gray" + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + + Rectangle { + id: buttonPressed + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + x: 26 + y: 14 + id: pressedText //id only required to preserve binding + text: control.text //binding has to be preserved + //anchors.fill: parent + color: "black" + + horizontalAlignment: Text.AlignHCenter // should not be preserved + verticalAlignment: Text.AlignVCenter // should not be preserved + elide: Text.ElideRight // should not be preserved + } + } + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] +} + diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplateWithOptions.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplateWithOptions.qml new file mode 100644 index 0000000000..de34e1ab0c --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonAbsoluteTemplateWithOptions.qml @@ -0,0 +1,109 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Rectangle { + + id: buttonNormal + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + id: normalText + x: 26 + y: 14 //id only required to preserve binding + text: control.text //binding has to be preserved + //anchors.fill: parent + color: "gray" + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + + Rectangle { + id: buttonPressed + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + x: 26 + y: 14 + id: pressedText //id only required to preserve binding + text: control.text //binding has to be preserved + //anchors.fill: parent + color: "black" + + horizontalAlignment: Text.AlignHCenter // should not be preserved + verticalAlignment: Text.AlignVCenter // should not be preserved + elide: Text.ElideRight // should not be preserved + } + } + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] + QtObject { + id: qds_stylesheet_merger_options + property bool preserveTextAlignment: true + } + +} + diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonInlineExpected.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonInlineExpected.qml new file mode 100644 index 0000000000..de131d2e64 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonInlineExpected.qml @@ -0,0 +1,93 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Rectangle { + id: buttonNormal + width: 100 + height: 60 + color: "#d4d4d4" + radius: 2 + border.color: "#808080" + border.width: 1 + anchors.fill: parent + Text { + id: normalText + color: "#808080" + text: control.text + elide: Text.ElideRight + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + Rectangle { + id: buttonPressed + width: 100 + height: 60 + color: "#69b5ec" + radius: 2 + border.color: "#808080" + border.width: 1 + anchors.fill: parent + Text { + id: pressedText + color: "#000000" + text: control.text + elide: Text.ElideRight + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] +}
\ No newline at end of file diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonOutlineExpected.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonOutlineExpected.qml new file mode 100644 index 0000000000..abe67f4fe8 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonOutlineExpected.qml @@ -0,0 +1,95 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Rectangle { + id: buttonNormal + width: 100 + height: 60 + color: "#d4d4d4" + radius: 2 + border.color: "#808080" + border.width: 1 + anchors.fill: parent + Text { + id: normalText + x: 33 + y: 24 + color: "#808080" + text: control.text + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + Rectangle { + id: buttonPressed + width: 100 + height: 60 + color: "#69b5ec" + radius: 2 + border.color: "#808080" + border.width: 1 + anchors.fill: parent + Text { + id: pressedText + x: 31 + y: 24 + color: "#000000" + text: control.text + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] +} diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.Expected.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.Expected.qml new file mode 100644 index 0000000000..ab54caa5b1 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.Expected.qml @@ -0,0 +1,88 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Image { + id: buttonNormal + width: 100 + height: 40 + anchors.fill: parent + source: "assets/buttonNormal.png" + Text { + id: normalText + x: 58 + y: 50 + color: "#bbbbbb" + text: control.text + font.letterSpacing: 0.594 + font.pixelSize: 24 + } + } + + Image { + id: buttonPressed + width: 100 + height: 40 + anchors.fill: parent + source: "assets/buttonPressed.png" + Text { + id: pressedText + x: 58 + y: 50 + color: "#e1e1e1" + text: control.text + font.letterSpacing: 0.594 + font.pixelSize: 24 + } + } + + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] +} + diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.qml new file mode 100644 index 0000000000..c16d51997c --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.qml @@ -0,0 +1,68 @@ +import QtQuick 2.8 + +Item { + id: buttonStyle + width: 576 + height: 169 + + Image { + id: buttonStyleAsset + x: 0 + y: 0 + source: "assets/ButtonStyle.png" + } + + Image { + id: buttonNormal + x: 14 + y: 5 + source: "assets/buttonNormal.png" + } + + Text { + id: normalText + x: 72 + y: 55 + color: "#BBBBBB" + text: "Button Normal" + font.letterSpacing: 0.594 + font.pixelSize: 24 + } + + Image { + id: buttonPressed + x: 290 + y: 5 + source: "assets/buttonPressed.png" + } + + Text { + id: pressedText + x: 348 + y: 55 + color: "#E1E1E1" + text: "Button Pressed" + font.letterSpacing: 0.594 + font.pixelSize: 24 + } + + Text { + id: annotation_text_to_b_219_17 + x: 78 + y: 137 + color: "#E1E1E1" + text: "Annotation Text - To be skipped on import " + font.letterSpacing: 0.594 + font.pixelSize: 24 + } +} + +/*##^## +Designer { + D{i:0;UUID:"2c9c0d7afb27ed7fc52953dffad06338"}D{i:1;UUID:"2c9c0d7afb27ed7fc52953dffad06338_asset"} +D{i:2;UUID:"fe9b73e310828dc3f213ba5ef14960b0"}D{i:3;UUID:"5c926d0aacc8788795645ff693c5211c"} +D{i:4;UUID:"261e8907a5da706273665c336dfec28a"}D{i:5;UUID:"7f46944edba773280017e4c8389c8ee0"} +D{i:6;UUID:"f4adf85e9cbce87a9e84a0aaa67d8a80"} +} +##^##*/ + diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonStyleInline.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleInline.qml new file mode 100644 index 0000000000..f33450bf7c --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleInline.qml @@ -0,0 +1,79 @@ +import QtQuick 2.12 + + +Rectangle { + id: artboard + width: 640 + height: 480 + color: "#ee4040" + + Rectangle { + + id: buttonNormal + x: 286 + y: 62 + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 60 + + border.color: "gray" + border.width: 1 + radius: 2 + + Text { + id: normalText //id only required to preserve binding + //binding has to be preserved + anchors.fill: parent //binding has to be preserved + color: "gray" + text: "Normal" + + horizontalAlignment: Text.AlignHCenter + //luckily enums are interpreted as variant properties and not bindings + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + + Rectangle { + id: buttonPressed + x: 123 + y: 62 + color: "#69b5ec" + width: 100 //Bit of black magic to define the default size + height: 60 + + border.color: "gray" + border.width: 1 + radius: 2 + + Text { + id: pressedText //id only required to preserve binding + //binding has to be preserved + anchors.fill: parent + color: "black" + text: "pressed" + + horizontalAlignment: Text.AlignHCenter // should not be preserved - + //luckily enums are interpreted as variant properties and not bindings + verticalAlignment: Text.AlignVCenter // should not be preserved + elide: Text.ElideRight // should not be preserved + } + } + + Text { + id: element + x: 1 + y: 362 + color: "#eaeaea" + text: qsTrId("Some stuff for reference that is thrown away") + font.pixelSize: 32 + } + + +} + +/*##^## +Designer { + D{i:0;formeditorColor:"#000000"} +} +##^##*/ diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonStyleOutline.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleOutline.qml new file mode 100644 index 0000000000..a9a7021383 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleOutline.qml @@ -0,0 +1,83 @@ +import QtQuick 2.12 + + +Rectangle { + id: artboard + width: 640 + height: 480 + color: "#ee4040" + + Rectangle { + + id: buttonNormal + x: 286 + y: 62 + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 60 + + border.color: "gray" + border.width: 1 + radius: 2 + } + + Text { + x: 319 + y: 86 + id: normalText //id only required to preserve binding + //binding has to be preserved + + color: "gray" + text: "Normal" + + horizontalAlignment: Text.AlignHCenter + //luckily enums are interpreted as variant properties and not bindings + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + Rectangle { + id: buttonPressed + x: 123 + y: 62 + color: "#69b5ec" + width: 100 //Bit of black magic to define the default size + height: 60 + + border.color: "gray" + border.width: 1 + radius: 2 + } + + Text { + x: 154 + y: 86 + id: pressedText //id only required to preserve binding + //binding has to be preserved + //anchors.fill: parent + color: "black" + text: "pressed" + + horizontalAlignment: Text.AlignHCenter // should not be preserved - + //luckily enums are interpreted as variant properties and not bindings + verticalAlignment: Text.AlignVCenter // should not be preserved + elide: Text.ElideRight // should not be preserved + } + + Text { + id: element + x: 1 + y: 362 + color: "#eaeaea" + text: qsTrId("Some stuff for reference that is thrown away") + font.pixelSize: 32 + } + + +} + +/*##^## +Designer { + D{i:0;formeditorColor:"#000000"} +} +##^##*/ diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonStyleWithOptions.ui.Expected.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleWithOptions.ui.Expected.qml new file mode 100644 index 0000000000..580a5f1560 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonStyleWithOptions.ui.Expected.qml @@ -0,0 +1,95 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Image { + id: buttonNormal + width: 100 + height: 40 + anchors.fill: parent + source: "assets/buttonNormal.png" + Text { + id: normalText + x: 58 + y: 50 + color: "#bbbbbb" + text: control.text + elide: Text.ElideRight + font.letterSpacing: 0.594 + font.pixelSize: 24 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + Image { + id: buttonPressed + width: 100 + height: 40 + anchors.fill: parent + source: "assets/buttonPressed.png" + Text { + id: pressedText + x: 58 + y: 50 + color: "#e1e1e1" + text: control.text + elide: Text.ElideRight + font.letterSpacing: 0.594 + font.pixelSize: 24 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] + +} + diff --git a/tests/auto/qml/qmldesigner/data/merging/ButtonTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/ButtonTemplate.qml new file mode 100644 index 0000000000..cd4b376a57 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ButtonTemplate.qml @@ -0,0 +1,100 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T + +T.Button { + id: control + + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + text: "My Button" + + background: Item { + implicitWidth: buttonNormal.width + implicitHeight: buttonNormal.height + opacity: enabled ? 1 : 0.3 + + Rectangle { + + id: buttonNormal + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + id: normalText //id only required to preserve binding + text: control.text //binding has to be preserved + anchors.fill: parent + color: "gray" + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + + Rectangle { + id: buttonPressed + color: "#d4d4d4" + width: 100 //Bit of black magic to define the default size + height: 40 + + border.color: "gray" + border.width: 1 + radius: 2 + anchors.fill: parent //binding has to be preserved + + Text { + id: pressedText //id only required to preserve binding + text: control.text //binding has to be preserved + anchors.fill: parent + color: "black" + + horizontalAlignment: Text.AlignHCenter // should not be preserved + verticalAlignment: Text.AlignVCenter // should not be preserved + elide: Text.ElideRight // should not be preserved + } + } + } + + contentItem: Item {} + + states: [ + State { + name: "normal" + when: !control.down + PropertyChanges { + target: buttonPressed + visible: false + } + PropertyChanges { + target: buttonNormal + visible: true + } + }, + State { + name: "down" + when: control.down + PropertyChanges { + target: buttonPressed + visible: true + } + PropertyChanges { + target: buttonNormal + visible: false + } + } + ] +} + diff --git a/tests/auto/qml/qmldesigner/data/merging/ComplexExpected.qml b/tests/auto/qml/qmldesigner/data/merging/ComplexExpected.qml new file mode 100644 index 0000000000..a3347ab4af --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ComplexExpected.qml @@ -0,0 +1,63 @@ +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle0 + x: 10 + y: 10 + width: 200 + height: 150 + + Image { + id: rectangle1 + x: 10 + y: 10 + width: 100 + height: 150 + source: "qt/icon.png" + } + } + + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + + Rectangle { + id: rectangle3 + x: 140 + y: 180 + gradient: Gradient { + GradientStop { + position: 0 + color: "#ffffff" + } + + GradientStop { + position: 1 + color: "#000000" + } + } + Image { + id: rectangle4 + x: 10 + y: 20 + width: 100 + height: 150 + source: "qt/realcool.jpg" + Rectangle { + id: rectangle5 + x: 10 + y: 20 + width: 200 + height: 50 + } + } + } + +} diff --git a/tests/auto/qml/qmldesigner/data/merging/ComplexStyle.qml b/tests/auto/qml/qmldesigner/data/merging/ComplexStyle.qml new file mode 100644 index 0000000000..63ed4868de --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ComplexStyle.qml @@ -0,0 +1,46 @@ +import QtQuick 2.1 + +Item { + Rectangle { + id: rectangle0 + Image { + id: rectangle1 + x: 10 + y: 10 + height: 150 + width: 100 + source: "qt/icon.png" + } + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + + GradientStop { + position: 1 + color: "black" + } + } + } + Rectangle { + id: rectangle5 + x: 160 + y: 220 + width: 200 + height: 50 + } + Image { + id: rectangle4 + x: 150; + y: 200; + height: 150 + width: 100 + source: "qt/realcool.jpg" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/ComplexTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/ComplexTemplate.qml new file mode 100644 index 0000000000..058b969823 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ComplexTemplate.qml @@ -0,0 +1,49 @@ +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle0 + x: 10; + y: 10; + height: 150 + width: 200 + } + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "black" + } + GradientStop { + position: 1 + color: "white" + } + } + Rectangle { + id: rectangle4 + x: 10 + y: 20 + width: 200 + height: 50 + Rectangle { + id: rectangle5 + x: 10 + y: 20 + width: 200 + height: 50 + } + } + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/EmptyStyleExpected.qml b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleExpected.qml new file mode 100644 index 0000000000..122ccd8767 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleExpected.qml @@ -0,0 +1,43 @@ +// Test that an empty style sheet will leave the original template untouched. +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle0 + x: 10; + y: 10; + height: 150 + width: 200 + } + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + GradientStop { + position: 1 + color: "black" + } + } + Rectangle { + id: rectangle4 + x: 10 + y: 20 + width: 200 + height: 50 + } + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/EmptyStyleStyle.qml b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleStyle.qml new file mode 100644 index 0000000000..8040be2697 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleStyle.qml @@ -0,0 +1 @@ +import QtQuick 2.1 diff --git a/tests/auto/qml/qmldesigner/data/merging/EmptyStyleTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleTemplate.qml new file mode 100644 index 0000000000..122ccd8767 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/EmptyStyleTemplate.qml @@ -0,0 +1,43 @@ +// Test that an empty style sheet will leave the original template untouched. +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle0 + x: 10; + y: 10; + height: 150 + width: 200 + } + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + GradientStop { + position: 1 + color: "black" + } + } + Rectangle { + id: rectangle4 + x: 10 + y: 20 + width: 200 + height: 50 + } + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/ListViewExpected.qml b/tests/auto/qml/qmldesigner/data/merging/ListViewExpected.qml new file mode 100644 index 0000000000..a8da56b1df --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ListViewExpected.qml @@ -0,0 +1,135 @@ +import QtQuick 2.10 + +ListView { + id: view + width: listViewBackground.width + height: listViewBackground.height + highlight: Rectangle { + id: listViewHighLight + width: view.width + height: 120 + color: "#343434" + radius: 4 + border.color: "#0d52a4" + border.width: 8 + } + + highlightMoveDuration: 0 + + children: [ + Item { + z: -1 + anchors.fill: parent + + Rectangle { + id: listViewBackground + width: 420 + height: 420 + color: "#69b5ec" + anchors.fill: parent + } + } + ] + + model: ListModel { + ListElement { + name: "Music" + } + ListElement { + name: "Movies" + } + ListElement { + name: "Camera" + } + ListElement { + name: "Map" + } + ListElement { + name: "Calendar" + } + ListElement { + name: "Messaging" + } + ListElement { + name: "Todo List" + } + ListElement { + name: "Contacts" + } + ListElement { + name: "Settings" + } + } + + + delegate: Item { + id: delegate + width: ListView.view.width + height: delegateNormal.height + + Rectangle { + id: delegateNormal + width: 420 + height: 120 + visible: true + color: "#bdbdbd" + radius: 4 + anchors.fill: parent + anchors.margins: 12 + Text { + id: labelNormal + color: "#343434" + text: name + anchors.top: parent.top + anchors.margins: 24 + anchors.horizontalCenter: parent.horizontalCenter + } + } + + + Rectangle { + id: delegateHighlighted + width: 420 + height: 120 + visible: false + color: "#8125eb29" + radius: 4 + anchors.fill: parent + anchors.margins: 12 + Text { + id: labelHighlighted + color: "#efefef" + text: name + anchors.top: parent.top + anchors.margins: 52 + anchors.horizontalCenter: parent.horizontalCenter + } + } + + MouseArea { + anchors.fill: parent + onClicked: delegate.ListView.view.currentIndex = index + } + + + states: [ + State { + name: "Highlighted" + + when: delegate.ListView.isCurrentItem + PropertyChanges { + target: delegateHighlighted + visible: true + } + + PropertyChanges { + target: delegateNormal + visible: false + } + + + } + ] + } + +}
\ No newline at end of file diff --git a/tests/auto/qml/qmldesigner/data/merging/ListViewStyle.qml b/tests/auto/qml/qmldesigner/data/merging/ListViewStyle.qml new file mode 100644 index 0000000000..4e68326f0a --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ListViewStyle.qml @@ -0,0 +1,82 @@ +import QtQuick 2.12 + + +Rectangle { + id: artboard + width: 800 + height: 600 + color: "#ee4040" + + Rectangle { + id: listViewBackground + x: 19 + y: 34 + width: 420 + height: 420 + + color: "#69b5ec" + + } + + Rectangle { + id: delegateNormal + x: 19 + y: 51 + color: "#bdbdbd" + + height: 120 + + width: 420 + + radius: 4 + Text { + id: labelNormal //id required for binding preservation + color: "#343434" + text: "some text" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + + anchors.margins: 24 + } + } + + + Rectangle { + id: delegateHighlighted + x: 19 + y: 177 + color: "#8125eb29" + height: 120 + + width: 420 + + radius: 4 + Text { + id: labelHighlighted //id required for binding preservation + color: "#efefef" + text: "some text" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + + anchors.margins: 52 + } + } + + + Rectangle { + id: listViewHighLight + x: 19 + y: 323 + width: 420 + height: 120 + color: "#343434" + radius: 4 + border.color: "#0d52a4" + border.width: 8 + } + + + +} + + diff --git a/tests/auto/qml/qmldesigner/data/merging/ListViewTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/ListViewTemplate.qml new file mode 100644 index 0000000000..6c59ca4d39 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/ListViewTemplate.qml @@ -0,0 +1,133 @@ +import QtQuick 2.10 + +ListView { + id: view + width: listViewBackground.width + height: listViewBackground.height + + highlightMoveDuration: 0 + + children: [ + Item { + z: -1 + anchors.fill: parent + + Rectangle { + id: listViewBackground + width: 420 + height: 420 + + color: "#d80e0e" + anchors.fill: parent // hsa to be preserved + } + } + ] + + model: ListModel { + ListElement { + name: "Music" + } + ListElement { + name: "Movies" + } + ListElement { + name: "Camera" + } + ListElement { + name: "Map" + } + ListElement { + name: "Calendar" + } + ListElement { + name: "Messaging" + } + ListElement { + name: "Todo List" + } + ListElement { + name: "Contacts" + } + ListElement { + name: "Settings" + } + } + + highlight: Rectangle { + id: listViewHighLight + width: view.width // has to be preserved + height: 120 + color: "#343434" + radius: 4 + border.color: "#0d52a4" + border.width: 8 + } + + delegate: Item { + id: delegate + width: ListView.view.width + height: delegateNormal.height + + Rectangle { + id: delegateNormal + color: "#bdbdbd" + anchors.fill: parent + height: 140 + anchors.margins: 12 + visible: true + radius: 4 + Text { + id: labelNormal //id required for binding preservation + color: "#343434" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + + text: name + anchors.margins: 24 + } + } + + Rectangle { + id: delegateHighlighted + color: "#36bdbdbd" + anchors.fill: parent + anchors.margins: 12 + visible: false + radius: 4 + Text { + id: labelHighlighted //id required for binding preservation + color: "#efefef" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + + text: name + anchors.margins: 32 + } + } + + + MouseArea { + anchors.fill: parent + onClicked: delegate.ListView.view.currentIndex = index + } + states: [ + State { + name: "Highlighted" + + when: delegate.ListView.isCurrentItem + PropertyChanges { + target: delegateHighlighted + visible: true + } + + PropertyChanges { + target: delegateNormal + visible: false + } + + + } + ] + } + +} diff --git a/tests/auto/qml/qmldesigner/data/merging/RootReplacementExpected.qml b/tests/auto/qml/qmldesigner/data/merging/RootReplacementExpected.qml new file mode 100644 index 0000000000..02f75103f4 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/RootReplacementExpected.qml @@ -0,0 +1,26 @@ +import QtQuick 2.1 + +Item { + id: root + + Rectangle { + id: rectangle0 + Image { + id: rectangle1 + x: 10 + y: 10 + width: 100 + height: 150 + source: "qt/icon.png" + } + } + + Image { + id: rectangle4 + x: 10 + y: 10 + width: 100 + height: 150 + source: "qt/realcool.jpg" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/RootReplacementStyle.qml b/tests/auto/qml/qmldesigner/data/merging/RootReplacementStyle.qml new file mode 100644 index 0000000000..0432a21b78 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/RootReplacementStyle.qml @@ -0,0 +1,24 @@ +import QtQuick 2.1 + +Item { + id: root + Rectangle { + id: rectangle0 + Image { + id: rectangle1 + x: 10 + y: 10 + height: 150 + width: 100 + source: "qt/icon.png" + } + } + Image { + id: rectangle4 + x: 10; + y: 10; + height: 150 + width: 100 + source: "qt/realcool.jpg" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/RootReplacementTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/RootReplacementTemplate.qml new file mode 100644 index 0000000000..0524162afa --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/RootReplacementTemplate.qml @@ -0,0 +1,35 @@ +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle1 + x: 10; + y: 10; + height: 150 + width: 200 + } + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + GradientStop { + position: 1 + color: "black" + } + } + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/SimpleExpected.qml b/tests/auto/qml/qmldesigner/data/merging/SimpleExpected.qml new file mode 100644 index 0000000000..9b7c6ff02b --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SimpleExpected.qml @@ -0,0 +1,38 @@ +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Image { + id: rectangle1 + x: 10 + y: 10 + width: 100 + height: 150 + source: "qt/icon.png" + } + + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + GradientStop { + position: 1 + color: "black" + } + } + } + +} diff --git a/tests/auto/qml/qmldesigner/data/merging/SimpleStyle.qml b/tests/auto/qml/qmldesigner/data/merging/SimpleStyle.qml new file mode 100644 index 0000000000..92e2e4cc5f --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SimpleStyle.qml @@ -0,0 +1,10 @@ +import QtQuick 2.1 + + Image { + id: rectangle1 + x: 10; + y: 10; + height: 150 + width: 100 + source: "qt/icon.png" + } diff --git a/tests/auto/qml/qmldesigner/data/merging/SimpleTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/SimpleTemplate.qml new file mode 100644 index 0000000000..22ac72ed94 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SimpleTemplate.qml @@ -0,0 +1,38 @@ +import QtQuick 2.1 + +Rectangle { + id: root + x: 10; + y: 10; + Rectangle { + id: rectangle1 + x: 10; + y: 10; + height: 150 + width: 200 + } + Rectangle { + id: rectangle2 + x: 100; + y: 100; + anchors.fill: root + } + Rectangle { + id: rectangle3 + x: 140; + y: 180; + gradient: Gradient { + GradientStop { + position: 0 + color: "white" + } + GradientStop { + position: 1 + color: "black" + } + } + } +} + + + diff --git a/tests/auto/qml/qmldesigner/data/merging/SliderExpected.qml b/tests/auto/qml/qmldesigner/data/merging/SliderExpected.qml new file mode 100644 index 0000000000..aa80d5d355 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SliderExpected.qml @@ -0,0 +1,68 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +Slider { + id: control + value: 0.5 + + background: Item { + x: control.leftPadding + y: control.topPadding + control.availableHeight / 2 - height / 2 + implicitWidth: sliderGroove.width + implicitHeight: sliderGroove.height + height: implicitHeight + width: control.availableWidth + + Rectangle { + id: sliderGroove + width: 200 + height: 6 + color: "#bdbebf" + radius: 2 + anchors.fill: parent + } + + Item { + width: control.visualPosition * sliderGroove.width // should be preserved + height: sliderGrooveLeft.height + clip: true + + Rectangle { + id: sliderGrooveLeft + width: 200 + height: 6 + color: "#21be2b" + radius: 2 + } + } + + } + + handle: Item { + x: control.leftPadding + control.visualPosition * (control.availableWidth - width) + y: control.topPadding + control.availableHeight / 2 - height / 2 + + implicitWidth: handleNormal.width + implicitHeight: handleNormal.height + Rectangle { + id: handleNormal + width: 32 + height: 32 + visible: !control.pressed + color: "#f6f6f6" + radius: 13 + border.color: "#bdbebf" + } + + Rectangle { + id: handlePressed + width: 32 + height: 32 + visible: control.pressed + color: "#221bdb" + radius: 13 + border.color: "#bdbebf" + } + + } +}
\ No newline at end of file diff --git a/tests/auto/qml/qmldesigner/data/merging/SliderStyle.qml b/tests/auto/qml/qmldesigner/data/merging/SliderStyle.qml new file mode 100644 index 0000000000..8af1ab1e3f --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SliderStyle.qml @@ -0,0 +1,65 @@ +import QtQuick 2.12 + + +Item { + id: artboard + width: 640 + height: 480 + + Rectangle { + id: sliderGroove + x: 78 + y: 127 + width: 200 + height: 6 + color: "#bdbebf" + } + + Rectangle { + id: sliderGrooveLeft + x: 78 + y: 165 + width: 200 + height: 6 + color: "#21be2b" + radius: 2 + } + + Rectangle { + id: handleNormal + x: 130 + y: 74 + width: 32 + height: 32 + radius: 13 + color: "#f6f6f6" + border.color: "#bdbebf" + } + Rectangle { + id: handlePressed + x: 78 + y: 74 + width: 32 + height: 32 + radius: 13 + color: "#221bdb" + border.color: "#bdbebf" + } + + Text { + id: element + x: 8 + y: 320 + color: "#eaeaea" + text: qsTrId("Some stuff for reference that is thrown away") + font.pixelSize: 32 + } + + +} + +/*##^## +Designer { + D{i:0;formeditorColor:"#000000"} +} +##^##*/ diff --git a/tests/auto/qml/qmldesigner/data/merging/SliderTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/SliderTemplate.qml new file mode 100644 index 0000000000..f78a00ef66 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SliderTemplate.qml @@ -0,0 +1,66 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +Slider { + id: control + value: 0.5 + + background: Item { + x: control.leftPadding + y: control.topPadding + control.availableHeight / 2 - height / 2 + implicitWidth: sliderGroove.width + implicitHeight: sliderGroove.height + height: implicitHeight + width: control.availableWidth + Rectangle { + id: sliderGroove + + width: 200 + height: 4 + + anchors.fill: parent // has to be preserved + radius: 2 + color: "#bdbebf" + } + + Item { + width: control.visualPosition * sliderGroove.width // should be preserved + height: sliderGrooveLeft.height + clip: true + + Rectangle { + id: sliderGrooveLeft + width: 200 + height: 4 + color: "#21be2b" + radius: 2 + } + } + } + + handle: Item { + x: control.leftPadding + control.visualPosition * (control.availableWidth - width) + y: control.topPadding + control.availableHeight / 2 - height / 2 + + implicitWidth: handleNormal.width + implicitHeight: handleNormal.height + Rectangle { + id: handleNormal + width: 26 + height: 26 + radius: 13 + color: "#f6f6f6" + visible: !control.pressed //has to be preserved + border.color: "#bdbebf" + } + Rectangle { + id: handlePressed + width: 26 + height: 26 + radius: 13 + visible: control.pressed //has to be preserved + color: "#f0f0f0" + border.color: "#bdbebf" + } + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/SwitchExpected.qml b/tests/auto/qml/qmldesigner/data/merging/SwitchExpected.qml new file mode 100644 index 0000000000..ebaf20c178 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SwitchExpected.qml @@ -0,0 +1,111 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import TemplateMerging 1.0 + +T.Switch { + id: control + + implicitWidth: background.implicitWidth + implicitHeight: background.implicitHeight + + text: "test" + indicator: Rectangle { + id: switchIndicator + x: control.leftPadding + y: 34 + width: 64 + height: 44 + color: "#e9e9e9" + radius: 16 + border.color: "#dddddd" + anchors.verticalCenter: parent.verticalCenter + Rectangle { + id: switchHandle + width: 31 + height: 44 + color: "#e9e9e9" + radius: 16 + border.color: "#808080" + } + } + + background: Item { + implicitWidth: switchBackground.width + implicitHeight: switchBackground.height + + Rectangle { + id: switchBackground + width: 144 + height: 52 + color: "#c2c2c2" + border.color: "#808080" + anchors.fill: parent + Text { + id: switchBackgroundText + text: control.text + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 12 + } + } + } + + leftPadding: 4 + + contentItem: Item { //designer want to edit the label as part of background + } + + + states: [ + State { + name: "off" + when: !control.checked && !control.down + }, + State { + name: "on" + when: control.checked && !control.down + + PropertyChanges { + target: switchIndicator + color: "#1713de" + border.color: "#1713de" + } + + PropertyChanges { + target: switchHandle + x: parent.width - width + } + }, + State { + name: "off_down" + when: !control.checked && control.down + + PropertyChanges { + target: switchIndicator + color: "#e9e9e9" + } + + PropertyChanges { + target: switchHandle + color: "#d2d2d2" + border.color: "#d2d2d2" + } + }, + State { + name: "on_down" + when: control.checked && control.down + + PropertyChanges { + target: switchHandle + x: parent.width - width + color: "#e9e9e9" + } + + PropertyChanges { + target: switchIndicator + color: "#030381" + border.color: "#030381" + } + } + ] +}
\ No newline at end of file diff --git a/tests/auto/qml/qmldesigner/data/merging/SwitchStyle.qml b/tests/auto/qml/qmldesigner/data/merging/SwitchStyle.qml new file mode 100644 index 0000000000..9f8cffc9b7 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SwitchStyle.qml @@ -0,0 +1,66 @@ +import QtQuick 2.12 + +Item { + width: 640 + height: 480 + + Rectangle { + id: switchIndicator + x: 219 + y: 34 + width: 64 + height: 44 + + color: "#e9e9e9" + + radius: 16 + border.color: "#dddddd" + + Rectangle { + id: switchHandle //id is required for states + + width: 31 + height: 44 + radius: 16 + color: "#e9e9e9" + border.color: "#808080" + } + } + + Rectangle { + id: switchBackground + x: 346 + y: 27 + width: 144 + height: 52 + color: "#c2c2c2" + border.color: "#808080" + + Text { + id: switchBackgroundText + text: "background" + anchors.right: parent.right + + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 12 + } + } + + Text { + id: element + x: 1 + y: 362 + color: "#eaeaea" + text: qsTrId("Some stuff for reference that is thrown away") + font.pixelSize: 32 + } + + Rectangle { //This is ignored when merging + id: weirdStuff02 + x: 8 + y: 87 + width: 624 + height: 200 + color: "#ffffff" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/SwitchTemplate.qml b/tests/auto/qml/qmldesigner/data/merging/SwitchTemplate.qml new file mode 100644 index 0000000000..2d794a8469 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/SwitchTemplate.qml @@ -0,0 +1,114 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import TemplateMerging 1.0 + +T.Switch { + id: control + + implicitWidth: background.implicitWidth + implicitHeight: background.implicitHeight + + text: "test" + + background: Item { + implicitWidth: switchBackground.width + implicitHeight: switchBackground.height + Rectangle { + id: switchBackground + color: "#ef1d1d" + border.color: "#808080" + width: 12 * 6.0 + height: 12 * 3.8 + anchors.fill: parent // has to be preserved + Text { + id: switchBackgroundText + anchors.right: parent.right // does have to be preserved -- how to handle this? - anchors preference from style if not "root"? + + anchors.verticalCenter: parent.verticalCenter // does have to be preserved -- how to handle this? - anchors preference from style if not "root"? + text: control.text // has to be preserved + anchors.rightMargin: 12 * 5 + } + } + } + + leftPadding: 4 + + contentItem: Item { //designer want to edit the label as part of background + } + + + indicator: Rectangle { + id: switchIndicator + width: 58 + height: 31 + x: control.leftPadding // has to be preserved + color: "#e9e9e9" + anchors.verticalCenter: parent.verticalCenter // has to be preserved + radius: 16 + border.color: "#dddddd" + + Rectangle { + id: switchHandle //id is required for states + + width: 31 + height: 31 + radius: 16 + color: "#e9e9e9" + border.color: "#808080" + } + } + states: [ + State { + name: "off" + when: !control.checked && !control.down + }, + State { + name: "on" + when: control.checked && !control.down + + PropertyChanges { + target: switchIndicator + color: "#1713de" + border.color: "#1713de" + } + + PropertyChanges { + target: switchHandle + x: parent.width - width + } + }, + State { + name: "off_down" + when: !control.checked && control.down + + PropertyChanges { + target: switchIndicator + color: "#e9e9e9" + } + + PropertyChanges { + target: switchHandle + color: "#d2d2d2" + border.color: "#d2d2d2" + } + }, + State { + name: "on_down" + when: control.checked && control.down + + PropertyChanges { + target: switchHandle + x: parent.width - width + color: "#e9e9e9" + } + + PropertyChanges { + target: switchIndicator + color: "#030381" + border.color: "#030381" + } + } + ] +} + + diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml new file mode 100644 index 0000000000..976431b8cd --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml @@ -0,0 +1,279 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import Home 1.0 + +T.Button { + id: control + width: 296 + height: 538 + + font: Constants.font + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + background: normalBG + contentItem: normalContent + Item { + id: normalBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: normalBGAsset + x: 0 + y: 0 + source: "assets/normalBG.png" + } + } + + Item { + id: normalContent + x: 0 + y: 42 + width: 296 + height: 428 + + Image { + id: normalContentAsset + x: 115 + y: 40 + source: "assets/normalContent.png" + } + + Text { + id: normal_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#c1c1c1" + text: "Normal button text" + font.pixelSize: 30 + lineHeight: 44 + lineHeightMode: Text.FixedHeight + wrapMode: Text.WordWrap + } + + Text { + id: normal_button_label + x: 113 + y: 203 + color: "#c1c1c1" + text: "Normal Button label" + font.pixelSize: 36 + } + } + Item { + id: focusedBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: focusedBGAsset + x: 0 + y: 0 + source: "assets/focusedBG.png" + } + + Item { + id: highlight_item_focused_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_focused_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_focusedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_focusedBG_1.png" + } + + Image { + id: highlight_img_focusedBG_1 + x: 0 + y: 0 + source: "assets/highlight_img_focusedBG_1.png" + } + + Image { + id: highlight_img_focused_1 + x: 291 + y: 7 + source: "assets/highlight_img_focused_1.png" + } + } + Item { + id: focusedContent + x: 0 + y: 42 + width: 296 + height: 428 + + Image { + id: focusedContentAsset + x: 115 + y: 40 + source: "assets/focusedContent.png" + } + + Text { + id: focus_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#ffffff" + text: "Focus button text" + font.pixelSize: 30 + lineHeight: 44 + lineHeightMode: Text.FixedHeight + wrapMode: Text.WordWrap + } + + Text { + id: focus_button_label + x: 113 + y: 203 + color: "#ba544d" + text: "Button label focus" + font.pixelSize: 36 + } + } + + Item { + id: pressedBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: pressedBGAsset + x: 0 + y: 0 + source: "assets/pressedBG.png" + } + + Item { + id: highlight_item_pressed_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_pressed_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_pressedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_pressedBG_1.png" + } + + Image { + id: highlight_img_pressed_1 + x: 0 + y: 0 + source: "assets/highlight_img_pressed_1.png" + } + + Image { + id: highlight_img_pressed_2 + x: 291 + y: 7 + source: "assets/highlight_img_pressed_2.png" + } + } + + Image { + id: defaultBG + x: 35 + y: 339 + source: "assets/defaultBG.png" + } + + + + + + + states: [ + State { + name: "normal" + when: !control.down && !control.focus + + PropertyChanges { + target: focusedBG + visible: false + } + PropertyChanges { + target: focusedContent + visible: false + } + PropertyChanges { + target: pressedBG + visible: false + } + }, + State { + name: "press" + when: control.down && control.focus + PropertyChanges { + target: control + contentItem: focusedContent + } + + PropertyChanges { + target: normalBG + visible: false + } + + PropertyChanges { + target: normalContent + visible: false + } + + PropertyChanges { + target: pressedBG + visible: true + } + + PropertyChanges { + target: focusedContent + visible: true + } + + PropertyChanges { + target: control + background: pressedBG + } + } + ] +} diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml new file mode 100644 index 0000000000..75c8653b39 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml @@ -0,0 +1,255 @@ +import QtQuick 2.10 + +Item { + id: info_screen + width: 296 + height: 538 + + Item { + id: normalBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: normalBGAsset + x: 0 + y: 0 + source: "assets/normalBG.png" + } + } + + Item { + id: normalContent + x: 0 + y: 42 + width: 296 + height: 428 + Image { + id: normalContentAsset + x: 115 + y: 40 + source: "assets/normalContent.png" + } + + Text { + id: normal_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#C1C1C1" + text: "Normal button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: normal_button_label + x: 113 + y: 203 + color: "#C1C1C1" + text: "Normal Button label" + font.pixelSize: 36 + } + } + + Item { + id: pressedBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: pressedBGAsset + x: 0 + y: 0 + source: "assets/pressedBG.png" + } + + Item { + id: highlight_item_pressed_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_pressed_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_pressedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_pressedBG_1.png" + } + + Image { + id: highlight_img_pressed_1 + x: 0 + y: 0 + source: "assets/highlight_img_pressed_1.png" + } + + Image { + id: highlight_img_pressed_2 + x: 291 + y: 7 + source: "assets/highlight_img_pressed_2.png" + } + } + + Item { + id: focusedBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: focusedBGAsset + x: 0 + y: 0 + source: "assets/focusedBG.png" + } + + Item { + id: highlight_item_focused_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_focused_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_focusedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_focusedBG_1.png" + } + + Image { + id: highlight_img_focusedBG_1 + x: 0 + y: 0 + source: "assets/highlight_img_focusedBG_1.png" + } + + Image { + id: highlight_img_focused_1 + x: 291 + y: 7 + source: "assets/highlight_img_focused_1.png" + } + } + + Item { + id: focusedContent + x: 0 + y: 42 + width: 296 + height: 428 + Image { + id: focusedContentAsset + x: 115 + y: 40 + source: "assets/focusedContent.png" + } + + Text { + id: focus_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#FFFFFF" + text: "Focus button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: focus_button_label + x: 113 + y: 203 + color: "#BA544D" + text: "Button label focus" + font.pixelSize: 36 + } + } + + Item { + id: disabledBG + x: 0 + y: 0 + width: 296 + height: 533 + Image { + id: disabledBGAsset + x: 0 + y: 0 + source: "assets/disabledBG.png" + } + } + + Item { + id: disabledContent + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: disabledContentAsset + x: 115 + y: 82 + source: "assets/disabledContent.png" + } + + Text { + id: disabled_button_text + x: 59 + y: 395 + width: 241 + height: 75 + color: "#413E3C" + text: "Disabled button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: disabled_button_label + x: 109 + y: 242 + color: "#413E3C" + text: "Disabled button label" + font.pixelSize: 40 + } + } + + Image { + id: defaultBG + x: 35 + y: 339 + source: "assets/defaultBG.png" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml new file mode 100644 index 0000000000..ac96a076f9 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml @@ -0,0 +1,99 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import Home 1.0 + +T.Button { + id: control + width: 296 + height: 538 + + font: Constants.font + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + background: normalBG + contentItem: normalContent + + Item { + id: normalBG + } + Item { + id: normalContent + } + + Item { + id: focusedBG + } + Item { + id: focusedContent + } + Item { + id: pressedBG + } + Item { + id: defaultBG + } + + states: [ + State { + name: "normal" + when: !control.down && !control.focus + + PropertyChanges { + target: focusedBG + visible: false + } + PropertyChanges { + target: focusedContent + visible: false + } + PropertyChanges { + target: pressedBG + visible: false + } + }, + State { + name: "press" + when: control.down && control.focus + PropertyChanges { + target: control + contentItem: focusedContent + } + + PropertyChanges { + target: normalBG + visible: false + } + + PropertyChanges { + target: normalContent + visible: false + } + + PropertyChanges { + target: pressedBG + visible: true + } + + PropertyChanges { + target: focusedContent + visible: true + } + + PropertyChanges { + target: control + background: pressedBG + } + } + ] + QtObject { + id: qds_stylesheet_merger_options + property bool useStyleSheetPositions: true + } +} |