-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
103 lines (80 loc) · 2.75 KB
/
main.cpp
File metadata and controls
103 lines (80 loc) · 2.75 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
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
#include "qtvsplayer.h"
#include <QApplication>
#if (!defined(__ANDROID__))
#include "qtvsplayer_adaptor.h"
#endif
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
#if (!defined(__linux__))
printf("Debug---DBus is bugy under windows");
#elif ((defined(__linux__) | defined(__APPLE__)) & !defined(__ANDROID__))
if (!QDBusConnection::sessionBus().isConnected()) {
qWarning("Cannot connect to the D-Bus session bus.\n"
"Please check your system settings and try again.\n mac :brew services start dbus\n linux:systemctl start dbus.service\n");
return 1;
}
#endif
QThreadPool::globalInstance()->setMaxThreadCount(1);
QThreadPool::globalInstance()->setExpiryTimeout(3000);
QSharedMemory sharedMemory;
sharedMemory.setKey("QtVsPlayerUniqueInstance");
//QtVsplayer crashed we free sharedMemory
if (sharedMemory.attach()){
sharedMemory.detach();
}
if (!sharedMemory.create(1))
{
#if (defined(__linux__) | defined(__APPLE__))
new QtVsPlayerAdaptor(&a);
QDBusConnection::sessionBus().registerObject("/", &a);
QDBusMessage msg = QDBusMessage::createSignal("/", "local.QtVsPlayer", "message");
if (argc > 1) {
msg << QString(argv[1]);
QDBusConnection::sessionBus().send(msg);
}else
{
msg << "Raiseit";
QDBusConnection::sessionBus().send(msg);
}
#endif
exit(0); // Exit already a process running
}
//Translation
QTranslator qtTranslator;
bool bsuc = false;
bsuc = qtTranslator.load( QLocale(), QLatin1String("qt"), QLatin1String("_"),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
//surpress warning!
if (bsuc == false ) {
//I'm happy for yu
}
//surpress warning!
a.installTranslator(&qtTranslator);
QTranslator myappTranslator;
bsuc = myappTranslator.load(QLocale(), QLatin1String("QtVsPlayer"), QLatin1String("_"),
"/usr/share/QtVsPlayer/translations");
//surpress warning!
if (bsuc == false ) {
//I'm happy for yu
}
//surpress warning!
#if (defined(_WIN32))
bsuc = myappTranslator.load(QLocale(), QLatin1String("QtVsPlayer"), QLatin1String("_"),
QCoreApplication::applicationDirPath());
#endif
a.installTranslator(&myappTranslator);
//End Translation
QtVsPlayer w;
// a.installEventFilter(&w);
w.show();
QStringList list;
for (int a = 1; a < argc; ++a) {
list << QString::fromLocal8Bit(argv[a]);
}
//if (list.length() > 0) {w.ParseArgs(list);}
qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
return a.exec();
//}
}