@@ -24,6 +24,7 @@ This file is part of Fast Track.
24
24
#include < QScopedPointer>
25
25
#include < QSplashScreen>
26
26
#include < QString>
27
+ #include " cli.h"
27
28
#include " mainwindow.h"
28
29
29
30
QScopedPointer<QFile> logFile;
@@ -35,27 +36,36 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
35
36
}
36
37
37
38
int main (int argc, char *argv[]) {
38
- char env[] = " OPENCV_OPENCL_DEVICE= disabled" ;
39
- putenv (env); // disable OpenCL to fix windows memory leaks and increase performance
40
- QApplication a (argc, argv);
41
- QPixmap pixmap (QStringLiteral (" :/assets/icon.png" ));
42
- QSplashScreen splash (pixmap);
43
- splash.show ();
44
- a.setApplicationName (QStringLiteral (" FastTrack" ));
45
- a.setApplicationVersion (APP_VERSION); // clazy:exclude=qstring-allocations
46
- a.setOrganizationName (QStringLiteral (" FastTrackOrg" ));
47
- a.setOrganizationDomain (QStringLiteral (" www.fasttrack.sh" ));
48
- logFile.reset (new QFile (QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation) + " /fasttrack.log" ));
49
- QDir ().mkpath (QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation));
50
- logFile.data ()->open (QFile::Append | QFile::Text);
39
+ qputenv ( " OPENCV_OPENCL_DEVICE" , " disabled" ); // disable OpenCL to fix windows memory leaks and increase performance
40
+ if ( qstrcmp (argv[ 1 ], " --cli " )) {
41
+ QApplication a (argc, argv);
42
+ QPixmap pixmap (QStringLiteral (" :/assets/icon.png" ));
43
+ QSplashScreen splash (pixmap);
44
+ splash.show ();
45
+ a.setApplicationName (QStringLiteral (" FastTrack" ));
46
+ a.setApplicationVersion (APP_VERSION); // clazy:exclude=qstring-allocations
47
+ a.setOrganizationName (QStringLiteral (" FastTrackOrg" ));
48
+ a.setOrganizationDomain (QStringLiteral (" www.fasttrack.sh" ));
49
+ logFile.reset (new QFile (QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation) + " /fasttrack.log" ));
50
+ QDir ().mkpath (QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation));
51
+ logFile.data ()->open (QFile::Append | QFile::Text);
51
52
#ifdef QT_NO_DEBUG
52
- qInstallMessageHandler (messageHandler);
53
+ qInstallMessageHandler (messageHandler);
53
54
#endif
54
- MainWindow w;
55
- w.setWindowIcon (QIcon (" :/assets/icon.png" ));
56
- QFontDatabase::addApplicationFont (QStringLiteral (" :/assets/Font.ttf" ));
57
- w.setStyleSheet (QStringLiteral (" QWidget {font-family: 'Lato', sans-serif;}" ));
58
- w.show ();
59
- splash.finish (&w);
60
- a.exec ();
55
+ MainWindow w;
56
+ w.setWindowIcon (QIcon (" :/assets/icon.png" ));
57
+ QFontDatabase::addApplicationFont (QStringLiteral (" :/assets/Font.ttf" ));
58
+ w.setStyleSheet (QStringLiteral (" QWidget {font-family: 'Lato', sans-serif;}" ));
59
+ w.show ();
60
+ splash.finish (&w);
61
+ a.exec ();
62
+ }
63
+ else {
64
+ std::vector<char *> args (argv, argv + argc);
65
+ args.erase (args.begin () + 1 );
66
+ argc = static_cast <int >(args.size ());
67
+ argv = args.data ();
68
+ QCoreApplication a (argc, argv);
69
+ return cli (argc, argv);
70
+ }
61
71
}
0 commit comments