-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotificationshandler.cpp
43 lines (34 loc) · 1.09 KB
/
notificationshandler.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
/*
This file is part of Waver
Copyright (C) 2021 Peter Papp
Please visit https://launchpad.net/waver for details
*/
#include "notificationshandler.h"
// constructor
NotificationsHandler::NotificationsHandler(Waver *waver) : QObject()
{
#ifdef Q_OS_LINUX
if (QDBusConnection::sessionBus().isConnected()) {
new MediaPlayer2DBusAdaptor(waver, this);
new MediaPlayer2PlayerDBusAdaptor(waver, this);
QDBusConnection::sessionBus().registerService("org.mpris.MediaPlayer2.waver");
QDBusConnection::sessionBus().registerObject("/org/mpris/MediaPlayer2", this);
}
#endif
#ifdef Q_OS_WIN
trayIcon = new TrayIcon(waver, this);
#endif
}
// destrucor
NotificationsHandler::~NotificationsHandler()
{
#ifdef Q_OS_LINUX
if (QDBusConnection::sessionBus().isConnected()) {
QDBusConnection::sessionBus().unregisterObject("/org/mpris/MediaPlayer2", QDBusConnection::UnregisterTree);
QDBusConnection::sessionBus().unregisterService("org.mpris.MediaPlayer2.waver");
}
#endif
#ifdef Q_OS_WIN
delete trayIcon;
#endif
}