2017-04-25 00:50:30 +02:00
|
|
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
|
|
|
#include "./dbusstatusnotifier.h"
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
using namespace Data;
|
|
|
|
using namespace MiscUtils;
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
DBusStatusNotifier::DBusStatusNotifier(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_disconnectedNotification(QCoreApplication::applicationName(), QStringLiteral("network-disconnect"), 5000)
|
|
|
|
, m_internalErrorNotification(QCoreApplication::applicationName() + tr(" - internal error"), NotificationIcon::Critical, 5000)
|
|
|
|
, m_syncthingNotification(tr("Syncthing notification"), NotificationIcon::Warning, 10000)
|
|
|
|
, m_syncCompleteNotification(QCoreApplication::applicationName(), NotificationIcon::Information, 5000)
|
2017-04-25 00:50:30 +02:00
|
|
|
{
|
|
|
|
m_disconnectedNotification.setMessage(tr("Disconnected from Syncthing"));
|
|
|
|
m_disconnectedNotification.setActions(QStringList(tr("Try to reconnect")));
|
|
|
|
connect(&m_disconnectedNotification, &DBusNotification::actionInvoked, this, &DBusStatusNotifier::connectRequested);
|
2017-05-01 03:34:43 +02:00
|
|
|
m_syncthingNotification.setActions(QStringList({ QStringLiteral("show"), tr("Show"), QStringLiteral("dismiss"), tr("Dismiss") }));
|
2017-04-25 00:50:30 +02:00
|
|
|
connect(&m_syncthingNotification, &DBusNotification::actionInvoked, this, &DBusStatusNotifier::handleSyncthingNotificationAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DBusStatusNotifier::handleSyncthingNotificationAction(const QString &action)
|
|
|
|
{
|
2017-05-01 03:34:43 +02:00
|
|
|
if (action == QLatin1String("dismiss")) {
|
2017-04-25 00:50:30 +02:00
|
|
|
emit dismissNotificationsRequested();
|
2017-05-01 03:34:43 +02:00
|
|
|
} else if (action == QLatin1String("show")) {
|
2017-04-25 00:50:30 +02:00
|
|
|
emit showNotificationsRequested();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|