2017-04-25 00:50:30 +02:00
|
|
|
#if !defined(SYNCTHINGWIDGETS_DBUSSTATUSNOTIFIER_H) && defined(QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS)
|
|
|
|
#define SYNCTHINGWIDGETS_DBUSSTATUSNOTIFIER_H
|
|
|
|
|
2017-08-20 01:20:47 +02:00
|
|
|
#include "./internalerror.h"
|
2017-04-25 00:50:30 +02:00
|
|
|
|
|
|
|
#include <qtutilities/misc/dbusnotification.h>
|
|
|
|
|
|
|
|
#include <c++utilities/chrono/datetime.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
enum class SyncthingErrorCategory;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT DBusStatusNotifier : public QObject {
|
2017-04-25 00:50:30 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DBusStatusNotifier(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void showDisconnect();
|
|
|
|
void hideDisconnect();
|
2017-08-20 01:20:47 +02:00
|
|
|
void showInternalError(const InternalError &error);
|
2017-04-25 00:50:30 +02:00
|
|
|
void showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message);
|
|
|
|
void showSyncComplete(const QString &message);
|
2018-05-01 22:27:03 +02:00
|
|
|
void showNewDev(const QString &devId, const QString &message);
|
|
|
|
void showNewDir(const QString &devId, const QString &dirId, const QString &message);
|
2017-04-25 00:50:30 +02:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void connectRequested();
|
|
|
|
void dismissNotificationsRequested();
|
|
|
|
void showNotificationsRequested();
|
2017-08-20 01:20:47 +02:00
|
|
|
void errorDetailsRequested();
|
2018-05-01 22:27:03 +02:00
|
|
|
void webUiRequested();
|
2017-04-25 00:50:30 +02:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void handleSyncthingNotificationAction(const QString &action);
|
|
|
|
|
|
|
|
private:
|
|
|
|
MiscUtils::DBusNotification m_disconnectedNotification;
|
|
|
|
MiscUtils::DBusNotification m_internalErrorNotification;
|
|
|
|
MiscUtils::DBusNotification m_syncthingNotification;
|
|
|
|
MiscUtils::DBusNotification m_syncCompleteNotification;
|
2018-05-01 22:27:03 +02:00
|
|
|
MiscUtils::DBusNotification m_newDevNotification;
|
|
|
|
MiscUtils::DBusNotification m_newDirNotification;
|
2017-04-25 00:50:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline void DBusStatusNotifier::showDisconnect()
|
|
|
|
{
|
|
|
|
m_disconnectedNotification.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void DBusStatusNotifier::hideDisconnect()
|
|
|
|
{
|
|
|
|
m_disconnectedNotification.hide();
|
|
|
|
}
|
|
|
|
|
2017-08-20 01:20:47 +02:00
|
|
|
inline void DBusStatusNotifier::showInternalError(const InternalError &error)
|
2017-04-25 00:50:30 +02:00
|
|
|
{
|
2017-08-20 01:20:47 +02:00
|
|
|
m_internalErrorNotification.update(error.message);
|
2017-04-25 00:50:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void DBusStatusNotifier::showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message)
|
|
|
|
{
|
|
|
|
Q_UNUSED(when)
|
|
|
|
m_syncthingNotification.update(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void DBusStatusNotifier::showSyncComplete(const QString &message)
|
|
|
|
{
|
|
|
|
m_syncCompleteNotification.update(message);
|
|
|
|
}
|
2018-05-01 22:27:03 +02:00
|
|
|
|
|
|
|
inline void DBusStatusNotifier::showNewDev(const QString &devId, const QString &message)
|
|
|
|
{
|
|
|
|
Q_UNUSED(devId)
|
|
|
|
m_newDevNotification.update(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void DBusStatusNotifier::showNewDir(const QString &devId, const QString &dirId, const QString &message)
|
|
|
|
{
|
|
|
|
Q_UNUSED(devId)
|
|
|
|
Q_UNUSED(dirId)
|
|
|
|
m_newDirNotification.update(message);
|
|
|
|
}
|
|
|
|
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace QtGui
|
2017-04-25 00:50:30 +02:00
|
|
|
|
|
|
|
#endif // !defined(SYNCTHINGWIDGETS_DBUSSTATUSNOTIFIER_H) && defined(QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS)
|