Skip to content
Snippets Groups Projects
Commit 1d7d10a1 authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

mainapplication: retranslate systray

Change-Id: Ib8e7407fa702f4003b33b688fa0dca517ff9a7fd
GitLab: #1396
parent c6899974
No related branches found
No related tags found
No related merge requests found
......@@ -105,7 +105,8 @@ ScreenInfo::onPhysicalDotsPerInchChanged()
}
MainApplication::MainApplication(int& argc, char** argv)
: QApplication(argc, argv), isCleanupped(false)
: QApplication(argc, argv)
, isCleanupped(false)
{
const char* qtVersion = qVersion();
qInfo() << "Using Qt runtime version:" << qtVersion;
......@@ -134,10 +135,19 @@ MainApplication::init()
settingsManager_ = new AppSettingsManager(this);
systemTray_ = new SystemTray(settingsManager_, this);
// These should should be QueuedConnection to ensure that the
// they are executed after the QML engine has been initialized,
// and after the QSystemTrayIcon has been created and shown.
QObject::connect(settingsManager_,
&AppSettingsManager::retranslate,
engine_.get(),
&QQmlApplicationEngine::retranslate);
&QQmlApplicationEngine::retranslate,
Qt::QueuedConnection);
QObject::connect(settingsManager_,
&AppSettingsManager::retranslate,
this,
&MainApplication::initSystray,
Qt::QueuedConnection);
setWindowIcon(QIcon(":/images/jami.ico"));
......@@ -361,7 +371,8 @@ MainApplication::initSystray()
{
systemTray_->setIcon(QIcon(":/images/jami.svg"));
QMenu* systrayMenu = new QMenu();
// Create a new menu
systemTrayMenu_.reset(new QMenu);
QString quitString;
#ifdef Q_OS_WINDOWS
......@@ -370,10 +381,10 @@ MainApplication::initSystray()
quitString = tr("&Quit");
#endif
QAction* quitAction = new QAction(quitString, this);
QAction* quitAction = new QAction(quitString, systemTrayMenu_.get());
connect(quitAction, &QAction::triggered, this, &MainApplication::closeRequested);
QAction* restoreAction = new QAction(tr("&Show Jami"), this);
QAction* restoreAction = new QAction(tr("&Show Jami"), systemTrayMenu_.get());
connect(restoreAction, &QAction::triggered, this, &MainApplication::restoreApp);
connect(systemTray_,
......@@ -384,18 +395,21 @@ MainApplication::initSystray()
#ifdef Q_OS_WINDOWS
restoreApp();
#elif !defined(Q_OS_MACOS)
QWindow* window = focusWindow();
if (window)
window->close();
else
restoreApp();
QWindow* window = focusWindow();
if (window)
window->close();
else
restoreApp();
#endif
}
});
systrayMenu->addAction(restoreAction);
systrayMenu->addAction(quitAction);
systemTray_->setContextMenu(systrayMenu);
systemTrayMenu_->addAction(restoreAction);
systemTrayMenu_->addAction(quitAction);
// Set the new menu as the context menu
systemTray_->setContextMenu(systemTrayMenu_.get());
systemTray_->show();
}
......
......@@ -124,5 +124,8 @@ private:
ScreenInfo screenInfo_;
// We will recreate the system tray menu when the user changes the language.
QScopedPointer<QMenu> systemTrayMenu_;
bool isCleanupped;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment