Fix invisible tray icon on Plasma 6 in Linux

PR #20529.
Closes #20367.

---------

Co-authored-by: thalieht <thalieht@users.noreply.github.com>
Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This commit is contained in:
tehcneko 2024-03-13 15:24:08 +08:00 committed by GitHub
parent d5e41bf679
commit 50caa231f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,7 @@
#include <chrono>
#include <QtEnvironmentVariables>
#include <QMenu>
#include <QTimer>
@ -283,17 +284,25 @@ void DesktopIntegration::createTrayIcon()
QIcon DesktopIntegration::getSystrayIcon() const
{
const TrayIcon::Style style = Preferences::instance()->trayIconStyle();
QIcon icon;
switch (style)
{
default:
case TrayIcon::Style::Normal:
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray"_s);
icon = UIThemeManager::instance()->getIcon(u"qbittorrent-tray"_s);
break;
case TrayIcon::Style::MonoDark:
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray-dark"_s);
icon = UIThemeManager::instance()->getIcon(u"qbittorrent-tray-dark"_s);
break;
case TrayIcon::Style::MonoLight:
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray-light"_s);
icon = UIThemeManager::instance()->getIcon(u"qbittorrent-tray-light"_s);
break;
}
#ifdef Q_OS_UNIX
// Workaround for invisible tray icon in KDE, https://bugreports.qt.io/browse/QTBUG-53550
if (qEnvironmentVariable("XDG_CURRENT_DESKTOP").compare(u"KDE", Qt::CaseInsensitive) == 0)
return icon.pixmap(32);
#endif
return icon;
}
#endif // Q_OS_MACOS