forked from zserge/tray
-
Notifications
You must be signed in to change notification settings - Fork 16
/
tray_linux.cpp
49 lines (39 loc) · 866 Bytes
/
tray_linux.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
#include "QtTrayMenu.h"
#include <QApplication>
#include "tray.h"
static QtTrayMenu *trayMenuInstance = nullptr;
static struct tray *currentTrayStruct = nullptr;
extern "C"
{
TRAY_EXPORT struct tray *tray_get_instance()
{
return currentTrayStruct;
}
TRAY_EXPORT int tray_init(struct tray *tray)
{
currentTrayStruct = tray;
if (!trayMenuInstance)
{
trayMenuInstance = new QtTrayMenu();
}
return trayMenuInstance->init(tray);
}
TRAY_EXPORT int tray_loop(int blocking) {
return trayMenuInstance ? trayMenuInstance->loop(blocking) : -1;
}
TRAY_EXPORT void tray_update(struct tray *tray)
{
currentTrayStruct = tray;
if (trayMenuInstance)
{
trayMenuInstance->update(tray);
}
}
TRAY_EXPORT void tray_exit(void)
{
if (trayMenuInstance)
{
trayMenuInstance->exit();
}
}
} // extern "C"