From 4d84d1d4facfe4b6f7332c29e301f4b69dafdf85 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 13 Sep 2022 19:21:39 +0200 Subject: [PATCH] Do not query an unexisting kconfig file Only check the colors forced by the application in case they are specified. --- CMakeLists.txt | 3 +++ kstyle/breezehelper.cpp | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 840ed0b8..b6879b05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,9 @@ include(FeatureSummary) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + include(CMakePackageConfigHelpers) include(ECMInstallIcons) include(KDEInstallDirs) diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp index aab94924..2f80094e 100644 --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -53,8 +53,11 @@ Helper::Helper(KSharedConfig::Ptr config, QObject *parent) { if (qApp) { connect(qApp, &QApplication::paletteChanged, this, [=]() { - if (qApp->property("KDE_COLOR_SCHEME_PATH").isValid()) { - const auto path = qApp->property("KDE_COLOR_SCHEME_PATH").toString(); + if (!qApp->property("KDE_COLOR_SCHEME_PATH").isValid()) { + return; + } + const auto path = qApp->property("KDE_COLOR_SCHEME_PATH").toString(); + if (!path.isEmpty()) { KConfig config(path, KConfig::SimpleConfig); KConfigGroup group(config.group("WM")); const QPalette palette(QApplication::palette()); @@ -95,17 +98,20 @@ void Helper::loadConfig() _cachedAutoValid = false; _decorationConfig->load(); - KConfig config(qApp->property("KDE_COLOR_SCHEME_PATH").toString(), KConfig::SimpleConfig); - KConfigGroup appGroup(config.group("WM")); KConfigGroup globalGroup(_config->group("WM")); - _activeTitleBarColor = - appGroup.readEntry("activeBackground", globalGroup.readEntry("activeBackground", palette.color(QPalette::Active, QPalette::Highlight))); - _activeTitleBarTextColor = - appGroup.readEntry("activeForeground", globalGroup.readEntry("activeForeground", palette.color(QPalette::Active, QPalette::HighlightedText))); - _inactiveTitleBarColor = - appGroup.readEntry("inactiveBackground", globalGroup.readEntry("inactiveBackground", palette.color(QPalette::Disabled, QPalette::Highlight))); - _inactiveTitleBarTextColor = - appGroup.readEntry("inactiveForeground", globalGroup.readEntry("inactiveForeground", palette.color(QPalette::Disabled, QPalette::HighlightedText))); + _activeTitleBarColor = globalGroup.readEntry("activeBackground", palette.color(QPalette::Active, QPalette::Highlight)); + _activeTitleBarTextColor = globalGroup.readEntry("activeForeground", palette.color(QPalette::Active, QPalette::HighlightedText)); + _inactiveTitleBarColor = globalGroup.readEntry("inactiveBackground", palette.color(QPalette::Disabled, QPalette::Highlight)); + _inactiveTitleBarTextColor = globalGroup.readEntry("inactiveForeground", palette.color(QPalette::Disabled, QPalette::HighlightedText)); + + if (const QString colorSchemePath = qApp->property("KDE_COLOR_SCHEME_PATH").toString(); !colorSchemePath.isEmpty()) { + KConfig config(colorSchemePath, KConfig::SimpleConfig); + KConfigGroup appGroup(config.group("WM")); + _activeTitleBarColor = appGroup.readEntry("activeBackground", _activeTitleBarColor); + _activeTitleBarTextColor = appGroup.readEntry("activeForeground", _activeTitleBarTextColor); + _inactiveTitleBarColor = appGroup.readEntry("inactiveBackground", _inactiveTitleBarColor); + _inactiveTitleBarTextColor = appGroup.readEntry("inactiveForeground", _inactiveTitleBarTextColor); + } } QColor transparentize(const QColor &color, qreal amount)