refactor: settings for windows use Appdata/local, always save daemon log to app install path

This commit is contained in:
sithlord48 2025-03-29 15:53:36 -04:00 committed by Chris Rizzitello
parent 01878b0522
commit 3ed0915b57
2 changed files with 11 additions and 12 deletions

View file

@ -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. `<install-path>/settings/Deskflow.conf`
1. A user settings file
1. A system settings file
- Check Install_path/settings/Deskflow.conf A new settings file will be created in the user path if no settings file is found.
- Check if User Settings Path The path of the settings file will be used as the base for all other config files.
- 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
### Windows ### Windows
- System: `C:\ProgramData\Deskflow\Deskflow.conf` - System: `C:\ProgramData\Deskflow\Deskflow.conf`

View file

@ -40,16 +40,12 @@ Settings::Settings(QObject *parent) : QObject(parent)
if (QFile(m_portableSettingsFile).exists()) { if (QFile(m_portableSettingsFile).exists()) {
fileToLoad = m_portableSettingsFile; fileToLoad = m_portableSettingsFile;
} else { } else {
#ifdef Q_OS_WIN
fileToLoad = SystemSettingFile;
#else
if (QFile(UserSettingFile).exists()) if (QFile(UserSettingFile).exists())
fileToLoad = UserSettingFile; fileToLoad = UserSettingFile;
else if (QFile(SystemSettingFile).exists()) else if (QFile(SystemSettingFile).exists())
fileToLoad = SystemSettingFile; fileToLoad = SystemSettingFile;
else else
fileToLoad = UserSettingFile; fileToLoad = UserSettingFile;
#endif
} }
m_settings = new QSettings(fileToLoad, QSettings::IniFormat); m_settings = new QSettings(fileToLoad, QSettings::IniFormat);
@ -122,7 +118,11 @@ QVariant Settings::defaultValue(const QString &key)
return defaultProcessMode; return defaultProcessMode;
if (key == Daemon::LogFile) { 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); return QStringLiteral("%1/%2").arg(instance()->settingsPath(), kDaemonLogFilename);
#endif
} }
if (key == Daemon::Elevate) if (key == Daemon::Elevate)