forked from qt-creator/qt-creator
Add some more tests for automatic stylesheet preprocessing
Currently, the tests fail, but the output is by and large correct. There are some issues that still need to be analyzed. Task-number: QDS-2071 Change-Id: Idb4618171a7256ec527368d6079c756eb734db82 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -3773,6 +3773,9 @@ void tst_TestCore::testMergeModelRewriter1_data()
|
||||
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");
|
||||
|
||||
QTest::newRow("Simple style replacement") << simpleTemplateQmlContents << simpleStyleQmlContents << simpleExpectedQmlContents;
|
||||
QTest::newRow("Complex style replacement") << complexTemplateQmlContents << complexStyleQmlContents << complexExpectedQmlContents;
|
||||
QTest::newRow("Empty stylesheet") << emptyTemplateQmlContents << emptyStyleQmlContents << emptyExpectedQmlContents;
|
||||
@@ -3783,6 +3786,7 @@ void tst_TestCore::testMergeModelRewriter1_data()
|
||||
QTest::newRow("Button Inline styling") << buttonTemplateQmlContents << buttonInlineStyleQmlContents << buttonInlineExpectedQmlContents;
|
||||
|
||||
QTest::newRow("Button Outline styling") << buttonAbsoluteTemplateQmlContents << buttonOutlineStyleQmlContents << buttonOutlineExpectedQmlContents;
|
||||
QTest::newRow("Button Designer styling") << buttonAbsoluteTemplateQmlContents << buttonStyleUiQmlContents << buttonStyleUiExpectedQmlContents;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,8 @@ T.Button {
|
||||
|
||||
Rectangle {
|
||||
id: buttonNormal
|
||||
x: 286
|
||||
y: 62
|
||||
width: 100
|
||||
height: 60
|
||||
color: "#d4d4d4"
|
||||
@@ -31,8 +33,8 @@ T.Button {
|
||||
anchors.fill: parent
|
||||
Text {
|
||||
id: normalText
|
||||
x: 20
|
||||
y: 20
|
||||
x: 33
|
||||
y: 24
|
||||
color: "#808080"
|
||||
text: control.text
|
||||
elide: Text.ElideRight
|
||||
@@ -44,6 +46,8 @@ T.Button {
|
||||
|
||||
Rectangle {
|
||||
id: buttonPressed
|
||||
x: 123
|
||||
y: 62
|
||||
width: 100
|
||||
height: 60
|
||||
color: "#69b5ec"
|
||||
@@ -53,8 +57,8 @@ T.Button {
|
||||
anchors.fill: parent
|
||||
Text {
|
||||
id: pressedText
|
||||
x: 20
|
||||
y: 40
|
||||
x: 31
|
||||
y: 24
|
||||
color: "#000000"
|
||||
text: control.text
|
||||
elide: Text.ElideRight
|
||||
|
@@ -0,0 +1,105 @@
|
||||
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
|
||||
color: "#d4d4d4"
|
||||
x: 14
|
||||
y: 5
|
||||
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
|
||||
source: "assets/buttonNormal.png"
|
||||
|
||||
Text {
|
||||
id: normalText
|
||||
x: 58
|
||||
y: 50 //id only required to preserve binding
|
||||
text: control.text //binding has to be preserved
|
||||
//anchors.fill: parent
|
||||
color: "#BBBBBB"
|
||||
font.letterSpacing: 0.594
|
||||
font.pixelSize: 24
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: buttonPressed
|
||||
x: 290
|
||||
y: 5
|
||||
width: 100 //Bit of black magic to define the default size
|
||||
height: 40
|
||||
source: "assets/buttonPressed.png"
|
||||
|
||||
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
|
||||
x: 58
|
||||
y: 50
|
||||
text: control.text //binding has to be preserved
|
||||
//anchors.fill: parent
|
||||
color: "#E1E1E1"
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
68
tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.qml
Normal file
68
tests/auto/qml/qmldesigner/data/merging/ButtonStyle.ui.qml
Normal file
@@ -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"}
|
||||
}
|
||||
##^##*/
|
||||
|
Reference in New Issue
Block a user