2016-08-30 20:01:07 +02:00
|
|
|
#ifndef TRAY_ICON_H
|
|
|
|
#define TRAY_ICON_H
|
|
|
|
|
|
|
|
#include "./traymenu.h"
|
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
#include <c++utilities/chrono/datetime.h>
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2016-12-11 17:58:58 +01:00
|
|
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
|
|
|
# include <qtutilities/misc/dbusnotification.h>
|
|
|
|
#endif
|
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QPixmap)
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
enum class SyncthingStatus;
|
2016-12-11 19:10:38 +01:00
|
|
|
enum class SyncthingErrorCategory;
|
2016-08-30 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
|
|
|
class TrayIcon : public QSystemTrayIcon
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
TrayIcon(QObject *parent = nullptr);
|
2016-09-01 16:34:30 +02:00
|
|
|
TrayMenu &trayMenu();
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2016-12-03 01:00:04 +01:00
|
|
|
public slots:
|
2016-12-11 19:10:38 +01:00
|
|
|
void showInternalError(const QString &errorMsg, Data::SyncthingErrorCategory category);
|
2016-09-08 23:35:15 +02:00
|
|
|
void showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message);
|
2016-08-30 20:01:07 +02:00
|
|
|
void updateStatusIconAndText(Data::SyncthingStatus status);
|
|
|
|
|
2016-12-03 01:00:04 +01:00
|
|
|
private slots:
|
|
|
|
void handleActivated(QSystemTrayIcon::ActivationReason reason);
|
2016-12-11 17:58:58 +01:00
|
|
|
void handleSyncthingNotificationAction(const QString &action);
|
2016-12-03 01:00:04 +01:00
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
private:
|
|
|
|
QPixmap renderSvgImage(const QString &path);
|
|
|
|
|
|
|
|
const QSize m_size;
|
|
|
|
const QIcon m_statusIconDisconnected;
|
2016-09-03 19:39:43 +02:00
|
|
|
const QIcon m_statusIconIdling;
|
|
|
|
const QIcon m_statusIconScanning;
|
2016-08-30 20:01:07 +02:00
|
|
|
const QIcon m_statusIconNotify;
|
|
|
|
const QIcon m_statusIconPause;
|
|
|
|
const QIcon m_statusIconSync;
|
2016-10-06 23:41:40 +02:00
|
|
|
const QIcon m_statusIconError;
|
|
|
|
const QIcon m_statusIconErrorSync;
|
2016-08-30 20:01:07 +02:00
|
|
|
TrayMenu m_trayMenu;
|
|
|
|
QMenu m_contextMenu;
|
|
|
|
Data::SyncthingStatus m_status;
|
2016-12-11 17:58:58 +01:00
|
|
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
|
|
|
MiscUtils::DBusNotification m_disconnectedNotification;
|
|
|
|
MiscUtils::DBusNotification m_internalErrorNotification;
|
|
|
|
MiscUtils::DBusNotification m_syncthingNotification;
|
|
|
|
MiscUtils::DBusNotification m_syncCompleteNotification;
|
|
|
|
#endif
|
2016-08-30 20:01:07 +02:00
|
|
|
};
|
|
|
|
|
2016-09-01 16:34:30 +02:00
|
|
|
inline TrayMenu &TrayIcon::trayMenu()
|
|
|
|
{
|
|
|
|
return m_trayMenu;
|
|
|
|
}
|
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TRAY_ICON_H
|