This commit is contained in:
BruebachL 2026-04-25 10:01:48 -03:00 committed by GitHub
commit 383fd0365f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 1 deletions

View file

@ -112,6 +112,39 @@ void ThemeManager::ensureThemeDirectoryExists()
}
}
bool ThemeManager::isDarkMode()
{
auto themeName = SettingsCache::instance().getThemeName();
// Explicit Dark Mode
if (themeName == FUSION_THEME_NAME_LIGHT || themeName.endsWith("(Light)")) {
return false;
}
// Explicit Light Mode
if (themeName == FUSION_THEME_NAME_DARK || themeName.endsWith("(Dark)")) {
return true;
}
// Auto detection on compatible Qt versions
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark &&
(themeName == NONE_THEME_NAME || themeName == FUSION_THEME_NAME || themeName.endsWith("(System Default)"))) {
return true;
} else {
return false;
}
#endif
// Default to light mode
return false;
}
bool ThemeManager::isBuiltInTheme()
{
const auto themeName = SettingsCache::instance().getThemeName();
return themeName == NONE_THEME_NAME || themeName == FUSION_THEME_NAME || themeName == FUSION_THEME_NAME_LIGHT ||
themeName == FUSION_THEME_NAME_DARK;
}
QStringMap &ThemeManager::getAvailableThemes()
{
QDir dir;

View file

@ -54,6 +54,8 @@ protected:
QBrush loadExtraBrush(QString fileName, QBrush &fallbackBrush);
public:
bool isBuiltInTheme();
bool isDarkMode();
QStringMap &getAvailableThemes();
QBrush &getBgBrush(Role zone);

View file

@ -2,6 +2,7 @@
#include "../../../client/settings/cache_settings.h"
#include "../../../interface/widgets/tabs/tab_supervisor.h"
#include "../../theme_manager.h"
#include "../../window_main.h"
#include "background_sources.h"
#include "home_styled_button.h"
@ -256,7 +257,7 @@ void HomeWidget::updateConnectButton(const ClientStatus status)
QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap)
{
if (SettingsCache::instance().getThemeName() == "Default" &&
if (themeManager->isBuiltInTheme() &&
SettingsCache::instance().getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) {
return QPair<QColor, QColor>(QColor::fromRgb(20, 140, 60), QColor::fromRgb(120, 200, 80));
}