Files
amnezia-client/client/ui/systemtray_notificationhandler.h
T

54 lines
1.6 KiB
C++
Raw Normal View History

2021-11-26 17:43:02 +03:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SYSTEMTRAY_NOTIFICATIONHANDLER_H
#define SYSTEMTRAY_NOTIFICATIONHANDLER_H
#include "notificationhandler.h"
#include <QMenu>
#include <QSystemTrayIcon>
class SystemTrayNotificationHandler : public NotificationHandler {
2021-11-28 17:28:25 +03:00
Q_OBJECT
2021-11-26 17:43:02 +03:00
2021-11-28 17:28:25 +03:00
public:
explicit SystemTrayNotificationHandler(QObject* parent);
~SystemTrayNotificationHandler();
2021-11-26 17:43:02 +03:00
2023-05-14 21:11:19 +08:00
void setConnectionState(Vpn::ConnectionState state) override;
2021-11-26 17:43:02 +03:00
2023-10-06 13:43:32 +08:00
void onTranslationsUpdated() override;
2021-11-28 17:28:25 +03:00
protected:
virtual void notify(Message type, const QString& title,
const QString& message, int timerMsec) override;
2021-11-26 17:43:02 +03:00
2021-11-28 17:28:25 +03:00
private:
void showHideWindow();
2021-11-26 17:43:02 +03:00
2023-05-14 21:11:19 +08:00
void setTrayState(Vpn::ConnectionState state);
2021-11-28 17:28:25 +03:00
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
2021-11-26 17:43:02 +03:00
2021-11-28 17:28:25 +03:00
void setTrayIcon(const QString &iconPath);
2021-11-26 17:43:02 +03:00
2021-11-28 17:28:25 +03:00
private:
QMenu m_menu;
QSystemTrayIcon m_systemTrayIcon;
2023-10-06 13:43:32 +08:00
QAction* m_trayActionShow = nullptr;
2021-11-28 17:28:25 +03:00
QAction* m_trayActionConnect = nullptr;
QAction* m_trayActionDisconnect = nullptr;
2023-10-06 13:43:32 +08:00
QAction* m_trayActionVisitWebSite = nullptr;
QAction* m_trayActionQuit = nullptr;
2021-11-28 17:28:25 +03:00
QAction* m_statusLabel = nullptr;
QAction* m_separator = nullptr;
const QString ConnectedTrayIconName = "active.png";
const QString DisconnectedTrayIconName = "default.png";
const QString ErrorTrayIconName = "error.png";
2021-11-26 17:43:02 +03:00
};
#endif // SYSTEMTRAY_NOTIFICATIONHANDLER_H