| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #include "qtdiag.h" |
| 5 | |
| 6 | #include <QtGui/QGuiApplication> |
| 7 | #include <QtCore/QCommandLineParser> |
| 8 | |
| 9 | #include <iostream> |
| 10 | #include <string> |
| 11 | |
| 12 | QT_USE_NAMESPACE |
| 13 | |
| 14 | int main(int argc, char **argv) |
| 15 | { |
| 16 | QGuiApplication app(argc, argv); |
| 17 | |
| 18 | QCoreApplication::setApplicationName(QStringLiteral("qtdiag")); |
| 19 | QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); |
| 20 | QCoreApplication::setOrganizationName(QStringLiteral("QtProject")); |
| 21 | QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org")); |
| 22 | |
| 23 | QCommandLineParser commandLineParser; |
| 24 | const QCommandLineOption noGlOption(QStringLiteral("no-gl"), QStringLiteral( "Do not output GL information")); |
| 25 | const QCommandLineOption glExtensionOption(QStringLiteral("gl-extensions"), QStringLiteral( "List GL extensions")); |
| 26 | const QCommandLineOption fontOption(QStringLiteral("fonts"), QStringLiteral( "Output list of fonts")); |
| 27 | const QCommandLineOption noVkOption(QStringLiteral("no-vulkan"), QStringLiteral( "Do not output Vulkan information")); |
| 28 | const QCommandLineOption noRhiOption(QStringLiteral("no-rhi"), QStringLiteral( "Do not output RHI information")); |
| 29 | commandLineParser.setApplicationDescription(QStringLiteral("Prints diagnostic output about the Qt library.")); |
| 30 | commandLineParser.addOption(commandLineOption: noGlOption); |
| 31 | commandLineParser.addOption(commandLineOption: glExtensionOption); |
| 32 | commandLineParser.addOption(commandLineOption: fontOption); |
| 33 | commandLineParser.addOption(commandLineOption: noVkOption); |
| 34 | commandLineParser.addOption(commandLineOption: noRhiOption); |
| 35 | commandLineParser.addHelpOption(); |
| 36 | commandLineParser.process(app); |
| 37 | unsigned flags = commandLineParser.isSet(option: noGlOption) ? 0u : unsigned(QtDiagGl); |
| 38 | if (commandLineParser.isSet(option: glExtensionOption)) |
| 39 | flags |= QtDiagGlExtensions; |
| 40 | if (commandLineParser.isSet(option: fontOption)) |
| 41 | flags |= QtDiagFonts; |
| 42 | if (!commandLineParser.isSet(option: noVkOption)) |
| 43 | flags |= QtDiagVk; |
| 44 | if (!commandLineParser.isSet(option: noRhiOption)) |
| 45 | flags |= QtDiagRhi; |
| 46 | |
| 47 | std::wcout << qtDiag(flags).toStdWString(); |
| 48 | std::wcout.flush(); |
| 49 | return 0; |
| 50 | } |
| 51 |
