diff --git a/resources/scripts/github-actions/build-windows.ps1 b/resources/scripts/github-actions/build-windows.ps1 index 553b87f57..14c0bc938 100755 --- a/resources/scripts/github-actions/build-windows.ps1 +++ b/resources/scripts/github-actions/build-windows.ps1 @@ -24,7 +24,7 @@ if ($use_qt5 -eq "ON") { $qt_version = "5.15.2" } else { - $qt_version = "6.5.0" + $qt_version = "6.4.3" } $maria_version = "10.6.12" diff --git a/src/librssguard/miscellaneous/skinfactory.cpp b/src/librssguard/miscellaneous/skinfactory.cpp index 34c54dc58..2c2778265 100644 --- a/src/librssguard/miscellaneous/skinfactory.cpp +++ b/src/librssguard/miscellaneous/skinfactory.cpp @@ -48,12 +48,67 @@ void SkinFactory::loadCurrentSkin() { } bool SkinFactory::isStyleGoodForAlternativeStylePalette(const QString& style_name) const { - static QRegularExpression re = QRegularExpression("^(fusion|windows|qt[56]ct-style)$"); + static QRegularExpression re = QRegularExpression(QSL("^(fusion|windows|qt[56]ct-style)$")); return re.match(style_name.toLower()).hasMatch(); } +// NOTE: Taken from "QPlatformThemePrivate" Qt class. +// This is here because in Qt 6.5.0, they hardcoded +// DARK palette if user has enabled "dark mode" in OS. +QPalette qt_fusionPalette(bool darkAppearance) { + const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black; + const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239); + const QColor light = backGround.lighter(150); + const QColor mid = (backGround.darker(130)); + const QColor midLight = mid.lighter(110); + const QColor base = darkAppearance ? backGround.darker(140) : Qt::white; + const QColor disabledBase(backGround); + const QColor dark = backGround.darker(150); + const QColor darkDisabled = QColor(209, 209, 209).darker(110); + const QColor text = darkAppearance ? windowText : Qt::black; + const QColor highlight = QColor(48, 140, 198); + const QColor hightlightedText = darkAppearance ? windowText : Qt::white; + const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190); + const QColor button = backGround; + const QColor shadow = dark.darker(135); + const QColor disabledShadow = shadow.lighter(150); + QColor placeholder = text; + placeholder.setAlpha(128); + + QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base); + fusionPalette.setBrush(QPalette::Midlight, midLight); + fusionPalette.setBrush(QPalette::Button, button); + fusionPalette.setBrush(QPalette::Shadow, shadow); + fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText); + + fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); + + fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight); + fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight); + fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145)); + + fusionPalette.setBrush(QPalette::PlaceholderText, placeholder); + + if (darkAppearance) { + fusionPalette.setBrush(QPalette::Link, highlight); + } + + return fusionPalette; +} + void SkinFactory::loadSkinFromData(const Skin& skin) { +#if QT_VERSION >= 0x060500 // Qt >= 6.5.0 + auto system_color_scheme = qApp->styleHints()->colorScheme(); + + qDebugNN << LOGSEC_GUI << "OS defines color scheme:" << QUOTE_W_SPACE_DOT(system_color_scheme); +#endif + QString style_name = qApp->settings()->value(GROUP(GUI), SETTING(GUI::Style)).toString(); auto env = QProcessEnvironment::systemEnvironment(); const QString env_forced_style = env.value(QSL("QT_STYLE_OVERRIDE")); @@ -123,6 +178,14 @@ void SkinFactory::loadSkinFromData(const Skin& skin) { QToolTip::setPalette(pal); qApp->setPalette(pal); } + // NOTE: Very hacky way of avoiding automatic "dark mode" + // palettes in some styles. Also in light mode, + // colors are now derived from system. +#if QT_VERSION >= 0x060500 // Qt >= 6.5.0 + else /* if (qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark) */ { + qApp->setPalette(qt_fusionPalette(false)); + } +#endif if (!skin.m_rawData.isEmpty()) { if (qApp->styleSheet().simplified().isEmpty() && use_skin_colors) {