2016-08-30 20:01:07 +02:00
|
|
|
#ifndef TRAY_ICON_H
|
|
|
|
#define TRAY_ICON_H
|
|
|
|
|
|
|
|
#include "./traymenu.h"
|
|
|
|
|
2021-01-25 19:48:11 +01:00
|
|
|
#include <syncthingwidgets/misc/dbusstatusnotifier.h>
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2017-04-25 00:50:30 +02:00
|
|
|
#include <c++utilities/chrono/datetime.h>
|
2016-12-11 17:58:58 +01:00
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
#include <QIcon>
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QSystemTrayIcon>
|
2016-08-30 20:01:07 +02:00
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QPixmap)
|
2017-08-20 01:20:47 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
|
2016-08-30 20:01:07 +02:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
enum class SyncthingStatus;
|
2016-12-11 19:10:38 +01:00
|
|
|
enum class SyncthingErrorCategory;
|
2018-01-27 23:27:50 +01:00
|
|
|
struct SyncthingDir;
|
|
|
|
struct SyncthingDev;
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace Data
|
2016-08-30 20:01:07 +02:00
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2018-05-01 22:27:03 +02:00
|
|
|
enum class TrayIconMessageClickedAction { None, DismissNotification, ShowInternalErrors, ShowWebUi };
|
2017-08-20 01:20:47 +02:00
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class TrayIcon : public QSystemTrayIcon {
|
2016-08-30 20:01:07 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-08-09 01:11:47 +02:00
|
|
|
TrayIcon(const QString &connectionConfig = QString(), QObject *parent = nullptr);
|
2016-09-01 16:34:30 +02:00
|
|
|
TrayMenu &trayMenu();
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2020-03-08 13:50:32 +01:00
|
|
|
public Q_SLOTS:
|
2019-07-13 13:21:25 +02:00
|
|
|
void showInternalError(const QString &errorMessage, Data::SyncthingErrorCategory category, int networkError, const QNetworkRequest &request,
|
|
|
|
const QByteArray &response);
|
2019-07-12 20:24:19 +02:00
|
|
|
void showLauncherError(const QString &errorMessage, const QString &additionalInfo);
|
2019-06-10 22:48:26 +02:00
|
|
|
void showSyncthingNotification(CppUtilities::DateTime when, const QString &message);
|
2017-09-05 00:24:52 +02:00
|
|
|
void showInternalErrorsDialog();
|
2017-04-25 00:50:30 +02:00
|
|
|
void updateStatusIconAndText();
|
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);
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2020-03-08 13:50:32 +01:00
|
|
|
private Q_SLOTS:
|
2016-12-03 01:00:04 +01:00
|
|
|
void handleActivated(QSystemTrayIcon::ActivationReason reason);
|
2017-08-20 01:20:47 +02:00
|
|
|
void handleMessageClicked();
|
2018-01-27 23:27:50 +01:00
|
|
|
void showDisconnected();
|
|
|
|
void showSyncComplete(const QString &message);
|
2017-09-05 00:24:52 +02:00
|
|
|
void handleErrorsCleared();
|
2016-12-03 01:00:04 +01:00
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
private:
|
2019-06-22 17:28:09 +02:00
|
|
|
QWidget m_parentWidget;
|
|
|
|
TrayMenu *m_trayMenu;
|
2019-07-17 19:07:58 +02:00
|
|
|
#ifndef SYNCTHINGTRAY_UNIFY_TRAY_MENUS
|
2016-08-30 20:01:07 +02:00
|
|
|
QMenu m_contextMenu;
|
2017-09-05 00:24:52 +02:00
|
|
|
QAction *m_errorsAction;
|
2019-07-17 19:07:58 +02:00
|
|
|
#endif
|
2016-12-11 17:58:58 +01:00
|
|
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
2017-04-25 00:50:30 +02:00
|
|
|
DBusStatusNotifier m_dbusNotifier;
|
2018-05-01 22:27:03 +02:00
|
|
|
bool &m_dbusNotificationsEnabled;
|
2016-12-11 17:58:58 +01:00
|
|
|
#endif
|
2018-05-10 13:51:07 +02:00
|
|
|
bool &m_notifyOnSyncthingErrors;
|
2017-08-20 01:20:47 +02:00
|
|
|
TrayIconMessageClickedAction m_messageClickedAction;
|
2016-08-30 20:01:07 +02:00
|
|
|
};
|
|
|
|
|
2016-09-01 16:34:30 +02:00
|
|
|
inline TrayMenu &TrayIcon::trayMenu()
|
|
|
|
{
|
2019-06-22 17:28:09 +02:00
|
|
|
return *m_trayMenu;
|
2016-09-01 16:34:30 +02:00
|
|
|
}
|
2018-01-27 23:27:50 +01:00
|
|
|
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace QtGui
|
2016-08-30 20:01:07 +02:00
|
|
|
|
|
|
|
#endif // TRAY_ICON_H
|