1 | /* -*- C++ -*- |
---|---|
2 | This file is part of ThreadWeaver. |
3 | |
4 | SPDX-FileCopyrightText: 2005-2014 Mirko Boehm <mirko@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #include <iostream> |
10 | |
11 | #include <QApplication> |
12 | #include <QCommandLineOption> |
13 | #include <QCommandLineParser> |
14 | #include <QFileInfoList> |
15 | #include <QTest> |
16 | |
17 | #include "Benchmark.h" |
18 | #include "MainWindow.h" |
19 | #include "Model.h" |
20 | |
21 | using namespace std; |
22 | |
23 | int main(int argc, char **argv) |
24 | { |
25 | QApplication app(argc, argv); |
26 | app.setApplicationName(QLatin1String("ThumbNailer")); |
27 | app.setOrganizationDomain(QLatin1String("kde.org")); |
28 | QCommandLineParser parser; |
29 | parser.setApplicationDescription(app.translate(context: "main", key: "ThreadWeaver ThumbNailer Example")); |
30 | parser.addHelpOption(); |
31 | parser.addPositionalArgument(name: QLatin1String("mode"), description: QLatin1String( "Benchmark or demo mode")); |
32 | parser.process(app); |
33 | const QStringList positionals = parser.positionalArguments(); |
34 | const QString mode = positionals.isEmpty() ? QLatin1String("demo") : positionals[0]; |
35 | if (mode == QLatin1String("benchmark")) { |
36 | Benchmark benchmark; |
37 | const QStringList arguments = app.arguments().mid(pos: 1); // remove mode selection |
38 | return QTest::qExec(testObject: &benchmark, arguments); |
39 | } else if (mode == QLatin1String("demo")) { |
40 | // demo mode |
41 | MainWindow mainWindow; |
42 | mainWindow.show(); |
43 | return app.exec(); |
44 | } else { |
45 | wcerr << "Unknown mode "<< mode.toStdWString() << endl << endl; |
46 | parser.showHelp(); |
47 | Q_UNREACHABLE(); |
48 | } |
49 | return 0; |
50 | } |
51 |
Definitions
Learn Advanced QML with KDAB
Find out more