-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.cpp
56 lines (44 loc) · 1.2 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QString addr = "";
bool debug_console = false;
//if (argc == 2)
// addr = QString(argv[1]);
for (int i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "debug"))
debug_console = true;
else
addr = QString(argv[i]);
}
#ifdef _WIN32
if (!debug_console)
{
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
}
else
{
if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
}
#endif
int return_code;
do
{
QApplication a(argc, argv);
MainWindow w(addr, nullptr);
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
w.move(screenGeometry.center() - w.rect().center());
w.show();
return_code = a.exec();
} while (return_code == RESTART_CODE);
return return_code;
}