diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index 01b37229..801b90b4 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -139,6 +139,7 @@ void AmneziaApplication::init() &ConnectionController::openConnection); connect(m_notificationHandler.get(), &NotificationHandler::disconnectRequested, m_connectionController.get(), &ConnectionController::closeConnection); + connect(this, &AmneziaApplication::translationsUpdated, m_notificationHandler.get(), &NotificationHandler::onTranslationsUpdated); m_engine->load(url); m_systemController->setQmlRoot(m_engine->rootObjects().value(0)); diff --git a/client/ui/notificationhandler.cpp b/client/ui/notificationhandler.cpp index f932eb17..1f81c2c2 100644 --- a/client/ui/notificationhandler.cpp +++ b/client/ui/notificationhandler.cpp @@ -88,6 +88,10 @@ void NotificationHandler::setConnectionState(Vpn::ConnectionState state) } } +void NotificationHandler::onTranslationsUpdated() +{ +} + void NotificationHandler::unsecuredNetworkNotification(const QString& networkName) { qDebug() << "Unsecured network notification shown"; diff --git a/client/ui/notificationhandler.h b/client/ui/notificationhandler.h index 9a2182de..abdce27b 100644 --- a/client/ui/notificationhandler.h +++ b/client/ui/notificationhandler.h @@ -32,6 +32,7 @@ public: public slots: virtual void setConnectionState(Vpn::ConnectionState state); + virtual void onTranslationsUpdated(); signals: void notificationShown(const QString& title, const QString& message); diff --git a/client/ui/systemtray_notificationhandler.cpp b/client/ui/systemtray_notificationhandler.cpp index 6adc8818..2c7c695f 100644 --- a/client/ui/systemtray_notificationhandler.cpp +++ b/client/ui/systemtray_notificationhandler.cpp @@ -17,7 +17,6 @@ #include "version.h" - SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) : NotificationHandler(parent), m_systemTrayIcon(parent) @@ -26,8 +25,7 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) : m_systemTrayIcon.show(); connect(&m_systemTrayIcon, &QSystemTrayIcon::activated, this, &SystemTrayNotificationHandler::onTrayActivated); - - m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){ + m_trayActionShow = m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){ emit raiseRequested(); }); m_menu.addSeparator(); @@ -36,11 +34,11 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) : m_menu.addSeparator(); - m_menu.addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){ + m_trayActionVisitWebSite = m_menu.addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){ QDesktopServices::openUrl(QUrl("https://amnezia.org")); }); - m_menu.addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){ + m_trayActionQuit = m_menu.addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){ qApp->quit(); }); @@ -57,6 +55,15 @@ void SystemTrayNotificationHandler::setConnectionState(Vpn::ConnectionState stat NotificationHandler::setConnectionState(state); } +void SystemTrayNotificationHandler::onTranslationsUpdated() +{ + m_trayActionShow->setText(tr("Show") + " " + APPLICATION_NAME); + m_trayActionConnect->setText(tr("Connect")); + m_trayActionDisconnect->setText(tr("Disconnect")); + m_trayActionVisitWebSite->setText(tr("Visit Website")); + m_trayActionQuit->setText(tr("Quit")+ " " + APPLICATION_NAME); +} + void SystemTrayNotificationHandler::setTrayIcon(const QString &iconPath) { QIcon trayIconMask(QPixmap(iconPath).scaled(128,128)); diff --git a/client/ui/systemtray_notificationhandler.h b/client/ui/systemtray_notificationhandler.h index 96134f14..60bf0b35 100644 --- a/client/ui/systemtray_notificationhandler.h +++ b/client/ui/systemtray_notificationhandler.h @@ -19,6 +19,8 @@ public: void setConnectionState(Vpn::ConnectionState state) override; + void onTranslationsUpdated() override; + protected: virtual void notify(Message type, const QString& title, const QString& message, int timerMsec) override; @@ -35,9 +37,11 @@ private: QMenu m_menu; QSystemTrayIcon m_systemTrayIcon; + QAction* m_trayActionShow = nullptr; QAction* m_trayActionConnect = nullptr; QAction* m_trayActionDisconnect = nullptr; - QAction* m_preferencesAction = nullptr; + QAction* m_trayActionVisitWebSite = nullptr; + QAction* m_trayActionQuit = nullptr; QAction* m_statusLabel = nullptr; QAction* m_separator = nullptr;