diff options
author | Daniel d'Andrada <daniel.dandrada@luxoft.com> | 2017-10-23 10:49:54 +0200 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@luxoft.com> | 2018-02-28 15:58:01 +0100 |
commit | e983cac6380de7c0d13e75a28129148bc51edc81 (patch) | |
tree | 45c8811e9597304b57c3a2e345b014cb0c8950de /tests | |
parent | 61c19cfd0d37be4d18064d2d50063bf25e2e1ace (diff) |
Use qmlscene code from 5.9 instead of 5.10
Diffstat (limited to 'tests')
-rw-r--r-- | tests/triton-qmlscene/triton-qmlscene.cpp | 116 |
1 files changed, 29 insertions, 87 deletions
diff --git a/tests/triton-qmlscene/triton-qmlscene.cpp b/tests/triton-qmlscene/triton-qmlscene.cpp index 33a10a8c..3ff74d3a 100644 --- a/tests/triton-qmlscene/triton-qmlscene.cpp +++ b/tests/triton-qmlscene/triton-qmlscene.cpp @@ -33,7 +33,7 @@ #include <QtCore/qpointer.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qtextstream.h> -#include <QtCore/qregularexpression.h> +#include <QtCore/qregexp.h> #include <QtGui/QGuiApplication> #include <QtGui/QOpenGLFunctions> @@ -137,17 +137,6 @@ void RenderStatistics::printTotalStats() struct Options { - enum QmlApplicationType - { - QmlApplicationTypeGui, - QmlApplicationTypeWidget, -#ifdef QT_WIDGETS_LIB - DefaultQmlApplicationType = QmlApplicationTypeWidget -#else - DefaultQmlApplicationType = QmlApplicationTypeGui -#endif - }; - Options() : originalQml(false) , originalQmlRaster(false) @@ -160,10 +149,7 @@ struct Options , quitImmediately(false) , resizeViewToRootItem(false) , multisample(false) - , coreProfile(false) , verbose(false) - , applicationType(DefaultQmlApplicationType) - , textRenderType(QQuickWindow::textRenderType()) { // QtWebEngine needs a shared context in order for the GPU thread to // upload textures. @@ -182,12 +168,9 @@ struct Options bool quitImmediately; bool resizeViewToRootItem; bool multisample; - bool coreProfile; bool verbose; QVector<Qt::ApplicationAttribute> applicationAttributes; QString translationFile; - QmlApplicationType applicationType; - QQuickWindow::TextRenderType textRenderType; }; #if defined(QMLSCENE_BUNDLE) @@ -280,8 +263,8 @@ static bool checkVersion(const QUrl &url) return false; } - QRegularExpression quick1("^\\s*import +QtQuick +1\\.\\w*"); - QRegularExpression qt47("^\\s*import +Qt +4\\.7"); + QRegExp quick1("^\\s*import +QtQuick +1\\.\\w*"); + QRegExp qt47("^\\s*import +Qt +4\\.7"); QTextStream stream(&f); bool codeFound= false; @@ -291,11 +274,10 @@ static bool checkVersion(const QUrl &url) codeFound = true; } else { QString import; - QRegularExpressionMatch match = quick1.match(line); - if (match.hasMatch()) - import = match.captured(0).trimmed(); - else if ((match = qt47.match(line)).hasMatch()) - import = match.captured(0).trimmed(); + if (quick1.indexIn(line) >= 0) + import = quick1.cap(0).trimmed(); + else if (qt47.indexIn(line) >= 0) + import = qt47.cap(0).trimmed(); if (!import.isNull()) { fprintf(stderr, "qmlscene: '%s' is no longer supported.\n" @@ -313,17 +295,15 @@ static bool checkVersion(const QUrl &url) static void displayFileDialog(Options *options) { #if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) - if (options->applicationType == Options::QmlApplicationTypeWidget) { - QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)"); - if (!fileName.isEmpty()) { - QFileInfo fi(fileName); - options->url = QUrl::fromLocalFile(fi.canonicalFilePath()); - } - return; + QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)"); + if (!fileName.isEmpty()) { + QFileInfo fi(fileName); + options->url = QUrl::fromLocalFile(fi.canonicalFilePath()); } -#endif // QT_WIDGETS_LIB && QT_CONFIG(filedialog) +#else Q_UNUSED(options); puts("No filename specified..."); +#endif } #if QT_CONFIG(translation) @@ -367,7 +347,6 @@ static void usage() puts(" --fullscreen ..................... Run fullscreen"); puts(" --transparent .................... Make the window transparent"); puts(" --multisample .................... Enable multisampling (OpenGL anti-aliasing)"); - puts(" --core-profile ................... Request a core profile OpenGL context"); puts(" --no-version-detection ........... Do not try to detect the version of the .qml file"); puts(" --slow-animations ................ Run all animations in slow motion"); puts(" --resize-to-root ................. Resize the window to the size of the root item"); @@ -380,10 +359,6 @@ static void usage() puts(" --scaling..........................Enable High DPI scaling (AA_EnableHighDpiScaling)"); puts(" --no-scaling.......................Disable High DPI scaling (AA_DisableHighDpiScaling)"); puts(" --verbose..........................Print version and graphical diagnostics for the run-time"); -#ifdef QT_WIDGETS_LIB - puts(" --apptype [gui|widgets] ...........Select which application class to use. Default is widgets."); -#endif - puts(" --textrendertype [qt|native].......Select the default render type for text-like elements."); puts(" -I <path> ........................ Add <path> to the list of import paths"); puts(" -P <path> ........................ Add <path> to the list of plugin paths"); puts(" -translation <translationfile> ... Set the language to run in"); @@ -463,19 +438,6 @@ static QUrl parseUrlArgument(const QString &arg) return url; } -static QQuickWindow::TextRenderType parseTextRenderType(const QString &renderType) -{ - if (renderType == QLatin1String("qt")) - return QQuickWindow::QtTextRendering; - else if (renderType == QLatin1String("native")) - return QQuickWindow::NativeTextRendering; - - usage(); - - Q_UNREACHABLE(); - return QQuickWindow::QtTextRendering; -} - class DummyTestRootObject : public QObject { Q_OBJECT @@ -510,38 +472,30 @@ int main(int argc, char ** argv) // Parse arguments for application attributes to be applied before Q[Gui]Application creation. for (int i = 1; i < argc; ++i) { const char *arg = argv[i]; - if (!qstrcmp(arg, "--disable-context-sharing")) { + if (!qstrcmp(arg, "--disable-context-sharing")) options.applicationAttributes.removeAll(Qt::AA_ShareOpenGLContexts); - } else if (!qstrcmp(arg, "--gles")) { + else if (!qstrcmp(arg, "--gles")) options.applicationAttributes.append(Qt::AA_UseOpenGLES); - } else if (!qstrcmp(arg, "--software")) { + else if (!qstrcmp(arg, "--software")) options.applicationAttributes.append(Qt::AA_UseSoftwareOpenGL); - } else if (!qstrcmp(arg, "--desktop")) { + else if (!qstrcmp(arg, "--desktop")) options.applicationAttributes.append(Qt::AA_UseDesktopOpenGL); - } else if (!qstrcmp(arg, "--scaling")) { + else if (!qstrcmp(arg, "--scaling")) options.applicationAttributes.append(Qt::AA_EnableHighDpiScaling); - } else if (!qstrcmp(arg, "--no-scaling")) { + else if (!qstrcmp(arg, "--no-scaling")) options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling); - } else if (!qstrcmp(arg, "--apptype")) { - if (++i >= argc) - usage(); - if (!qstrcmp(argv[i], "gui")) - options.applicationType = Options::QmlApplicationTypeGui; - } } for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes)) QCoreApplication::setAttribute(a); - QScopedPointer<QGuiApplication> app; #ifdef QT_WIDGETS_LIB - if (options.applicationType == Options::QmlApplicationTypeWidget) - app.reset(new QApplication(argc, argv)); + QApplication app(argc, argv); +#else + QGuiApplication app(argc, argv); #endif - if (app.isNull()) - app.reset(new QGuiApplication(argc, argv)); - QCoreApplication::setApplicationName(QStringLiteral("Viewer for Triton qml tests")); - QCoreApplication::setOrganizationName(QStringLiteral("QtProject")); - QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org")); + app.setApplicationName("Viewer for Triton qml tests"); + app.setOrganizationName("QtProject"); + app.setOrganizationDomain("qt-project.org"); QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); const QStringList arguments = QCoreApplication::arguments(); @@ -570,18 +524,12 @@ int main(int argc, char ** argv) options.resizeViewToRootItem = true; else if (lowerArgument == QLatin1String("--multisample")) options.multisample = true; - else if (lowerArgument == QLatin1String("--core-profile")) - options.coreProfile = true; else if (lowerArgument == QLatin1String("--verbose")) options.verbose = true; else if (lowerArgument == QLatin1String("-i") && i + 1 < size) imports.append(arguments.at(++i)); else if (lowerArgument == QLatin1String("-p") && i + 1 < size) pluginPaths.append(arguments.at(++i)); - else if (lowerArgument == QLatin1String("--apptype")) - ++i; // Consume previously parsed argument - else if (lowerArgument == QLatin1String("--textrendertype") && i + 1 < size) - options.textRenderType = parseTextRenderType(arguments.at(++i)); else if (lowerArgument == QLatin1String("--help") || lowerArgument == QLatin1String("-help") || lowerArgument == QLatin1String("--h") @@ -595,14 +543,14 @@ int main(int argc, char ** argv) QTranslator qtTranslator; QString sysLocale = QLocale::system().name(); if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app->installTranslator(&qtTranslator); + app.installTranslator(&qtTranslator); if (translator.load(QLatin1String("qmlscene_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app->installTranslator(&translator); + app.installTranslator(&translator); QTranslator qmlTranslator; if (!options.translationFile.isEmpty()) { if (qmlTranslator.load(options.translationFile)) { - app->installTranslator(&qmlTranslator); + app.installTranslator(&qmlTranslator); } else { fprintf(stderr, "Could not load the translation file \"%s\"\n", qPrintable(options.translationFile)); @@ -610,8 +558,6 @@ int main(int argc, char ** argv) } #endif - QQuickWindow::setTextRenderType(options.textRenderType); - QUnifiedTimer::instance()->setSlowModeEnabled(options.slowAnimations); if (options.url.isEmpty()) @@ -703,10 +649,6 @@ int main(int argc, char ** argv) window->setColor(QColor(Qt::transparent)); window->setFlags(Qt::FramelessWindowHint); } - if (options.coreProfile) { - surfaceFormat.setVersion(4, 1); - surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); - } window->setFormat(surfaceFormat); if (window->flags() == Qt::Window) // Fix window flags unless set by QML. @@ -725,7 +667,7 @@ int main(int argc, char ** argv) // Now would be a good time to inform the debug service to start listening. - exitCode = app->exec(); + exitCode = app.exec(); #ifdef QML_RUNTIME_TESTING RenderStatistics::printTotalStats(); |