-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (47 loc) · 1.36 KB
/
main.cpp
File metadata and controls
56 lines (47 loc) · 1.36 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
#include "MainWindow.h"
#include "parametermanager.h"
#include "QSingleInstance/qsingleinstance.h"
#include "threadhttpd.h"
#include "bookmarks.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);
}
if ( p.isBookmarkRequest() )
{
BookmarkManager b ;
b.loadFromFile(BookmarkManager::pathBookmark());
b.addBookmark (p.nameParam);
b.saveToFile(BookmarkManager::pathBookmark());
}
QSingleInstance instance;
instance.setAutoRecovery(true);
MainWindow *w= nullptr;
instance.setStartupFunction([&]() -> int {
w = new MainWindow( a.applicationDirPath() );
ThreadHttpd *t = new ThreadHttpd(w);
instance.setNotifyWindow(w);
t->start();
w->show();
return 0;
});
QObject::connect(&instance, &QSingleInstance::instanceMessage, [&](QStringList args){
if (w) {
qDebug() << args;
w->commandRecieved(QDir::currentPath(),args);
}
});
return instance.singleExec();
}