8
8
#include < QSharedMemory>
9
9
#include < QMessageBox>
10
10
#include " App.h"
11
- #include " Tray.h"
12
- #include " Logger.h"
13
11
#include " NativeRect.h"
14
12
#include " Font.h"
15
13
#include " ../Win/WinFull.h"
16
14
#include " ../Win/WinPin.h"
17
- #include " ../Lib/QHotKey/qhotkey.h"
18
15
#include " ../Tool/ToolMain.h"
19
16
#include " ../Tool/ToolSub.h"
20
17
#include " ../Tool/ColorCtrl.h"
@@ -23,42 +20,21 @@ namespace {
23
20
std::unique_ptr<App> app;
24
21
QList<QRect> screens;
25
22
QList<QRect> windows;
26
- QSharedMemory* smSingleApp;
27
23
}
28
24
void App::init ()
29
25
{
30
- new Logger (qApp);
31
26
initConfig ();
32
27
start ();
33
28
}
34
29
void App::dispose ()
35
30
{
36
- app.reset ();
37
- if (smSingleApp->isAttached ()) {
38
- smSingleApp->detach ();// 如果是最后一个进程,则会自动删除共享内存
39
- }
31
+ app.reset ();
40
32
}
41
33
void App::start ()
42
34
{
43
35
NativeRect::init ();
44
36
WinFull::init ();
45
37
}
46
- bool App::singleAppLock ()
47
- {
48
- smSingleApp = new QSharedMemory (" ScreenCapture" , qApp);
49
- bool flag{ false };
50
- if (smSingleApp->attach (QSharedMemory::ReadOnly)) {
51
- smSingleApp->detach ();
52
- flag = false ;
53
- }
54
- else if (smSingleApp->create (1 )) {
55
- flag = true ;
56
- }
57
- if (!flag) {
58
- QMessageBox::warning (nullptr , " Warning" , " ScreenCapture is already running." );
59
- }
60
- return flag;
61
- }
62
38
void App::initConfig ()
63
39
{
64
40
QString jsonStr = R"888( {
@@ -408,12 +384,9 @@ void App::initConfig()
408
384
}
409
385
QJsonObject jsonObject = document.object ();
410
386
auto lang = jsonObject[" defaultLang" ].toString ();
411
- Tray::initData (jsonObject[" tray" ].toObject (), lang);
412
387
WinPin::initData (jsonObject[" winPin" ].toArray (), lang);
413
388
ToolMain::initData (jsonObject[" toolMain" ].toArray (), lang);
414
389
ToolSub::initData (jsonObject[" toolSub" ].toObject (), lang);
415
390
ColorCtrl::initData (jsonObject[" colorCtrl" ].toObject (), lang);
416
391
Font::initData (jsonObject[" icon" ].toObject ());
417
- auto hotkey = new QHotkey (QKeySequence (jsonObject[" hotKey" ].toString ()), true ,qApp);
418
- QObject::connect (hotkey, &QHotkey::activated, &App::start);
419
392
}
0 commit comments