Allow to choose Qt style

PR #21553.
This commit is contained in:
Vladimir Golovnev 2024-10-11 16:04:57 +03:00 committed by GitHub
parent 2d857b6200
commit 2d185dc1c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 106 additions and 28 deletions

View file

@ -37,6 +37,10 @@
#include <QStyle>
#include <QStyleHints>
#ifdef Q_OS_WIN
#include <QOperatingSystemVersion>
#endif
#include "base/global.h"
#include "base/logger.h"
#include "base/path.h"
@ -80,6 +84,12 @@ UIThemeManager::UIThemeManager()
, m_useSystemIcons {Preferences::instance()->useSystemIcons()}
#endif
{
#ifdef Q_OS_WIN
const QString defaultStyle = (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) ? u"Fusion"_s : QString();
if (const QString styleName = Preferences::instance()->getStyle(); !QApplication::setStyle(styleName.isEmpty() ? defaultStyle : styleName))
LogMsg(tr("Set app style failed. Unknown style: \"%1\"").arg(styleName), Log::WARNING);
#endif
// NOTE: Qt::QueuedConnection can be omitted as soon as support for Qt 6.5 is dropped
connect(QApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, &UIThemeManager::onColorSchemeChanged, Qt::QueuedConnection);