mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Utility method to check if a theme is supposed to be in dark or light mode.
Took 22 minutes Took 4 seconds
This commit is contained in:
parent
d7b31f2f9d
commit
36b4eac829
2 changed files with 26 additions and 0 deletions
|
|
@ -108,6 +108,31 @@ 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;
|
||||
}
|
||||
|
||||
QStringMap &ThemeManager::getAvailableThemes()
|
||||
{
|
||||
QDir dir;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ private:
|
|||
|
||||
protected:
|
||||
void ensureThemeDirectoryExists();
|
||||
bool isDarkMode();
|
||||
QBrush loadBrush(QString fileName, QColor fallbackColor);
|
||||
QBrush loadExtraBrush(QString fileName, QBrush &fallbackBrush);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue