forked from xinhecuican/easy-capture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
112 lines (103 loc) · 3.24 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Setting/setting.h"
#include "new_capture/CaptureWindow.h"
#include "Manager/WindowManager.h"
#include <QApplication>
#include<QTextCodec>
#include "Manager/config.h"
#include "Manager/KeyManager.h"
#include "Paint/PaintWindow.h"
#include "JlCompress.h"
#include "Manager/update.h"
#include "Style_widget/tray.h"
#include <windows.h>
#include "MainFilter.h"
#include "Paint/Widgets/history.h"
#include<dbghelp.h>
#include "Helper/debug.h"
#include "Paint/Widgets/Layers/rect_layer.h"
#include "Paint/Widgets/Layers/text_layer.h"
#include "Paint/Widgets/Layers/picture_layer.h"
#include "Paint/Widgets/Layers/paintlayer.h"
#include "Paint/Widgets/Layers/shapelayer.h"
#include "Paint/Widgets/Layers/blurlayer.h"
#include "Paint/Widgets/Layers/arrowlayer.h"
#include "new_capture/Widgets/cliplayer.h"
#include "Helper/log.h"
#include<QPair>
#include "Manager/uimanager.h"
#include "Paint/Widgets/Panels/flow_edit_panel.h"
#include "Windows/scrollerwindow.h"
#include "Windows/pinwindow.h"
#ifndef QT_DEBUG
#include <QBreakpadHandler.h>
#include <QBreakpadHttpUploader.h>
#endif
//#ifdef QT_DEBUG
//#pragma comment(lib, "C:/usr/software/Visual_Leak_Detector/lib/Win64/vld.lib")
//#include "vld.h"
//#endif
void registerClasses();
void setupDebug();
void preLoad();
#ifdef TEST
#include "Tests/AllTests.h"
#include <QTest>
QTEST_MAIN(ConfigTest);
#else
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
// 设置PWD
QString applicationDirPathStr = QCoreApplication::applicationDirPath();
QDir::setCurrent(applicationDirPathStr);
if(argc == 3 && strncmp(argv[1], "buildTheme", 20) == 0) {
UIManager::instance()->buildRelease(QString(argv[2]));
return 0;
}
if(argc == 2 && strncmp(argv[1], "update", 10) == 0){
Update::instance()->save();
return 0;
}
setupDebug();
preLoad();
MainFilter* fliter = MainFilter::instance();
a.installNativeEventFilter(fliter); // 捕获程序键盘事件
a.setQuitOnLastWindowClosed(false);
a.connect(&a, &QApplication::aboutToQuit, &a, [=]() {
KeyManager::instance()->unRegisterAll();
Update::instance()->onFinish();
fliter->deleteLater();
});
Flow_edit_panel::instance();// 初始化时间过长,提前初始化一次
qInfo() << "程序启动";
int ans = a.exec();
return ans;
}
#endif
void registerClasses() {
Reflect::registerClass<Setting>();
Reflect::registerClass<CaptureWindow>();
Reflect::registerClass<PaintWindow>();
Reflect::registerClass<ScrollerWindow>();
Reflect::registerClass<PinWindow>();
Reflect::registerClass<RectLayer>();
Reflect::registerClass<Text_layer>();
Reflect::registerClass<Picture_layer>();
Reflect::registerClass< PaintLayer>();
Reflect::registerClass<ShapeLayer>();
Reflect::registerClass<BlurLayer>();
Reflect::registerClass<ArrowLayer>();
Reflect::registerClass<ClipRegion>();
}
void setupDebug(){
#ifndef QT_DEBUG
QBreakpadInstance.setDumpPath(QLatin1String("crashs"));
QBreakpadInstance.mainVersion = Update::now_version.get_version();
logSysInit("Data/Temp/log.txt");
#endif
}
void preLoad(){
Config::loadConfig();
KeyManager::instance()->load();
MString::load_from_file("Data/Languages/");
registerClasses();
}