Skip to content

Commit

Permalink
Check whether path is empty in Qt6CT::resolvePath
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin committed Oct 2, 2024
1 parent 55dba87 commit 567bec5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/qt6ct-common/qt6ct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("$"))
Expand Down
14 changes: 6 additions & 8 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,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<QPalette>(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<QPalette>(Qt6CT::loadColorScheme(schemePath, *QPlatformTheme::palette(SystemPalette)))
: nullptr;
m_iconTheme = settings.value("icon_theme").toString();
//load dialogs
if(!m_update)
Expand Down
3 changes: 1 addition & 2 deletions src/qt6ct/appearancepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 567bec5

Please sign in to comment.