1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Graphical Effects module.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0
import org.qtproject.pngdumper 1.0
Rectangle {
id: main
width: 300
height: width
property real size: width
property real timerInterval: 1
property color background: "white"
property bool checkerboard: false
color: background
Rectangle {
id: blurMask
anchors.fill: parent
visible: false
gradient: Gradient {
GradientStop { position: 0.3; color: "#ff000000" }
GradientStop { position: 0.7; color: "#00000000" }
}
}
Gradient {
id: firstGradient
GradientStop { position: 0.000; color: Qt.rgba(1, 0, 0, 1) }
GradientStop { position: 0.167; color: Qt.rgba(1, 1, 0, 1) }
GradientStop { position: 0.333; color: Qt.rgba(0, 1, 0, 1) }
GradientStop { position: 0.500; color: Qt.rgba(0, 1, 1, 1) }
GradientStop { position: 0.667; color: Qt.rgba(0, 0, 1, 1) }
GradientStop { position: 0.833; color: Qt.rgba(1, 0, 1, 1) }
GradientStop { position: 1.000; color: Qt.rgba(1, 0, 0, 1) }
}
Gradient {
id: secondGradient
GradientStop { position: 0.0; color: "#F0F0F0" }
GradientStop { position: 0.5; color: "#000000" }
GradientStop { position: 1.0; color: "#F0F0F0" }
}
Gradient {
id: thirdGradient
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: 1.0; color: "#FF000000" }
}
ItemModel {
id: itemModel
}
Item {
id: container
width: size
height: size
clip: true
Image {
source: '../../tests/manual/testbed/images/checker.png'
smooth: true
anchors.fill: parent
fillMode: Image.Tile
visible: main.checkerboard
}
ListView {
id: list
width: size
height: size
model: itemModel
highlightMoveDuration: 1
spacing: size
anchors.centerIn: parent
cacheBuffer: size
}
}
// Sources
Image {
id: bug
source: "../../tests/manual/testbed/images/bug.jpg"
smooth: true
width: size
height: width
fillMode: Image.PreserveAspectFit
visible: false
}
ShaderEffectSource {
id: butterfly
smooth: true
width: size
height: width
visible: false
sourceItem:
Image {
//id: butterfly
source: "../../tests/manual/testbed/images/butterfly.png"
smooth: true
width: size
height: width
fillMode: Image.PreserveAspectFit
visible: false
}
}
Image {
id: fog
source: "../../tests/manual/testbed/images/fog.png"
smooth: true
width: size
height: width
fillMode: Image.PreserveAspectFit
visible: false
}
Rectangle {
id: rect
width: size / 2
height: size / 2
anchors.centerIn: container
color: "#dde4ff"
visible: false
}
Rectangle {
id: displacementMapSource
visible: false
color: Qt.rgba(0.5, 0.5, 1.0, 1.0)
smooth: true
anchors.fill: bug
Image {
id: di
x: (parent.width - width) / 2
y: (parent.height - height) / 2
sourceSize: Qt.size(128, 128)
source: "../../tests/manual/testbed/images/glass_normal.png"
smooth: true
}
}
ItemCapturer {
id: capturer
}
Timer {
interval: 1000
running: true
onTriggered: {
// Ugly workaround for listview not updating itself
list.contentX = 1
eval("list.currentItem."+list.currentItem.__varyingProperty+"=list.currentItem.__values[0]");
list.contentX = 0
if (list.currentItem.init != undefined) list.currentItem.init()
timer.running = true
}
}
property int i: 0
Connections {
target: capturer
onImageSaved: {
if (i >= list.currentItem.__values.length - 1) {
var filename = list.currentItem.__name + "_" + list.currentItem.__varyingProperty + (i + 1) + ".png"
filename = filename.replace(/\"/g,"")
capturer.document("\\table\n")
capturer.document("\\header\n")
capturer.document("\\o Output examples with different " + list.currentItem.__varyingProperty + " values\n")
capturer.document("\\o\n\\o\n\\row\n")
var ii = 0
for(ii = 0; ii < list.currentItem.__values.length; ii++) {
filename = list.currentItem.__name + "_" + list.currentItem.__varyingProperty + (ii + 1) + ".png"
filename = filename.replace(/\"/g,"")
//filename = filename.toLowerCase();
capturer.document(" \\o \\image " + filename + "\n")
}
capturer.document("\\row\n")
for(ii = 0; ii < list.currentItem.__values.length; ii++) {
capturer.document(" \\o \\bold { " + list.currentItem.__varyingProperty + ": " + list.currentItem.__values[ii] + " }\n")
}
for (var p = 0; p < list.currentItem.__properties.length; p++) {
if (list.currentItem.__properties[p] == list.currentItem.__varyingProperty) continue;
capturer.document("\\row\n")
for(ii = 0; ii < list.currentItem.__values.length; ii++) {
capturer.document(" \\o \\l " + list.currentItem.__properties[p] + ": " + eval("list.currentItem."+list.currentItem.__properties[p]) + "\n")
}
}
capturer.document("\\endtable\n")
if (list.currentIndex < list.count-1) {
i = 0
if (list.currentItem.uninit != undefined) list.currentItem.uninit()
list.currentIndex++
list.positionViewAtIndex(list.currentIndex, ListView.Center)
if (list.currentItem.init != undefined) list.currentItem.init()
} else Qt.quit()
} else i++
eval("list.currentItem."+list.currentItem.__varyingProperty+"=list.currentItem.__values[i]");
timer.running = true
}
}
Timer {
id: timer
interval: timerInterval
running: false
onTriggered: {
var filename = list.currentItem.__name + "_" + list.currentItem.__varyingProperty + (i + 1) + ".png"
filename = filename.replace(/\"/g,"")
capturer.grabItem(container, filename)
}
}
}
|