DolphinQt: Auto-load embedded dark theme on Windows if the user uses a system-wide dark theme.

This commit is contained in:
Admiral H. Curtiss 2023-07-31 00:35:48 +02:00
parent ea30651cd7
commit adbe56ce15
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 16 additions and 0 deletions

View File

@ -153,6 +153,22 @@ void Settings::SetCurrentUserStyle(const QString& stylesheet_name)
stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data());
}
#ifdef _WIN32
if (stylesheet_contents.isEmpty())
{
// No theme selected or found. Usually we would just fallthrough and set an empty stylesheet
// which would select Qt's default theme, but unlike other OSes we don't automatically get a
// default dark theme on Windows when the user has selected dark mode in the Windows settings.
// So manually check if the user wants dark mode and, if yes, load our embedded dark theme.
if (IsSystemDark())
{
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
if (file.open(QFile::ReadOnly))
stylesheet_contents = QString::fromUtf8(file.readAll().data());
}
}
#endif
// Define tooltips style if not already defined
if (!stylesheet_contents.contains(QStringLiteral("QToolTip"), Qt::CaseSensitive))
{