mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Merge 4568f4b501 into b1fe4c85d3
This commit is contained in:
commit
383fd0365f
3 changed files with 37 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ protected:
|
|||
QBrush loadExtraBrush(QString fileName, QBrush &fallbackBrush);
|
||||
|
||||
public:
|
||||
bool isBuiltInTheme();
|
||||
bool isDarkMode();
|
||||
QStringMap &getAvailableThemes();
|
||||
|
||||
QBrush &getBgBrush(Role zone);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue