Revamp system tray icon menu handling

Update system tray icon menu without re-create it.

PR #20597.
Closes #20516.
This commit is contained in:
Vladimir Golovnev 2024-03-26 15:24:43 +03:00 committed by GitHub
parent 489bacd766
commit 5e8b9df859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 82 deletions

View file

@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@ -832,7 +832,7 @@ int Application::exec()
m_desktopIntegration = new DesktopIntegration;
m_desktopIntegration->setToolTip(tr("Loading torrents..."));
#ifndef Q_OS_MACOS
auto *desktopIntegrationMenu = new QMenu;
auto *desktopIntegrationMenu = m_desktopIntegration->menu();
auto *actionExit = new QAction(tr("E&xit"), desktopIntegrationMenu);
actionExit->setIcon(UIThemeManager::instance()->getIcon(u"application-exit"_s));
actionExit->setMenuRole(QAction::QuitRole);
@ -843,8 +843,6 @@ int Application::exec()
});
desktopIntegrationMenu->addAction(actionExit);
m_desktopIntegration->setMenu(desktopIntegrationMenu);
const bool isHidden = m_desktopIntegration->isActive() && (startUpWindowState() == WindowState::Hidden);
#else
const bool isHidden = false;