added signal-slot connection between corecontroller and systemtraynofificationhandler updating websiteurl

This commit is contained in:
Mitternacht822 2025-07-02 17:47:09 +04:00
parent 979ab42c5a
commit 95d48d8a2d
4 changed files with 19 additions and 1 deletions

View file

@ -243,6 +243,9 @@ void CoreController::initNotificationHandler()
&ConnectionController::closeConnection);
connect(this, &CoreController::translationsUpdated, m_notificationHandler.get(), &NotificationHandler::onTranslationsUpdated);
#endif
auto* trayHandler = qobject_cast<SystemTrayNotificationHandler*>(m_notificationHandler.get());
connect(this, &CoreController::websiteUrlChanged, trayHandler, &SystemTrayNotificationHandler::updateWebsiteUrl);
}
void CoreController::updateTranslator(const QLocale &locale)
@ -279,6 +282,7 @@ void CoreController::updateTranslator(const QLocale &locale)
m_engine->retranslate();
emit translationsUpdated();
emit websiteUrlChanged(m_languageModel->getCurrentSiteUrl());
}
void CoreController::initErrorMessagesHandler()
@ -335,6 +339,8 @@ void CoreController::initTranslationsUpdatedHandler()
connect(m_languageModel.get(), &LanguageModel::updateTranslations, this, &CoreController::updateTranslator);
connect(this, &CoreController::translationsUpdated, m_languageModel.get(), &LanguageModel::translationsUpdated);
connect(this, &CoreController::translationsUpdated, m_connectionController.get(), &ConnectionController::onTranslationsUpdated);
//auto* trayHandler = qobject_cast<SystemTrayNotificationHandler*>(m_notificationHandler.get());
//connect(this, &CoreController::websiteUrlChanged, trayHandler, &SystemTrayNotificationHandler::updateWebsiteUrl);
}
void CoreController::initAutoConnectHandler()

View file

@ -5,6 +5,8 @@
#include <QQmlContext>
#include <QThread>
#include "ui/systemtray_notificationhandler.h"
#include "ui/controllers/api/apiConfigsController.h"
#include "ui/controllers/api/apiSettingsController.h"
#include "ui/controllers/api/apiPremV1MigrationController.h"
@ -61,6 +63,7 @@ public:
signals:
void translationsUpdated();
void websiteUrlChanged(const QString &newUrl);
private:
void initModels();

View file

@ -35,7 +35,7 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
m_menu.addSeparator();
m_trayActionVisitWebSite = m_menu.addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){
QDesktopServices::openUrl(QUrl("https://amnezia.org"));
QDesktopServices::openUrl(QUrl(websiteUrl));
});
m_trayActionQuit = m_menu.addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){
@ -64,6 +64,11 @@ void SystemTrayNotificationHandler::onTranslationsUpdated()
m_trayActionQuit->setText(tr("Quit")+ " " + APPLICATION_NAME);
}
void SystemTrayNotificationHandler::updateWebsiteUrl(const QString &newWebsiteUrl) {
qDebug() << "Updated website URL:" << newWebsiteUrl;
websiteUrl = newWebsiteUrl;
}
void SystemTrayNotificationHandler::setTrayIcon(const QString &iconPath)
{
QIcon trayIconMask(QPixmap(iconPath).scaled(128,128));

View file

@ -21,6 +21,9 @@ public:
void onTranslationsUpdated() override;
public slots:
void updateWebsiteUrl(const QString &newWebsiteUrl);
protected:
virtual void notify(Message type, const QString& title,
const QString& message, int timerMsec) override;
@ -48,6 +51,7 @@ private:
const QString ConnectedTrayIconName = "active.png";
const QString DisconnectedTrayIconName = "default.png";
const QString ErrorTrayIconName = "error.png";
QString websiteUrl = "https://amnezia.org";
};
#endif // SYSTEMTRAY_NOTIFICATIONHANDLER_H