-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
31 lines (26 loc) · 820 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <QApplication>
#include <QCoreApplication>
#include <QTextStream>
#include "cli.h"
#include "mainwindow.h"
QCoreApplication* createApplication(int &argc, char *argv[]) {
// Iterate over argv[] to find arguments
for (int i = 1; i < argc; i++)
if (!qstrcmp(argv[i], "--no-gui") || !qstrcmp(argv[i], "--help"))
return new QCoreApplication(argc, argv);
return new QApplication(argc, argv);
}
int main(int argc, char *argv[])
{
QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
if (qobject_cast<QApplication*>(app.data())) {
// GUI version
MainWindow w;
w.show();
return app->exec();
} else {
// Non-GUI version
QScopedPointer<CLI> console(new CLI(argc, argv, app.data()));
return 0;
}
}