Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/tools/qmlscene/main.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the tools applications of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | - | ||||||||||||
21 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
22 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** $QT_END_LICENSE$ | - | ||||||||||||
26 | ** | - | ||||||||||||
27 | ****************************************************************************/ | - | ||||||||||||
28 | - | |||||||||||||
29 | #include <QtCore/qabstractanimation.h> | - | ||||||||||||
30 | #include <QtCore/qdir.h> | - | ||||||||||||
31 | #include <QtCore/qmath.h> | - | ||||||||||||
32 | #include <QtCore/qdatetime.h> | - | ||||||||||||
33 | #include <QtCore/qpointer.h> | - | ||||||||||||
34 | #include <QtCore/qscopedpointer.h> | - | ||||||||||||
35 | #include <QtCore/qtextstream.h> | - | ||||||||||||
36 | #include <QtCore/qregularexpression.h> | - | ||||||||||||
37 | - | |||||||||||||
38 | #include <QtGui/QGuiApplication> | - | ||||||||||||
39 | #include <QtGui/QOpenGLFunctions> | - | ||||||||||||
40 | - | |||||||||||||
41 | #include <QtQml/qqml.h> | - | ||||||||||||
42 | #include <QtQml/qqmlengine.h> | - | ||||||||||||
43 | #include <QtQml/qqmlcomponent.h> | - | ||||||||||||
44 | #include <QtQml/qqmlcontext.h> | - | ||||||||||||
45 | - | |||||||||||||
46 | #include <QtQuick/qquickitem.h> | - | ||||||||||||
47 | #include <QtQuick/qquickview.h> | - | ||||||||||||
48 | - | |||||||||||||
49 | #include <private/qabstractanimation_p.h> | - | ||||||||||||
50 | #include <private/qopenglcontext_p.h> | - | ||||||||||||
51 | - | |||||||||||||
52 | #ifdef QT_WIDGETS_LIB | - | ||||||||||||
53 | #include <QtWidgets/QApplication> | - | ||||||||||||
54 | #include <QtWidgets/QFileDialog> | - | ||||||||||||
55 | #endif | - | ||||||||||||
56 | - | |||||||||||||
57 | #include <QtCore/QTranslator> | - | ||||||||||||
58 | #include <QtCore/QLibraryInfo> | - | ||||||||||||
59 | - | |||||||||||||
60 | #ifdef QML_RUNTIME_TESTING | - | ||||||||||||
61 | class RenderStatistics | - | ||||||||||||
62 | { | - | ||||||||||||
63 | public: | - | ||||||||||||
64 | static void updateStats(); | - | ||||||||||||
65 | static void printTotalStats(); | - | ||||||||||||
66 | private: | - | ||||||||||||
67 | static QVector<qreal> timePerFrame; | - | ||||||||||||
68 | static QVector<int> timesPerFrames; | - | ||||||||||||
69 | }; | - | ||||||||||||
70 | - | |||||||||||||
71 | QVector<qreal> RenderStatistics::timePerFrame; | - | ||||||||||||
72 | QVector<int> RenderStatistics::timesPerFrames; | - | ||||||||||||
73 | - | |||||||||||||
74 | void RenderStatistics::updateStats() | - | ||||||||||||
75 | { | - | ||||||||||||
76 | static QTime time; | - | ||||||||||||
77 | static int frames; | - | ||||||||||||
78 | static int lastTime; | - | ||||||||||||
79 | - | |||||||||||||
80 | if (frames == 0) {
| 0 | ||||||||||||
81 | time.start(); | - | ||||||||||||
82 | } else { never executed: end of block | 0 | ||||||||||||
83 | int elapsed = time.elapsed(); | - | ||||||||||||
84 | timesPerFrames.append(elapsed - lastTime); | - | ||||||||||||
85 | lastTime = elapsed; | - | ||||||||||||
86 | - | |||||||||||||
87 | if (elapsed > 5000) {
| 0 | ||||||||||||
88 | qreal avgtime = elapsed / (qreal) frames; | - | ||||||||||||
89 | qreal var = 0; | - | ||||||||||||
90 | for (int i = 0; i < timesPerFrames.size(); ++i) {
| 0 | ||||||||||||
91 | qreal diff = timesPerFrames.at(i) - avgtime; | - | ||||||||||||
92 | var += diff * diff; | - | ||||||||||||
93 | } never executed: end of block | 0 | ||||||||||||
94 | var /= timesPerFrames.size(); | - | ||||||||||||
95 | - | |||||||||||||
96 | printf("Average time per frame: %f ms (%i fps), std.dev: %f ms\n", avgtime, qRound(1000. / avgtime), qSqrt(var)); | - | ||||||||||||
97 | - | |||||||||||||
98 | timePerFrame.append(avgtime); | - | ||||||||||||
99 | timesPerFrames.clear(); | - | ||||||||||||
100 | time.start(); | - | ||||||||||||
101 | lastTime = 0; | - | ||||||||||||
102 | frames = 0; | - | ||||||||||||
103 | } never executed: end of block | 0 | ||||||||||||
104 | } never executed: end of block | 0 | ||||||||||||
105 | ++frames; | - | ||||||||||||
106 | } never executed: end of block | 0 | ||||||||||||
107 | - | |||||||||||||
108 | void RenderStatistics::printTotalStats() | - | ||||||||||||
109 | { | - | ||||||||||||
110 | int count = timePerFrame.count(); | - | ||||||||||||
111 | if (count == 0)
| 0-14 | ||||||||||||
112 | return; executed 14 times by 2 tests: return; Executed by:
| 14 | ||||||||||||
113 | - | |||||||||||||
114 | qreal minTime = 0; | - | ||||||||||||
115 | qreal maxTime = 0; | - | ||||||||||||
116 | qreal avg = 0; | - | ||||||||||||
117 | for (int i = 0; i < count; ++i) {
| 0 | ||||||||||||
118 | minTime = minTime == 0 ? timePerFrame.at(i) : qMin(minTime, timePerFrame.at(i));
| 0 | ||||||||||||
119 | maxTime = qMax(maxTime, timePerFrame.at(i)); | - | ||||||||||||
120 | avg += timePerFrame.at(i); | - | ||||||||||||
121 | } never executed: end of block | 0 | ||||||||||||
122 | avg /= count; | - | ||||||||||||
123 | - | |||||||||||||
124 | puts(" "); | - | ||||||||||||
125 | puts("----- Statistics -----"); | - | ||||||||||||
126 | printf("Average time per frame: %f ms (%i fps)\n", avg, qRound(1000. / avg)); | - | ||||||||||||
127 | printf("Best time per frame: %f ms (%i fps)\n", minTime, int(1000 / minTime)); | - | ||||||||||||
128 | printf("Worst time per frame: %f ms (%i fps)\n", maxTime, int(1000 / maxTime)); | - | ||||||||||||
129 | puts("----------------------"); | - | ||||||||||||
130 | puts(" "); | - | ||||||||||||
131 | } never executed: end of block | 0 | ||||||||||||
132 | #endif | - | ||||||||||||
133 | - | |||||||||||||
134 | struct Options | - | ||||||||||||
135 | { | - | ||||||||||||
136 | enum QmlApplicationType | - | ||||||||||||
137 | { | - | ||||||||||||
138 | QmlApplicationTypeGui, | - | ||||||||||||
139 | QmlApplicationTypeWidget, | - | ||||||||||||
140 | #ifdef QT_WIDGETS_LIB | - | ||||||||||||
141 | DefaultQmlApplicationType = QmlApplicationTypeWidget | - | ||||||||||||
142 | #else | - | ||||||||||||
143 | DefaultQmlApplicationType = QmlApplicationTypeGui | - | ||||||||||||
144 | #endif | - | ||||||||||||
145 | }; | - | ||||||||||||
146 | - | |||||||||||||
147 | Options() | - | ||||||||||||
148 | : textRenderType(QQuickWindow::textRenderType()) | - | ||||||||||||
149 | { | - | ||||||||||||
150 | // QtWebEngine needs a shared context in order for the GPU thread to | - | ||||||||||||
151 | // upload textures. | - | ||||||||||||
152 | applicationAttributes.append(Qt::AA_ShareOpenGLContexts); | - | ||||||||||||
153 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
154 | - | |||||||||||||
155 | QUrl url; | - | ||||||||||||
156 | bool originalQml = false; | - | ||||||||||||
157 | bool originalQmlRaster = false; | - | ||||||||||||
158 | bool maximized = false; | - | ||||||||||||
159 | bool fullscreen = false; | - | ||||||||||||
160 | bool transparent = false; | - | ||||||||||||
161 | bool clip = false; | - | ||||||||||||
162 | bool versionDetection = true; | - | ||||||||||||
163 | bool slowAnimations = false; | - | ||||||||||||
164 | bool quitImmediately = false; | - | ||||||||||||
165 | bool resizeViewToRootItem = false; | - | ||||||||||||
166 | bool multisample = false; | - | ||||||||||||
167 | bool coreProfile = false; | - | ||||||||||||
168 | bool verbose = false; | - | ||||||||||||
169 | QVector<Qt::ApplicationAttribute> applicationAttributes; | - | ||||||||||||
170 | QString translationFile; | - | ||||||||||||
171 | QmlApplicationType applicationType = DefaultQmlApplicationType; | - | ||||||||||||
172 | QQuickWindow::TextRenderType textRenderType; | - | ||||||||||||
173 | }; | - | ||||||||||||
174 | - | |||||||||||||
175 | #if defined(QMLSCENE_BUNDLE) | - | ||||||||||||
176 | QFileInfoList findQmlFiles(const QString &dirName) | - | ||||||||||||
177 | { | - | ||||||||||||
178 | QDir dir(dirName); | - | ||||||||||||
179 | - | |||||||||||||
180 | QFileInfoList ret; | - | ||||||||||||
181 | if (dir.exists()) { | - | ||||||||||||
182 | const QFileInfoList fileInfos = dir.entryInfoList(QStringList() << "*.qml", | - | ||||||||||||
183 | QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot); | - | ||||||||||||
184 | - | |||||||||||||
185 | for (const QFileInfo &fileInfo : fileInfos) { | - | ||||||||||||
186 | if (fileInfo.isDir()) | - | ||||||||||||
187 | ret += findQmlFiles(fileInfo.filePath()); | - | ||||||||||||
188 | else if (fileInfo.fileName().length() > 0 && fileInfo.fileName().at(0).isLower()) | - | ||||||||||||
189 | ret.append(fileInfo); | - | ||||||||||||
190 | } | - | ||||||||||||
191 | } | - | ||||||||||||
192 | - | |||||||||||||
193 | return ret; | - | ||||||||||||
194 | } | - | ||||||||||||
195 | - | |||||||||||||
196 | static int displayOptionsDialog(Options *options) | - | ||||||||||||
197 | { | - | ||||||||||||
198 | QDialog dialog; | - | ||||||||||||
199 | - | |||||||||||||
200 | QFormLayout *layout = new QFormLayout(&dialog); | - | ||||||||||||
201 | - | |||||||||||||
202 | QComboBox *qmlFileComboBox = new QComboBox(&dialog); | - | ||||||||||||
203 | const QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources"); | - | ||||||||||||
204 | - | |||||||||||||
205 | for (const QFileInfo &fileInfo : fileInfos) | - | ||||||||||||
206 | qmlFileComboBox->addItem(fileInfo.dir().dirName() + QLatin1Char('/') + fileInfo.fileName(), QVariant::fromValue(fileInfo)); | - | ||||||||||||
207 | - | |||||||||||||
208 | QCheckBox *originalCheckBox = new QCheckBox(&dialog); | - | ||||||||||||
209 | originalCheckBox->setText("Use original QML viewer"); | - | ||||||||||||
210 | originalCheckBox->setChecked(options->originalQml); | - | ||||||||||||
211 | - | |||||||||||||
212 | QCheckBox *fullscreenCheckBox = new QCheckBox(&dialog); | - | ||||||||||||
213 | fullscreenCheckBox->setText("Start fullscreen"); | - | ||||||||||||
214 | fullscreenCheckBox->setChecked(options->fullscreen); | - | ||||||||||||
215 | - | |||||||||||||
216 | QCheckBox *maximizedCheckBox = new QCheckBox(&dialog); | - | ||||||||||||
217 | maximizedCheckBox->setText("Start maximized"); | - | ||||||||||||
218 | maximizedCheckBox->setChecked(options->maximized); | - | ||||||||||||
219 | - | |||||||||||||
220 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, | - | ||||||||||||
221 | Qt::Horizontal, | - | ||||||||||||
222 | &dialog); | - | ||||||||||||
223 | QObject::connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); | - | ||||||||||||
224 | QObject::connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); | - | ||||||||||||
225 | - | |||||||||||||
226 | layout->addRow("Qml file:", qmlFileComboBox); | - | ||||||||||||
227 | layout->addWidget(originalCheckBox); | - | ||||||||||||
228 | layout->addWidget(maximizedCheckBox); | - | ||||||||||||
229 | layout->addWidget(fullscreenCheckBox); | - | ||||||||||||
230 | layout->addWidget(buttonBox); | - | ||||||||||||
231 | - | |||||||||||||
232 | int result = dialog.exec(); | - | ||||||||||||
233 | if (result == QDialog::Accepted) { | - | ||||||||||||
234 | QVariant variant = qmlFileComboBox->itemData(qmlFileComboBox->currentIndex()); | - | ||||||||||||
235 | QFileInfo fileInfo = variant.value<QFileInfo>(); | - | ||||||||||||
236 | - | |||||||||||||
237 | if (fileInfo.canonicalFilePath().startsWith(QLatin1Char(':'))) | - | ||||||||||||
238 | options->file = QUrl("qrc" + fileInfo.canonicalFilePath()); | - | ||||||||||||
239 | else | - | ||||||||||||
240 | options->file = QUrl::fromLocalFile(fileInfo.canonicalFilePath()); | - | ||||||||||||
241 | options->originalQml = originalCheckBox->isChecked(); | - | ||||||||||||
242 | options->maximized = maximizedCheckBox->isChecked(); | - | ||||||||||||
243 | options->fullscreen = fullscreenCheckBox->isChecked(); | - | ||||||||||||
244 | } | - | ||||||||||||
245 | return result; | - | ||||||||||||
246 | } | - | ||||||||||||
247 | #endif | - | ||||||||||||
248 | - | |||||||||||||
249 | static bool checkVersion(const QUrl &url) | - | ||||||||||||
250 | { | - | ||||||||||||
251 | if (!qgetenv("QMLSCENE_IMPORT_NAME").isEmpty())
| 0-14 | ||||||||||||
252 | fprintf(stderr, "QMLSCENE_IMPORT_NAME is no longer supported.\n"); never executed: fprintf( stderr , "QMLSCENE_IMPORT_NAME is no longer supported.\n"); | 0 | ||||||||||||
253 | - | |||||||||||||
254 | if (!url.isLocalFile())
| 0-14 | ||||||||||||
255 | return true; never executed: return true; | 0 | ||||||||||||
256 | - | |||||||||||||
257 | const QString fileName = url.toLocalFile(); | - | ||||||||||||
258 | QFile f(fileName); | - | ||||||||||||
259 | if (!f.open(QFile::ReadOnly | QFile::Text)) {
| 0-14 | ||||||||||||
260 | fprintf(stderr, "qmlscene: failed to check version of file '%s', could not open...\n", | - | ||||||||||||
261 | qPrintable(fileName)); | - | ||||||||||||
262 | return false; never executed: return false; | 0 | ||||||||||||
263 | } | - | ||||||||||||
264 | - | |||||||||||||
265 | QRegularExpression quick1("^\\s*import +QtQuick +1\\.\\w*"); | - | ||||||||||||
266 | QRegularExpression qt47("^\\s*import +Qt +4\\.7"); | - | ||||||||||||
267 | - | |||||||||||||
268 | QTextStream stream(&f); | - | ||||||||||||
269 | bool codeFound= false; | - | ||||||||||||
270 | while (!codeFound) {
| 14-282 | ||||||||||||
271 | QString line = stream.readLine(); | - | ||||||||||||
272 | if (line.contains(QLatin1Char('{'))) {
| 14-268 | ||||||||||||
273 | codeFound = true; | - | ||||||||||||
274 | } else { executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
275 | QString import; | - | ||||||||||||
276 | QRegularExpressionMatch match = quick1.match(line); | - | ||||||||||||
277 | if (match.hasMatch())
| 0-268 | ||||||||||||
278 | import = match.captured(0).trimmed(); never executed: import = match.captured(0).trimmed(); | 0 | ||||||||||||
279 | else if ((match = qt47.match(line)).hasMatch())
| 0-268 | ||||||||||||
280 | import = match.captured(0).trimmed(); never executed: import = match.captured(0).trimmed(); | 0 | ||||||||||||
281 | - | |||||||||||||
282 | if (!import.isNull()) {
| 0-268 | ||||||||||||
283 | fprintf(stderr, "qmlscene: '%s' is no longer supported.\n" | - | ||||||||||||
284 | "Use qmlviewer to load file '%s'.\n", | - | ||||||||||||
285 | qPrintable(import), | - | ||||||||||||
286 | qPrintable(fileName)); | - | ||||||||||||
287 | return false; never executed: return false; | 0 | ||||||||||||
288 | } | - | ||||||||||||
289 | } executed 268 times by 2 tests: end of block Executed by:
| 268 | ||||||||||||
290 | } | - | ||||||||||||
291 | - | |||||||||||||
292 | return true; executed 14 times by 2 tests: return true; Executed by:
| 14 | ||||||||||||
293 | } | - | ||||||||||||
294 | - | |||||||||||||
295 | static void displayFileDialog(Options *options) | - | ||||||||||||
296 | { | - | ||||||||||||
297 | #if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) | - | ||||||||||||
298 | if (options->applicationType == Options::QmlApplicationTypeWidget) {
| 0 | ||||||||||||
299 | QString fileName = QFileDialog::getOpenFileName(nullptr, "Open QML file", QString(), "QML Files (*.qml)"); | - | ||||||||||||
300 | if (!fileName.isEmpty()) {
| 0 | ||||||||||||
301 | QFileInfo fi(fileName); | - | ||||||||||||
302 | options->url = QUrl::fromLocalFile(fi.canonicalFilePath()); | - | ||||||||||||
303 | } never executed: end of block | 0 | ||||||||||||
304 | return; never executed: return; | 0 | ||||||||||||
305 | } | - | ||||||||||||
306 | #endif // QT_WIDGETS_LIB && QT_CONFIG(filedialog) | - | ||||||||||||
307 | Q_UNUSED(options); | - | ||||||||||||
308 | puts("No filename specified..."); | - | ||||||||||||
309 | } never executed: end of block | 0 | ||||||||||||
310 | - | |||||||||||||
311 | #if QT_CONFIG(translation) | - | ||||||||||||
312 | static void loadTranslationFile(QTranslator &translator, const QString& directory) | - | ||||||||||||
313 | { | - | ||||||||||||
314 | translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); | - | ||||||||||||
315 | QCoreApplication::installTranslator(&translator); | - | ||||||||||||
316 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
317 | #endif | - | ||||||||||||
318 | - | |||||||||||||
319 | static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) | - | ||||||||||||
320 | { | - | ||||||||||||
321 | QDir dir(directory+"/dummydata", "*.qml"); | - | ||||||||||||
322 | QStringList list = dir.entryList(); | - | ||||||||||||
323 | for (int i = 0; i < list.size(); ++i) {
| 0-14 | ||||||||||||
324 | QString qml = list.at(i); | - | ||||||||||||
325 | QQmlComponent comp(&engine, dir.filePath(qml)); | - | ||||||||||||
326 | QObject *dummyData = comp.create(); | - | ||||||||||||
327 | - | |||||||||||||
328 | if(comp.isError()) {
| 0 | ||||||||||||
329 | const QList<QQmlError> errors = comp.errors(); | - | ||||||||||||
330 | for (const QQmlError &error : errors) | - | ||||||||||||
331 | fprintf(stderr, "%s\n", qPrintable(error.toString())); never executed: fprintf( stderr , "%s\n", QtPrivate::asString(error.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||
332 | } never executed: end of block | 0 | ||||||||||||
333 | - | |||||||||||||
334 | if (dummyData) {
| 0 | ||||||||||||
335 | fprintf(stderr, "Loaded dummy data: %s\n", qPrintable(dir.filePath(qml))); | - | ||||||||||||
336 | qml.truncate(qml.length()-4); | - | ||||||||||||
337 | engine.rootContext()->setContextProperty(qml, dummyData); | - | ||||||||||||
338 | dummyData->setParent(&engine); | - | ||||||||||||
339 | } never executed: end of block | 0 | ||||||||||||
340 | } never executed: end of block | 0 | ||||||||||||
341 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
342 | - | |||||||||||||
343 | static void usage() | - | ||||||||||||
344 | { | - | ||||||||||||
345 | puts("Usage: qmlscene [options] <filename>"); | - | ||||||||||||
346 | puts(" "); | - | ||||||||||||
347 | puts(" Options:"); | - | ||||||||||||
348 | puts(" --maximized ...................... Run maximized"); | - | ||||||||||||
349 | puts(" --fullscreen ..................... Run fullscreen"); | - | ||||||||||||
350 | puts(" --transparent .................... Make the window transparent"); | - | ||||||||||||
351 | puts(" --multisample .................... Enable multisampling (OpenGL anti-aliasing)"); | - | ||||||||||||
352 | puts(" --core-profile ................... Request a core profile OpenGL context"); | - | ||||||||||||
353 | puts(" --no-version-detection ........... Do not try to detect the version of the .qml file"); | - | ||||||||||||
354 | puts(" --slow-animations ................ Run all animations in slow motion"); | - | ||||||||||||
355 | puts(" --resize-to-root ................. Resize the window to the size of the root item"); | - | ||||||||||||
356 | puts(" --quit ........................... Quit immediately after starting"); | - | ||||||||||||
357 | puts(" --disable-context-sharing ........ Disable the use of a shared GL context for QtQuick Windows\n" | - | ||||||||||||
358 | " .........(remove AA_ShareOpenGLContexts)"); | - | ||||||||||||
359 | puts(" --desktop..........................Force use of desktop GL (AA_UseDesktopOpenGL)"); | - | ||||||||||||
360 | puts(" --gles.............................Force use of GLES (AA_UseOpenGLES)"); | - | ||||||||||||
361 | puts(" --software.........................Force use of software rendering (AA_UseOpenGLES)"); | - | ||||||||||||
362 | puts(" --scaling..........................Enable High DPI scaling (AA_EnableHighDpiScaling)"); | - | ||||||||||||
363 | puts(" --no-scaling.......................Disable High DPI scaling (AA_DisableHighDpiScaling)"); | - | ||||||||||||
364 | puts(" --verbose..........................Print version and graphical diagnostics for the run-time"); | - | ||||||||||||
365 | #ifdef QT_WIDGETS_LIB | - | ||||||||||||
366 | puts(" --apptype [gui|widgets] ...........Select which application class to use. Default is widgets."); | - | ||||||||||||
367 | #endif | - | ||||||||||||
368 | puts(" --textrendertype [qt|native].......Select the default render type for text-like elements."); | - | ||||||||||||
369 | puts(" -I <path> ........................ Add <path> to the list of import paths"); | - | ||||||||||||
370 | puts(" -P <path> ........................ Add <path> to the list of plugin paths"); | - | ||||||||||||
371 | puts(" -translation <translationfile> ... Set the language to run in"); | - | ||||||||||||
372 | - | |||||||||||||
373 | puts(" "); | - | ||||||||||||
374 | exit(1); never executed: exit(1); | 0 | ||||||||||||
375 | } | - | ||||||||||||
376 | #if QT_CONFIG(opengl) | - | ||||||||||||
377 | // Listen on GL context creation of the QQuickWindow in order to print diagnostic output. | - | ||||||||||||
378 | class DiagnosticGlContextCreationListener : public QObject { | - | ||||||||||||
379 | Q_OBJECT | - | ||||||||||||
380 | public: | - | ||||||||||||
381 | explicit DiagnosticGlContextCreationListener(QQuickWindow *window) : QObject(window) | - | ||||||||||||
382 | { | - | ||||||||||||
383 | connect(window, &QQuickWindow::openglContextCreated, | - | ||||||||||||
384 | this, &DiagnosticGlContextCreationListener::onOpenGlContextCreated); | - | ||||||||||||
385 | } never executed: end of block | 0 | ||||||||||||
386 | - | |||||||||||||
387 | private slots: | - | ||||||||||||
388 | void onOpenGlContextCreated(QOpenGLContext *context) | - | ||||||||||||
389 | { | - | ||||||||||||
390 | context->makeCurrent(qobject_cast<QQuickWindow *>(parent())); | - | ||||||||||||
391 | QOpenGLFunctions functions(context); | - | ||||||||||||
392 | QByteArray output = "Vendor : "; | - | ||||||||||||
393 | output += reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR)); | - | ||||||||||||
394 | output += "\nRenderer: "; | - | ||||||||||||
395 | output += reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER)); | - | ||||||||||||
396 | output += "\nVersion : "; | - | ||||||||||||
397 | output += reinterpret_cast<const char *>(functions.glGetString(GL_VERSION)); | - | ||||||||||||
398 | output += "\nLanguage: "; | - | ||||||||||||
399 | output += reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)); | - | ||||||||||||
400 | puts(output.constData()); | - | ||||||||||||
401 | context->doneCurrent(); | - | ||||||||||||
402 | deleteLater(); | - | ||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||
404 | - | |||||||||||||
405 | }; | - | ||||||||||||
406 | #endif | - | ||||||||||||
407 | - | |||||||||||||
408 | static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *window) | - | ||||||||||||
409 | { | - | ||||||||||||
410 | const QString oldTitle = window->title(); | - | ||||||||||||
411 | QString newTitle = oldTitle; | - | ||||||||||||
412 | if (newTitle.isEmpty()) {
| 0-8 | ||||||||||||
413 | newTitle = QLatin1String("qmlscene"); | - | ||||||||||||
414 | if (!qobject_cast<const QWindow *>(topLevel) && !topLevel->objectName().isEmpty())
| 0-8 | ||||||||||||
415 | newTitle += QLatin1String(": ") + topLevel->objectName(); never executed: newTitle += QLatin1String(": ") + topLevel->objectName(); | 0 | ||||||||||||
416 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
417 | if (verbose) {
| 0-8 | ||||||||||||
418 | newTitle += QLatin1String(" [Qt ") + QLatin1String(QT_VERSION_STR) + QLatin1Char(' ') | - | ||||||||||||
419 | + QGuiApplication::platformName() + QLatin1Char(' '); | - | ||||||||||||
420 | #if QT_CONFIG(opengl) | - | ||||||||||||
421 | newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
| 0 | ||||||||||||
422 | ? QLatin1String("GL") : QLatin1String("GLES"); | - | ||||||||||||
423 | #endif | - | ||||||||||||
424 | newTitle += QLatin1Char(']'); | - | ||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||
426 | if (oldTitle != newTitle)
| 0-8 | ||||||||||||
427 | window->setTitle(newTitle); executed 8 times by 1 test: window->setTitle(newTitle); Executed by:
| 8 | ||||||||||||
428 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
429 | - | |||||||||||||
430 | static QUrl parseUrlArgument(const QString &arg) | - | ||||||||||||
431 | { | - | ||||||||||||
432 | const QUrl url = QUrl::fromUserInput(arg, QDir::currentPath(), QUrl::AssumeLocalFile); | - | ||||||||||||
433 | if (!url.isValid()) {
| 0-14 | ||||||||||||
434 | fprintf(stderr, "Invalid URL: \"%s\"\n", qPrintable(arg)); | - | ||||||||||||
435 | return QUrl(); never executed: return QUrl(); | 0 | ||||||||||||
436 | } | - | ||||||||||||
437 | if (url.isLocalFile()) {
| 0-14 | ||||||||||||
438 | const QFileInfo fi(url.toLocalFile()); | - | ||||||||||||
439 | if (!fi.exists()) {
| 0-14 | ||||||||||||
440 | fprintf(stderr, "\"%s\" does not exist.\n", | - | ||||||||||||
441 | qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath()))); | - | ||||||||||||
442 | return QUrl(); never executed: return QUrl(); | 0 | ||||||||||||
443 | } | - | ||||||||||||
444 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
445 | return url; executed 14 times by 2 tests: return url; Executed by:
| 14 | ||||||||||||
446 | } | - | ||||||||||||
447 | - | |||||||||||||
448 | static QQuickWindow::TextRenderType parseTextRenderType(const QString &renderType) | - | ||||||||||||
449 | { | - | ||||||||||||
450 | if (renderType == QLatin1String("qt"))
| 0 | ||||||||||||
451 | return QQuickWindow::QtTextRendering; never executed: return QQuickWindow::QtTextRendering; | 0 | ||||||||||||
452 | else if (renderType == QLatin1String("native"))
| 0 | ||||||||||||
453 | return QQuickWindow::NativeTextRendering; never executed: return QQuickWindow::NativeTextRendering; | 0 | ||||||||||||
454 | - | |||||||||||||
455 | usage(); | - | ||||||||||||
456 | - | |||||||||||||
457 | Q_UNREACHABLE(); | - | ||||||||||||
458 | return QQuickWindow::QtTextRendering; never executed: return QQuickWindow::QtTextRendering; | 0 | ||||||||||||
459 | } | - | ||||||||||||
460 | - | |||||||||||||
461 | int main(int argc, char ** argv) | - | ||||||||||||
462 | { | - | ||||||||||||
463 | Options options; | - | ||||||||||||
464 | - | |||||||||||||
465 | QStringList imports; | - | ||||||||||||
466 | QStringList pluginPaths; | - | ||||||||||||
467 | - | |||||||||||||
468 | // Parse arguments for application attributes to be applied before Q[Gui]Application creation. | - | ||||||||||||
469 | for (int i = 1; i < argc; ++i) {
| 14-28 | ||||||||||||
470 | const char *arg = argv[i]; | - | ||||||||||||
471 | if (!qstrcmp(arg, "--disable-context-sharing")) {
| 0-28 | ||||||||||||
472 | options.applicationAttributes.removeAll(Qt::AA_ShareOpenGLContexts); | - | ||||||||||||
473 | } else if (!qstrcmp(arg, "--gles")) { never executed: end of block
| 0-28 | ||||||||||||
474 | options.applicationAttributes.append(Qt::AA_UseOpenGLES); | - | ||||||||||||
475 | } else if (!qstrcmp(arg, "--software")) { never executed: end of block
| 0-28 | ||||||||||||
476 | options.applicationAttributes.append(Qt::AA_UseSoftwareOpenGL); | - | ||||||||||||
477 | } else if (!qstrcmp(arg, "--desktop")) { never executed: end of block
| 0-28 | ||||||||||||
478 | options.applicationAttributes.append(Qt::AA_UseDesktopOpenGL); | - | ||||||||||||
479 | } else if (!qstrcmp(arg, "--scaling")) { never executed: end of block
| 0-28 | ||||||||||||
480 | options.applicationAttributes.append(Qt::AA_EnableHighDpiScaling); | - | ||||||||||||
481 | } else if (!qstrcmp(arg, "--no-scaling")) { never executed: end of block
| 0-28 | ||||||||||||
482 | options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling); | - | ||||||||||||
483 | } else if (!qstrcmp(arg, "--apptype")) { never executed: end of block
| 0-28 | ||||||||||||
484 | if (++i >= argc)
| 0 | ||||||||||||
485 | usage(); never executed: usage(); | 0 | ||||||||||||
486 | if (!qstrcmp(argv[i], "gui"))
| 0 | ||||||||||||
487 | options.applicationType = Options::QmlApplicationTypeGui; never executed: options.applicationType = Options::QmlApplicationTypeGui; | 0 | ||||||||||||
488 | } never executed: end of block | 0 | ||||||||||||
489 | } executed 28 times by 2 tests: end of block Executed by:
| 28 | ||||||||||||
490 | - | |||||||||||||
491 | for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes)) | - | ||||||||||||
492 | QCoreApplication::setAttribute(a); executed 14 times by 2 tests: QCoreApplication::setAttribute(a); Executed by:
| 14 | ||||||||||||
493 | QScopedPointer<QGuiApplication> app; | - | ||||||||||||
494 | #ifdef QT_WIDGETS_LIB | - | ||||||||||||
495 | if (options.applicationType == Options::QmlApplicationTypeWidget)
| 0-14 | ||||||||||||
496 | app.reset(new QApplication(argc, argv)); executed 14 times by 2 tests: app.reset(new QApplication(argc, argv)); Executed by:
| 14 | ||||||||||||
497 | #endif | - | ||||||||||||
498 | if (app.isNull())
| 0-14 | ||||||||||||
499 | app.reset(new QGuiApplication(argc, argv)); never executed: app.reset(new QGuiApplication(argc, argv)); | 0 | ||||||||||||
500 | QCoreApplication::setApplicationName(QStringLiteral("QtQmlViewer")); executed 14 times by 2 tests: return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
501 | QCoreApplication::setOrganizationName(QStringLiteral("QtProject")); executed 14 times by 2 tests: return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
502 | QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org")); executed 14 times by 2 tests: return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
503 | QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); | - | ||||||||||||
504 | - | |||||||||||||
505 | const QStringList arguments = QCoreApplication::arguments(); | - | ||||||||||||
506 | for (int i = 1, size = arguments.size(); i < size; ++i) {
| 14 | ||||||||||||
507 | if (!arguments.at(i).startsWith(QLatin1Char('-'))) {
| 0-14 | ||||||||||||
508 | options.url = parseUrlArgument(arguments.at(i)); | - | ||||||||||||
509 | } else { executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
510 | const QString lowerArgument = arguments.at(i).toLower(); | - | ||||||||||||
511 | if (lowerArgument == QLatin1String("--maximized"))
| 0 | ||||||||||||
512 | options.maximized = true; never executed: options.maximized = true; | 0 | ||||||||||||
513 | else if (lowerArgument == QLatin1String("--fullscreen"))
| 0 | ||||||||||||
514 | options.fullscreen = true; never executed: options.fullscreen = true; | 0 | ||||||||||||
515 | else if (lowerArgument == QLatin1String("--transparent"))
| 0 | ||||||||||||
516 | options.transparent = true; never executed: options.transparent = true; | 0 | ||||||||||||
517 | else if (lowerArgument == QLatin1String("--clip"))
| 0 | ||||||||||||
518 | options.clip = true; never executed: options.clip = true; | 0 | ||||||||||||
519 | else if (lowerArgument == QLatin1String("--no-version-detection"))
| 0 | ||||||||||||
520 | options.versionDetection = false; never executed: options.versionDetection = false; | 0 | ||||||||||||
521 | else if (lowerArgument == QLatin1String("--slow-animations"))
| 0 | ||||||||||||
522 | options.slowAnimations = true; never executed: options.slowAnimations = true; | 0 | ||||||||||||
523 | else if (lowerArgument == QLatin1String("--quit"))
| 0 | ||||||||||||
524 | options.quitImmediately = true; never executed: options.quitImmediately = true; | 0 | ||||||||||||
525 | else if (lowerArgument == QLatin1String("-translation"))
| 0 | ||||||||||||
526 | options.translationFile = QLatin1String(argv[++i]); never executed: options.translationFile = QLatin1String(argv[++i]); | 0 | ||||||||||||
527 | else if (lowerArgument == QLatin1String("--resize-to-root"))
| 0 | ||||||||||||
528 | options.resizeViewToRootItem = true; never executed: options.resizeViewToRootItem = true; | 0 | ||||||||||||
529 | else if (lowerArgument == QLatin1String("--multisample"))
| 0 | ||||||||||||
530 | options.multisample = true; never executed: options.multisample = true; | 0 | ||||||||||||
531 | else if (lowerArgument == QLatin1String("--core-profile"))
| 0 | ||||||||||||
532 | options.coreProfile = true; never executed: options.coreProfile = true; | 0 | ||||||||||||
533 | else if (lowerArgument == QLatin1String("--verbose"))
| 0 | ||||||||||||
534 | options.verbose = true; never executed: options.verbose = true; | 0 | ||||||||||||
535 | else if (lowerArgument == QLatin1String("-i") && i + 1 < size)
| 0 | ||||||||||||
536 | imports.append(arguments.at(++i)); never executed: imports.append(arguments.at(++i)); | 0 | ||||||||||||
537 | else if (lowerArgument == QLatin1String("-p") && i + 1 < size)
| 0 | ||||||||||||
538 | pluginPaths.append(arguments.at(++i)); never executed: pluginPaths.append(arguments.at(++i)); | 0 | ||||||||||||
539 | else if (lowerArgument == QLatin1String("--apptype"))
| 0 | ||||||||||||
540 | ++i; // Consume previously parsed argument never executed: ++i; | 0 | ||||||||||||
541 | else if (lowerArgument == QLatin1String("--textrendertype") && i + 1 < size)
| 0 | ||||||||||||
542 | options.textRenderType = parseTextRenderType(arguments.at(++i)); never executed: options.textRenderType = parseTextRenderType(arguments.at(++i)); | 0 | ||||||||||||
543 | else if (lowerArgument == QLatin1String("--help")
| 0 | ||||||||||||
544 | || lowerArgument == QLatin1String("-help")
| 0 | ||||||||||||
545 | || lowerArgument == QLatin1String("--h")
| 0 | ||||||||||||
546 | || lowerArgument == QLatin1String("-h"))
| 0 | ||||||||||||
547 | usage(); never executed: usage(); | 0 | ||||||||||||
548 | } never executed: end of block | 0 | ||||||||||||
549 | } | - | ||||||||||||
550 | - | |||||||||||||
551 | #if QT_CONFIG(translation) | - | ||||||||||||
552 | QTranslator translator; | - | ||||||||||||
553 | QTranslator qtTranslator; | - | ||||||||||||
554 | QString sysLocale = QLocale::system().name(); | - | ||||||||||||
555 | if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
| 0-14 | ||||||||||||
556 | app->installTranslator(&qtTranslator); never executed: app->installTranslator(&qtTranslator); | 0 | ||||||||||||
557 | if (translator.load(QLatin1String("qmlscene_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
| 0-14 | ||||||||||||
558 | app->installTranslator(&translator); never executed: app->installTranslator(&translator); | 0 | ||||||||||||
559 | - | |||||||||||||
560 | QTranslator qmlTranslator; | - | ||||||||||||
561 | if (!options.translationFile.isEmpty()) {
| 0-14 | ||||||||||||
562 | if (qmlTranslator.load(options.translationFile)) {
| 0 | ||||||||||||
563 | app->installTranslator(&qmlTranslator); | - | ||||||||||||
564 | } else { never executed: end of block | 0 | ||||||||||||
565 | fprintf(stderr, "Could not load the translation file \"%s\"\n", | - | ||||||||||||
566 | qPrintable(options.translationFile)); | - | ||||||||||||
567 | } never executed: end of block | 0 | ||||||||||||
568 | } | - | ||||||||||||
569 | #endif | - | ||||||||||||
570 | - | |||||||||||||
571 | QQuickWindow::setTextRenderType(options.textRenderType); | - | ||||||||||||
572 | - | |||||||||||||
573 | QUnifiedTimer::instance()->setSlowModeEnabled(options.slowAnimations); | - | ||||||||||||
574 | - | |||||||||||||
575 | if (options.url.isEmpty())
| 0-14 | ||||||||||||
576 | #if defined(QMLSCENE_BUNDLE) | - | ||||||||||||
577 | displayOptionsDialog(&options); | - | ||||||||||||
578 | #else | - | ||||||||||||
579 | displayFileDialog(&options); never executed: displayFileDialog(&options); | 0 | ||||||||||||
580 | #endif | - | ||||||||||||
581 | - | |||||||||||||
582 | int exitCode = 0; | - | ||||||||||||
583 | - | |||||||||||||
584 | if (options.verbose)
| 0-14 | ||||||||||||
585 | puts(QLibraryInfo::build()); never executed: puts(QLibraryInfo::build()); | 0 | ||||||||||||
586 | - | |||||||||||||
587 | if (!options.url.isEmpty()) {
| 0-14 | ||||||||||||
588 | if (!options.versionDetection || checkVersion(options.url)) {
| 0-14 | ||||||||||||
589 | #if QT_CONFIG(translation) | - | ||||||||||||
590 | QTranslator translator; | - | ||||||||||||
591 | #endif | - | ||||||||||||
592 | - | |||||||||||||
593 | // TODO: as soon as the engine construction completes, the debug service is | - | ||||||||||||
594 | // listening for connections. But actually we aren't ready to debug anything. | - | ||||||||||||
595 | QQmlEngine engine; | - | ||||||||||||
596 | QPointer<QQmlComponent> component = new QQmlComponent(&engine); | - | ||||||||||||
597 | for (int i = 0; i < imports.size(); ++i)
| 0-14 | ||||||||||||
598 | engine.addImportPath(imports.at(i)); never executed: engine.addImportPath(imports.at(i)); | 0 | ||||||||||||
599 | for (int i = 0; i < pluginPaths.size(); ++i)
| 0-14 | ||||||||||||
600 | engine.addPluginPath(pluginPaths.at(i)); never executed: engine.addPluginPath(pluginPaths.at(i)); | 0 | ||||||||||||
601 | if (options.url.isLocalFile()) {
| 0-14 | ||||||||||||
602 | QFileInfo fi(options.url.toLocalFile()); | - | ||||||||||||
603 | #if QT_CONFIG(translation) | - | ||||||||||||
604 | loadTranslationFile(translator, fi.path()); | - | ||||||||||||
605 | #endif | - | ||||||||||||
606 | loadDummyDataFiles(engine, fi.path()); | - | ||||||||||||
607 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
608 | QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); | - | ||||||||||||
609 | QObject::connect(&engine, &QQmlEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); | - | ||||||||||||
610 | component->loadUrl(options.url); | - | ||||||||||||
611 | while (component->isLoading())
| 0-14 | ||||||||||||
612 | QCoreApplication::processEvents(); never executed: QCoreApplication::processEvents(); | 0 | ||||||||||||
613 | if ( !component->isReady() ) {
| 0-14 | ||||||||||||
614 | fprintf(stderr, "%s\n", qPrintable(component->errorString())); | - | ||||||||||||
615 | return -1; never executed: return -1; | 0 | ||||||||||||
616 | } | - | ||||||||||||
617 | - | |||||||||||||
618 | QObject *topLevel = component->create(); | - | ||||||||||||
619 | if (!topLevel && component->isError()) {
| 0-14 | ||||||||||||
620 | fprintf(stderr, "%s\n", qPrintable(component->errorString())); | - | ||||||||||||
621 | return -1; never executed: return -1; | 0 | ||||||||||||
622 | } | - | ||||||||||||
623 | QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(topLevel)); | - | ||||||||||||
624 | if (window) {
| 0-14 | ||||||||||||
625 | engine.setIncubationController(window->incubationController()); | - | ||||||||||||
626 | } else { never executed: end of block | 0 | ||||||||||||
627 | QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel); | - | ||||||||||||
628 | if (contentItem) {
| 6-8 | ||||||||||||
629 | QQuickView* qxView = new QQuickView(&engine, nullptr); | - | ||||||||||||
630 | window.reset(qxView); | - | ||||||||||||
631 | // Set window default properties; the qml can still override them | - | ||||||||||||
632 | if (options.resizeViewToRootItem)
| 0-8 | ||||||||||||
633 | qxView->setResizeMode(QQuickView::SizeViewToRootObject); never executed: qxView->setResizeMode(QQuickView::SizeViewToRootObject); | 0 | ||||||||||||
634 | else | - | ||||||||||||
635 | qxView->setResizeMode(QQuickView::SizeRootObjectToView); executed 8 times by 1 test: qxView->setResizeMode(QQuickView::SizeRootObjectToView); Executed by:
| 8 | ||||||||||||
636 | qxView->setContent(options.url, component, contentItem); | - | ||||||||||||
637 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
638 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
639 | - | |||||||||||||
640 | if (window) {
| 6-8 | ||||||||||||
641 | setWindowTitle(options.verbose, topLevel, window.data()); | - | ||||||||||||
642 | #if QT_CONFIG(opengl) | - | ||||||||||||
643 | if (options.verbose)
| 0-8 | ||||||||||||
644 | new DiagnosticGlContextCreationListener(window.data()); never executed: new DiagnosticGlContextCreationListener(window.data()); | 0 | ||||||||||||
645 | #endif | - | ||||||||||||
646 | QSurfaceFormat surfaceFormat = window->requestedFormat(); | - | ||||||||||||
647 | if (options.multisample)
| 0-8 | ||||||||||||
648 | surfaceFormat.setSamples(16); never executed: surfaceFormat.setSamples(16); | 0 | ||||||||||||
649 | if (options.transparent) {
| 0-8 | ||||||||||||
650 | surfaceFormat.setAlphaBufferSize(8); | - | ||||||||||||
651 | window->setClearBeforeRendering(true); | - | ||||||||||||
652 | window->setColor(QColor(Qt::transparent)); | - | ||||||||||||
653 | window->setFlags(Qt::FramelessWindowHint); | - | ||||||||||||
654 | } never executed: end of block | 0 | ||||||||||||
655 | if (options.coreProfile) {
| 0-8 | ||||||||||||
656 | surfaceFormat.setVersion(4, 1); | - | ||||||||||||
657 | surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); | - | ||||||||||||
658 | } never executed: end of block | 0 | ||||||||||||
659 | window->setFormat(surfaceFormat); | - | ||||||||||||
660 | - | |||||||||||||
661 | if (window->flags() == Qt::Window) // Fix window flags unless set by QML.
| 0-8 | ||||||||||||
662 | window->setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint); executed 8 times by 1 test: window->setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint); Executed by:
| 8 | ||||||||||||
663 | - | |||||||||||||
664 | if (options.fullscreen)
| 0-8 | ||||||||||||
665 | window->showFullScreen(); never executed: window->showFullScreen(); | 0 | ||||||||||||
666 | else if (options.maximized)
| 0-8 | ||||||||||||
667 | window->showMaximized(); never executed: window->showMaximized(); | 0 | ||||||||||||
668 | else if (!window->isVisible())
| 0-8 | ||||||||||||
669 | window->show(); executed 8 times by 1 test: window->show(); Executed by:
| 8 | ||||||||||||
670 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
671 | - | |||||||||||||
672 | if (options.quitImmediately)
| 0-14 | ||||||||||||
673 | QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); never executed: QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); | 0 | ||||||||||||
674 | - | |||||||||||||
675 | // Now would be a good time to inform the debug service to start listening. | - | ||||||||||||
676 | - | |||||||||||||
677 | exitCode = app->exec(); | - | ||||||||||||
678 | - | |||||||||||||
679 | #ifdef QML_RUNTIME_TESTING | - | ||||||||||||
680 | RenderStatistics::printTotalStats(); | - | ||||||||||||
681 | #endif | - | ||||||||||||
682 | // Ready to exit. Notice that the component might be owned by | - | ||||||||||||
683 | // QQuickView if one was created. That case is tracked by | - | ||||||||||||
684 | // QPointer, so it is safe to delete the component here. | - | ||||||||||||
685 | delete component; | - | ||||||||||||
686 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
687 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
688 | - | |||||||||||||
689 | return exitCode; executed 14 times by 2 tests: return exitCode; Executed by:
| 14 | ||||||||||||
690 | } | - | ||||||||||||
691 | - | |||||||||||||
692 | #include "main.moc" | - | ||||||||||||
Source code | Switch to Preprocessed file |