applied translation-funcation to SystemTray
This commit is contained in:
parent
1eafa9a38a
commit
1357c4a309
5 changed files with 23 additions and 6 deletions
|
|
@ -139,6 +139,7 @@ void AmneziaApplication::init()
|
||||||
&ConnectionController::openConnection);
|
&ConnectionController::openConnection);
|
||||||
connect(m_notificationHandler.get(), &NotificationHandler::disconnectRequested, m_connectionController.get(),
|
connect(m_notificationHandler.get(), &NotificationHandler::disconnectRequested, m_connectionController.get(),
|
||||||
&ConnectionController::closeConnection);
|
&ConnectionController::closeConnection);
|
||||||
|
connect(this, &AmneziaApplication::translationsUpdated, m_notificationHandler.get(), &NotificationHandler::onTranslationsUpdated);
|
||||||
|
|
||||||
m_engine->load(url);
|
m_engine->load(url);
|
||||||
m_systemController->setQmlRoot(m_engine->rootObjects().value(0));
|
m_systemController->setQmlRoot(m_engine->rootObjects().value(0));
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,10 @@ void NotificationHandler::setConnectionState(Vpn::ConnectionState state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationHandler::onTranslationsUpdated()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void NotificationHandler::unsecuredNetworkNotification(const QString& networkName) {
|
void NotificationHandler::unsecuredNetworkNotification(const QString& networkName) {
|
||||||
qDebug() << "Unsecured network notification shown";
|
qDebug() << "Unsecured network notification shown";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setConnectionState(Vpn::ConnectionState state);
|
virtual void setConnectionState(Vpn::ConnectionState state);
|
||||||
|
virtual void onTranslationsUpdated();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notificationShown(const QString& title, const QString& message);
|
void notificationShown(const QString& title, const QString& message);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
||||||
NotificationHandler(parent),
|
NotificationHandler(parent),
|
||||||
m_systemTrayIcon(parent)
|
m_systemTrayIcon(parent)
|
||||||
|
|
@ -26,8 +25,7 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
||||||
m_systemTrayIcon.show();
|
m_systemTrayIcon.show();
|
||||||
connect(&m_systemTrayIcon, &QSystemTrayIcon::activated, this, &SystemTrayNotificationHandler::onTrayActivated);
|
connect(&m_systemTrayIcon, &QSystemTrayIcon::activated, this, &SystemTrayNotificationHandler::onTrayActivated);
|
||||||
|
|
||||||
|
m_trayActionShow = m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){
|
||||||
m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){
|
|
||||||
emit raiseRequested();
|
emit raiseRequested();
|
||||||
});
|
});
|
||||||
m_menu.addSeparator();
|
m_menu.addSeparator();
|
||||||
|
|
@ -36,11 +34,11 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
||||||
|
|
||||||
m_menu.addSeparator();
|
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"));
|
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();
|
qApp->quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -57,6 +55,15 @@ void SystemTrayNotificationHandler::setConnectionState(Vpn::ConnectionState stat
|
||||||
NotificationHandler::setConnectionState(state);
|
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)
|
void SystemTrayNotificationHandler::setTrayIcon(const QString &iconPath)
|
||||||
{
|
{
|
||||||
QIcon trayIconMask(QPixmap(iconPath).scaled(128,128));
|
QIcon trayIconMask(QPixmap(iconPath).scaled(128,128));
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ public:
|
||||||
|
|
||||||
void setConnectionState(Vpn::ConnectionState state) override;
|
void setConnectionState(Vpn::ConnectionState state) override;
|
||||||
|
|
||||||
|
void onTranslationsUpdated() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void notify(Message type, const QString& title,
|
virtual void notify(Message type, const QString& title,
|
||||||
const QString& message, int timerMsec) override;
|
const QString& message, int timerMsec) override;
|
||||||
|
|
@ -35,9 +37,11 @@ private:
|
||||||
QMenu m_menu;
|
QMenu m_menu;
|
||||||
QSystemTrayIcon m_systemTrayIcon;
|
QSystemTrayIcon m_systemTrayIcon;
|
||||||
|
|
||||||
|
QAction* m_trayActionShow = nullptr;
|
||||||
QAction* m_trayActionConnect = nullptr;
|
QAction* m_trayActionConnect = nullptr;
|
||||||
QAction* m_trayActionDisconnect = nullptr;
|
QAction* m_trayActionDisconnect = nullptr;
|
||||||
QAction* m_preferencesAction = nullptr;
|
QAction* m_trayActionVisitWebSite = nullptr;
|
||||||
|
QAction* m_trayActionQuit = nullptr;
|
||||||
QAction* m_statusLabel = nullptr;
|
QAction* m_statusLabel = nullptr;
|
||||||
QAction* m_separator = nullptr;
|
QAction* m_separator = nullptr;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue