-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathmain.cpp
77 lines (63 loc) · 2.17 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <QApplication>
#include <QFontDatabase>
#include <QElapsedTimer>
#include <QFile>
#include <QDir>
#include <QLockFile>
#include "tc_common_new/log.h"
#include "tc_common_new/folder_util.h"
#include "render_panel/gr_application.h"
#include "render_panel/gr_workspace.h"
#include "render_panel/gr_running_pipe.h"
#include "tc_common_new/win32/dxgi_mon_detector.h"
using namespace tc;
bool PrepareDirs(const QString& base_path) {
std::vector<QString> dirs = {
"gr_logs", "gr_data"
};
bool result = true;
for (const QString& dir : dirs) {
auto target_dir_path = base_path + "/" + dir;
QDir target_dir(target_dir_path);
if (target_dir.exists()) {
continue;
}
if (!target_dir.mkpath(target_dir_path)) {
result = false;
LOGI("Make path failed: {}", target_dir_path.toStdString());
}
}
return result;
}
std::shared_ptr<GrWorkspace> g_workspace = nullptr;
int main(int argc, char *argv[]) {
// AllocConsole();
// freopen("CONOUT$", "w", stdout);
QApplication app(argc, argv);
auto base_dir = QString::fromStdWString(FolderUtil::GetCurrentFolderPath());
auto log_path = base_dir + "/gr_logs/gammaray.log";
std::cout << "log path: " << log_path.toStdString() << std::endl;
Logger::InitLog(log_path.toStdString(), true);
// pipe
auto rn_pipe = std::make_shared<GrRunningPipe>();
if (!rn_pipe->SendHello()) {
rn_pipe->StartListening([=]() {
if (g_workspace) {
g_workspace->showNormal();
}
});
}
auto mon_detector = DxgiMonitorDetector::Instance();
mon_detector->DetectAdapters();
mon_detector->PrintAdapters();
int id = QFontDatabase::addApplicationFont(":/resources/font/matrix.ttf");
auto families = QFontDatabase::applicationFontFamilies(id);
for (auto& f : families) {
LOGI("font family : {}", f.toStdString());
}
PrepareDirs(base_dir);
g_workspace = std::make_shared<GrWorkspace>();
g_workspace->setFixedSize(1720, 900);
g_workspace->show();
return app.exec();
}