From 3ed0915b573caafe46a67088476a204427dac227 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 29 Mar 2025 15:53:36 -0400 Subject: [PATCH] refactor: settings for windows use Appdata/local, always save daemon log to app install path --- doc/configuration.md | 15 +++++++-------- src/lib/common/Settings.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/configuration.md b/doc/configuration.md index c16e8f4bc..fd0f5ec81 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -1,13 +1,12 @@ -# Gui Config +# GUI Config -The search path for settings ar as follows: + The search order for a setting file is: + 1. `/settings/Deskflow.conf` + 1. A user settings file + 1. A system settings file - - Check Install_path/settings/Deskflow.conf - - Check if User Settings Path - - Check if System Settings File - - Make a User Setting file - - The path of the settings file will be used as the base for all other config files + A new settings file will be created in the user path if no settings file is found. + The path of the settings file will be used as the base for all other config files. ### Windows - System: `C:\ProgramData\Deskflow\Deskflow.conf` diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index bb95b9da9..41472667c 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -40,16 +40,12 @@ Settings::Settings(QObject *parent) : QObject(parent) if (QFile(m_portableSettingsFile).exists()) { fileToLoad = m_portableSettingsFile; } else { -#ifdef Q_OS_WIN - fileToLoad = SystemSettingFile; -#else if (QFile(UserSettingFile).exists()) fileToLoad = UserSettingFile; else if (QFile(SystemSettingFile).exists()) fileToLoad = SystemSettingFile; else fileToLoad = UserSettingFile; -#endif } m_settings = new QSettings(fileToLoad, QSettings::IniFormat); @@ -122,7 +118,11 @@ QVariant Settings::defaultValue(const QString &key) return defaultProcessMode; if (key == Daemon::LogFile) { +#ifdef Q_OS_WIN + return QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), kDaemonLogFilename); +#else return QStringLiteral("%1/%2").arg(instance()->settingsPath(), kDaemonLogFilename); +#endif } if (key == Daemon::Elevate)