From 2230c00bc60a3b5d838e40d96eab8fbae5bb26a6 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 7 Jul 2024 08:52:13 +0400 Subject: [PATCH] Check whether path is empty in Qt6CT::resolvePath --- src/qt6ct-common/qt6ct.cpp | 3 +++ src/qt6ct-qtplugin/qt6ctplatformtheme.cpp | 14 ++++++-------- src/qt6ct/appearancepage.cpp | 3 +-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qt6ct-common/qt6ct.cpp b/src/qt6ct-common/qt6ct.cpp index d97d4c7..825ba67 100644 --- a/src/qt6ct-common/qt6ct.cpp +++ b/src/qt6ct-common/qt6ct.cpp @@ -124,6 +124,9 @@ QStringList Qt6CT::sharedColorSchemePaths() QString Qt6CT::resolvePath(const QString &path) { + if(path.isEmpty()) + return path; + QString tmp = path; tmp.replace("~", QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); if(!tmp.contains("$")) diff --git a/src/qt6ct-qtplugin/qt6ctplatformtheme.cpp b/src/qt6ct-qtplugin/qt6ctplatformtheme.cpp index 1d13faf..3ba470f 100644 --- a/src/qt6ct-qtplugin/qt6ctplatformtheme.cpp +++ b/src/qt6ct-qtplugin/qt6ctplatformtheme.cpp @@ -248,18 +248,16 @@ void Qt6CTPlatformTheme::updateSettings() void Qt6CTPlatformTheme::readSettings() { - m_palette.reset(); - QSettings settings(Qt6CT::configFile(), QSettings::IniFormat); settings.beginGroup("Appearance"); m_style = settings.value("style", "Fusion").toString(); - QString schemePath = settings.value("color_scheme_path").toString(); - if(!schemePath.isEmpty() && settings.value("custom_palette", false).toBool()) - { - schemePath = Qt6CT::resolvePath(schemePath); //replace environment variables - m_palette = std::make_unique(Qt6CT::loadColorScheme(schemePath, *QPlatformTheme::palette(SystemPalette))); - } + QString schemePath = settings.value("custom_palette", false).toBool() + ? Qt6CT::resolvePath(settings.value("color_scheme_path").toString()) //replace environment variables + : QString(); + m_palette = !schemePath.isEmpty() + ? std::make_unique(Qt6CT::loadColorScheme(schemePath, *QPlatformTheme::palette(SystemPalette))) + : nullptr; m_iconTheme = settings.value("icon_theme").toString(); //load dialogs if(!m_update) diff --git a/src/qt6ct/appearancepage.cpp b/src/qt6ct/appearancepage.cpp index fc154c2..c0ddc40 100644 --- a/src/qt6ct/appearancepage.cpp +++ b/src/qt6ct/appearancepage.cpp @@ -326,8 +326,7 @@ void AppearancePage::readSettings() m_ui->styleComboBox->setCurrentText(style); m_ui->customPaletteButton->setChecked(settings.value("custom_palette", false).toBool()); - QString colorSchemePath = settings.value("color_scheme_path").toString(); - colorSchemePath = Qt6CT::resolvePath(colorSchemePath); //replace environment variables + QString colorSchemePath = Qt6CT::resolvePath(settings.value("color_scheme_path").toString()); //replace environment variables QDir("/").mkpath(Qt6CT::userColorSchemePath()); findColorSchemes(Qt6CT::userColorSchemePath());