@@ -24,6 +24,7 @@ This file is part of Fast Track.
2424#include < QScopedPointer>
2525#include < QSplashScreen>
2626#include < QString>
27+ #include " cli.h"
2728#include " mainwindow.h"
2829
2930QScopedPointer<QFile> logFile;
@@ -35,27 +36,36 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
3536}
3637
3738int 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);
5152#ifdef QT_NO_DEBUG
52- qInstallMessageHandler (messageHandler);
53+ qInstallMessageHandler (messageHandler);
5354#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+ }
6171}
0 commit comments