mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-03 22:35:45 +02:00
systray: fix crash on linux
QSystemTray::setContextMenu isn't working using a QScopedPointer on GNU/Linux, don't know why, not investigating. Also, resetting the contextMenu has different behaviour on different platforms, so avoid that. Change-Id: I3464e4c5e410a2c7028555b8177e0e56f7c5d1c3
This commit is contained in:
parent
1d7d10a12d
commit
bb8f4cc3a7
2 changed files with 17 additions and 17 deletions
|
@ -371,8 +371,13 @@ MainApplication::initSystray()
|
|||
{
|
||||
systemTray_->setIcon(QIcon(":/images/jami.svg"));
|
||||
|
||||
// Create a new menu
|
||||
systemTrayMenu_.reset(new QMenu);
|
||||
QMenu* menu {nullptr};
|
||||
// If there was a previous menu, reuse it, otherwise create a new one.
|
||||
if ((menu = systemTray_->contextMenu())) {
|
||||
menu->clear();
|
||||
} else {
|
||||
menu = new QMenu;
|
||||
}
|
||||
|
||||
QString quitString;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
@ -381,10 +386,10 @@ MainApplication::initSystray()
|
|||
quitString = tr("&Quit");
|
||||
#endif
|
||||
|
||||
QAction* quitAction = new QAction(quitString, systemTrayMenu_.get());
|
||||
QAction* quitAction = new QAction(quitString, this);
|
||||
connect(quitAction, &QAction::triggered, this, &MainApplication::closeRequested);
|
||||
|
||||
QAction* restoreAction = new QAction(tr("&Show Jami"), systemTrayMenu_.get());
|
||||
QAction* restoreAction = new QAction(tr("&Show Jami"), this);
|
||||
connect(restoreAction, &QAction::triggered, this, &MainApplication::restoreApp);
|
||||
|
||||
connect(systemTray_,
|
||||
|
@ -395,20 +400,18 @@ 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
|
||||
}
|
||||
});
|
||||
|
||||
systemTrayMenu_->addAction(restoreAction);
|
||||
systemTrayMenu_->addAction(quitAction);
|
||||
|
||||
// Set the new menu as the context menu
|
||||
systemTray_->setContextMenu(systemTrayMenu_.get());
|
||||
menu->addAction(restoreAction);
|
||||
menu->addAction(quitAction);
|
||||
systemTray_->setContextMenu(menu);
|
||||
|
||||
systemTray_->show();
|
||||
}
|
||||
|
|
|
@ -124,8 +124,5 @@ private:
|
|||
|
||||
ScreenInfo screenInfo_;
|
||||
|
||||
// We will recreate the system tray menu when the user changes the language.
|
||||
QScopedPointer<QMenu> systemTrayMenu_;
|
||||
|
||||
bool isCleanupped;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue