refactor: allow settings to use XDG_CONFIG_DIR if defined

fixes: #8421
This commit is contained in:
sithlord48
2025-03-30 13:04:41 -04:00
committed by Chris Rizzitello
parent 3ed0915b57
commit d2bf5e63e4
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@
The search order for a setting file is:
1. `<install-path>/settings/Deskflow.conf`
1. `<XDG_CONFIG_HOME>/Deskflow/Deskflow.conf`
1. A user settings file
1. A system settings file

View File

@ -40,7 +40,9 @@ Settings::Settings(QObject *parent) : QObject(parent)
if (QFile(m_portableSettingsFile).exists()) {
fileToLoad = m_portableSettingsFile;
} else {
if (QFile(UserSettingFile).exists())
if (!qEnvironmentVariable("XDG_CONFIG_HOME").isEmpty())
fileToLoad = QStringLiteral("%1/%2/%2.conf").arg(qEnvironmentVariable("XDG_CONFIG_HOME"), kAppName);
else if (QFile(UserSettingFile).exists())
fileToLoad = UserSettingFile;
else if (QFile(SystemSettingFile).exists())
fileToLoad = SystemSettingFile;