-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (36 loc) · 1012 Bytes
/
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
#include "MainWindow.h"
#include "parametermanager.h"
#include "QSingleInstance/qsingleinstance.h"
#include <QDir>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStringList cmd;
for( int n = 0; n< argc; n++)
{
cmd << QString(argv[n]);
}
auto p = parameterManager(cmd);
if ( p.isHelpRequest() )
{
p.showHelp();
exit(0);
}
QSingleInstance instance;
instance.setAutoRecovery(true);
MainWindow *w= nullptr;
instance.setStartupFunction([&]() -> int {
w = new MainWindow();
instance.setNotifyWindow(w);
w->show();
return 0;
});
QObject::connect(&instance, &QSingleInstance::instanceMessage, [&](QStringList args){
if (w) {
qDebug() << args;
w->commandRecieved(QDir::currentPath(),args);
}
});
return instance.singleExec();
}