mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 03:28:41 -07:00
parent
25b7972f88
commit
ce013f132f
11 changed files with 195 additions and 126 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "uithememanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QPixmapCache>
|
||||
#include <QResource>
|
||||
|
@ -79,11 +80,8 @@ UIThemeManager::UIThemeManager()
|
|||
, m_useSystemIcons {Preferences::instance()->useSystemIcons()}
|
||||
#endif
|
||||
{
|
||||
connect(QApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, []
|
||||
{
|
||||
// workaround to refresh styled controls once color scheme is changed
|
||||
QApplication::setStyle(QApplication::style()->name());
|
||||
});
|
||||
// NOTE: Qt::QueuedConnection can be omitted as soon as support for Qt 6.5 is dropped
|
||||
connect(QApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, &UIThemeManager::onColorSchemeChanged, Qt::QueuedConnection);
|
||||
|
||||
if (m_useCustomTheme)
|
||||
{
|
||||
|
@ -122,6 +120,14 @@ void UIThemeManager::applyStyleSheet() const
|
|||
qApp->setStyleSheet(QString::fromUtf8(m_themeSource->readStyleSheet()));
|
||||
}
|
||||
|
||||
void UIThemeManager::onColorSchemeChanged()
|
||||
{
|
||||
emit themeChanged();
|
||||
|
||||
// workaround to refresh styled controls once color scheme is changed
|
||||
QApplication::setStyle(QApplication::style()->name());
|
||||
}
|
||||
|
||||
QIcon UIThemeManager::getIcon(const QString &iconId, [[maybe_unused]] const QString &fallback) const
|
||||
{
|
||||
const auto colorMode = isDarkTheme() ? ColorMode::Dark : ColorMode::Light;
|
||||
|
@ -184,8 +190,6 @@ QPixmap UIThemeManager::getScaledPixmap(const QString &iconId, const int height)
|
|||
QColor UIThemeManager::getColor(const QString &id) const
|
||||
{
|
||||
const QColor color = m_themeSource->getColor(id, (isDarkTheme() ? ColorMode::Dark : ColorMode::Light));
|
||||
Q_ASSERT(color.isValid());
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue