From 11eda2037877c5b186aa9a4a77501ae4b2519462 Mon Sep 17 00:00:00 2001 From: Jamie Newbon Date: Thu, 19 Mar 2020 15:35:29 +0000 Subject: [PATCH] #6538 Changed System scope path to be OS dependant --- src/gui/src/main.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 5e036be81..24d80b93a 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -48,6 +48,7 @@ public: }; int waitForTray(); +QString getSystemSettingPath(); #if defined(Q_OS_MAC) bool checkMacAssistiveDevices(); @@ -88,11 +89,10 @@ int main(int argc, char* argv[]) #ifndef Q_OS_WIN QApplication::setQuitOnLastWindowClosed(false); #endif - //Set the path of the system settings to the programs local folder - //as the default system settings path has problems writing without Admin/root permission + //S QSettings::setPath(QSettings::Format::IniFormat, - QSettings::Scope::SystemScope, - QString("SystemSettings")); + QSettings::Scope::SystemScope, + getSystemSettingPath()); //Config will default to User settings if they exist, // otherwise it will load System setting and save them to User settings @@ -160,6 +160,26 @@ int waitForTray() return true; } +QString getSystemSettingPath() +{ + const QString settingFilename("SystemConfig.ini"); + QString path; +#if defined(Q_OS_WIN) + // Program file + path = "" +#elif defined(Q_OS_DARWIN) + //Global preferances dir + // Would be nice to use /library, but QT has no elevate system in place + path = "/usr/local/etc/symless/synergy/"; +#elif defined(Q_OS_LINUX) + // /usr/local/etc/synergy + path = "/usr/local/etc/symless/synergy/"; +#else + assert("OS not supported") +#endif + return path + settingFilename; +} + #if defined(Q_OS_MAC) bool checkMacAssistiveDevices() {