mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
parent
8bcac1bed2
commit
77bd09bb8b
@ -38,7 +38,6 @@
|
|||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "base/logger.h"
|
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "uithememanager.h"
|
#include "uithememanager.h"
|
||||||
|
|
||||||
@ -243,7 +242,7 @@ void DesktopIntegration::onPreferencesChanged()
|
|||||||
if (m_systrayIcon)
|
if (m_systrayIcon)
|
||||||
{
|
{
|
||||||
// Reload systray icon
|
// Reload systray icon
|
||||||
m_systrayIcon->setIcon(UIThemeManager::instance()->getSystrayIcon());
|
m_systrayIcon->setIcon(getSystrayIcon());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -264,7 +263,7 @@ void DesktopIntegration::createTrayIcon()
|
|||||||
{
|
{
|
||||||
Q_ASSERT(!m_systrayIcon);
|
Q_ASSERT(!m_systrayIcon);
|
||||||
|
|
||||||
m_systrayIcon = new QSystemTrayIcon(UIThemeManager::instance()->getSystrayIcon(), this);
|
m_systrayIcon = new QSystemTrayIcon(getSystrayIcon(), this);
|
||||||
|
|
||||||
m_systrayIcon->setToolTip(m_toolTip);
|
m_systrayIcon->setToolTip(m_toolTip);
|
||||||
|
|
||||||
@ -284,4 +283,21 @@ void DesktopIntegration::createTrayIcon()
|
|||||||
m_systrayIcon->show();
|
m_systrayIcon->show();
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon DesktopIntegration::getSystrayIcon() const
|
||||||
|
{
|
||||||
|
const TrayIcon::Style style = Preferences::instance()->trayIconStyle();
|
||||||
|
switch (style)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case TrayIcon::Style::Normal:
|
||||||
|
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray"_qs);
|
||||||
|
|
||||||
|
case TrayIcon::Style::MonoDark:
|
||||||
|
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray-dark"_qs);
|
||||||
|
|
||||||
|
case TrayIcon::Style::MonoLight:
|
||||||
|
return UIThemeManager::instance()->getIcon(u"qbittorrent-tray-light"_qs);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
|
@ -78,6 +78,7 @@ private:
|
|||||||
void onPreferencesChanged();
|
void onPreferencesChanged();
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
|
QIcon getSystrayIcon() const;
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
|
|
||||||
CachedSettingValue<bool> m_storeNotificationEnabled;
|
CachedSettingValue<bool> m_storeNotificationEnabled;
|
||||||
|
@ -121,7 +121,7 @@ QIcon UIThemeManager::getIcon(const QString &iconId, [[maybe_unused]] const QStr
|
|||||||
if (m_useSystemIcons)
|
if (m_useSystemIcons)
|
||||||
{
|
{
|
||||||
auto icon = QIcon::fromTheme(iconId);
|
auto icon = QIcon::fromTheme(iconId);
|
||||||
if (icon.name() != iconId)
|
if (icon.isNull() || icon.availableSizes().isEmpty())
|
||||||
icon = QIcon::fromTheme(fallback, QIcon(m_themeSource->getIconPath(iconId, colorMode).data()));
|
icon = QIcon::fromTheme(fallback, QIcon(m_themeSource->getIconPath(iconId, colorMode).data()));
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
@ -174,36 +174,6 @@ QColor UIThemeManager::getColor(const QString &id) const
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
|
||||||
QIcon UIThemeManager::getSystrayIcon() const
|
|
||||||
{
|
|
||||||
const TrayIcon::Style style = Preferences::instance()->trayIconStyle();
|
|
||||||
switch (style)
|
|
||||||
{
|
|
||||||
#if defined(Q_OS_UNIX)
|
|
||||||
case TrayIcon::Style::Normal:
|
|
||||||
return QIcon::fromTheme(u"qbittorrent-tray"_qs);
|
|
||||||
case TrayIcon::Style::MonoDark:
|
|
||||||
return QIcon::fromTheme(u"qbittorrent-tray-dark"_qs);
|
|
||||||
case TrayIcon::Style::MonoLight:
|
|
||||||
return QIcon::fromTheme(u"qbittorrent-tray-light"_qs);
|
|
||||||
#else
|
|
||||||
case TrayIcon::Style::Normal:
|
|
||||||
return getIcon(u"qbittorrent-tray"_qs);
|
|
||||||
case TrayIcon::Style::MonoDark:
|
|
||||||
return getIcon(u"qbittorrent-tray-dark"_qs);
|
|
||||||
case TrayIcon::Style::MonoLight:
|
|
||||||
return getIcon(u"qbittorrent-tray-light"_qs);
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// As a failsafe in case the enum is invalid
|
|
||||||
return getIcon(u"qbittorrent-tray"_qs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void UIThemeManager::applyPalette() const
|
void UIThemeManager::applyPalette() const
|
||||||
{
|
{
|
||||||
struct ColorDescriptor
|
struct ColorDescriptor
|
||||||
|
@ -57,10 +57,6 @@ public:
|
|||||||
|
|
||||||
QColor getColor(const QString &id) const;
|
QColor getColor(const QString &id) const;
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
|
||||||
QIcon getSystrayIcon() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UIThemeManager(); // singleton class
|
UIThemeManager(); // singleton class
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user