-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (48 loc) · 1.7 KB
/
main.cpp
File metadata and controls
60 lines (48 loc) · 1.7 KB
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
57
58
59
60
#include "mainwindow.h"
#include <QApplication>
#include <QThread>
#include <windows.h>
#include <cstdio>
#include "Helpers/jsonhelper.h"
#include "Settings/System/settingthreadpriority.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// enable debug console
{
QJsonObject profileSettings = JsonHelper::ReadSetting("ProfileSettings");
QJsonObject development = JsonHelper::ReadObject(profileSettings, "Development");
QVariant enabled;
if (JsonHelper::ReadValue(development, "DebugConsole", enabled) && enabled.toBool())
{
// detach from the current console window
FreeConsole();
// create a separate new console window
AllocConsole();
// attach the new console to this application's process
AttachConsole(GetCurrentProcessId());
// reopen the std I/O streams to redirect I/O to the new console
freopen("CON", "r", stdin);
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);
}
}
// set main thread priority
{
QJsonObject profileSettings = JsonHelper::ReadSetting("ProfileSettings");
QJsonObject performance = JsonHelper::ReadObject(profileSettings, "Performance");
QVariant text;
if (JsonHelper::ReadValue(performance, "MainPriority", text))
{
QThread::currentThread()->setPriority(Setting::System::SettingThreadPriority::StringToPriority(text.toString()));
}
else
{
// default
QThread::currentThread()->setPriority(QThread::HighestPriority);
}
}
MainWindow w;
w.show();
return a.exec();
}