Switch to classic if theme set to auto and high contast mode is on.

The light and dark theme don't respond to Windows's high contrast
accessibility mode, so when the theme is set to "auto", we
default to "classic" instead of "light".

Fixes #5044
This commit is contained in:
Janek Bevendorff 2020-07-28 19:43:32 +02:00 committed by Jonathan White
parent 0070d5f295
commit a32147182a
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
3 changed files with 12 additions and 0 deletions

View File

@ -147,6 +147,11 @@ void Application::applyTheme()
auto appTheme = config()->get(Config::GUI_ApplicationTheme).toString();
if (appTheme == "auto") {
appTheme = osUtils->isDarkMode() ? "dark" : "light";
#ifdef Q_OS_WIN
if (winUtils()->isHighContrastMode()) {
appTheme = "classic";
}
#endif
}
if (appTheme == "light") {

View File

@ -105,3 +105,9 @@ bool WinUtils::isCapslockEnabled()
{
return GetKeyState(VK_CAPITAL) == 1;
}
bool WinUtils::isHighContrastMode() const
{
QSettings settings(R"(HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast)", QSettings::NativeFormat);
return (settings.value("Flags").toInt() & 1u) != 0;
}

View File

@ -36,6 +36,7 @@ public:
bool isLaunchAtStartupEnabled() const override;
void setLaunchAtStartup(bool enable) override;
bool isCapslockEnabled() override;
bool isHighContrastMode() const;
protected:
explicit WinUtils(QObject* parent = nullptr);