syncthingtray/tray/gui/trayicon.h
Martchus 975e86c895 Allow backend libraries to be used from other projects
So far the backend libraries' include paths were relative within this
repository. This means the header files could not be used at their
installed location.

This change replaces them with "<>" includes to fix that problem and adds
a new include directory so building everything at once still works.

With this change it should be easier to actually split some parts into
another repository if this one would become too big.
2021-01-25 19:48:11 +01:00

74 lines
2.0 KiB
C++

#ifndef TRAY_ICON_H
#define TRAY_ICON_H
#include "./traymenu.h"
#include <syncthingwidgets/misc/dbusstatusnotifier.h>
#include <c++utilities/chrono/datetime.h>
#include <QIcon>
#include <QSystemTrayIcon>
QT_FORWARD_DECLARE_CLASS(QPixmap)
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
namespace Data {
enum class SyncthingStatus;
enum class SyncthingErrorCategory;
struct SyncthingDir;
struct SyncthingDev;
} // namespace Data
namespace QtGui {
enum class TrayIconMessageClickedAction { None, DismissNotification, ShowInternalErrors, ShowWebUi };
class TrayIcon : public QSystemTrayIcon {
Q_OBJECT
public:
TrayIcon(const QString &connectionConfig = QString(), QObject *parent = nullptr);
TrayMenu &trayMenu();
public Q_SLOTS:
void showInternalError(const QString &errorMessage, Data::SyncthingErrorCategory category, int networkError, const QNetworkRequest &request,
const QByteArray &response);
void showLauncherError(const QString &errorMessage, const QString &additionalInfo);
void showSyncthingNotification(CppUtilities::DateTime when, const QString &message);
void showInternalErrorsDialog();
void updateStatusIconAndText();
void showNewDev(const QString &devId, const QString &message);
void showNewDir(const QString &devId, const QString &dirId, const QString &message);
private Q_SLOTS:
void handleActivated(QSystemTrayIcon::ActivationReason reason);
void handleMessageClicked();
void showDisconnected();
void showSyncComplete(const QString &message);
void handleErrorsCleared();
private:
QWidget m_parentWidget;
TrayMenu *m_trayMenu;
#ifndef SYNCTHINGTRAY_UNIFY_TRAY_MENUS
QMenu m_contextMenu;
QAction *m_errorsAction;
#endif
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
DBusStatusNotifier m_dbusNotifier;
bool &m_dbusNotificationsEnabled;
#endif
bool &m_notifyOnSyncthingErrors;
TrayIconMessageClickedAction m_messageClickedAction;
};
inline TrayMenu &TrayIcon::trayMenu()
{
return *m_trayMenu;
}
} // namespace QtGui
#endif // TRAY_ICON_H