#6538 Added save to ConfigWriter, updated system config pathing and, set initial scope
This commit is contained in:
parent
b3892a1b82
commit
73b9f40a44
2 changed files with 29 additions and 7 deletions
|
|
@ -42,6 +42,8 @@ namespace GUI {
|
|||
QCoreApplication::organizationName(),
|
||||
QCoreApplication::applicationName());
|
||||
|
||||
//Set scope to user for initially
|
||||
m_pSettingsCurrent = m_pSettingsUser;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -98,9 +100,6 @@ namespace GUI {
|
|||
//setScope should never be kCurrent
|
||||
assert(scope);
|
||||
}
|
||||
|
||||
//Notify registered classes to reload
|
||||
globalLoad();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +128,7 @@ namespace GUI {
|
|||
for (auto &i : m_pCallerList) {
|
||||
i->saveSettings();
|
||||
}
|
||||
save();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -153,10 +153,11 @@ namespace GUI {
|
|||
#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/";
|
||||
path = "/usr/local/etc/symless/";
|
||||
#elif defined(Q_OS_LINUX)
|
||||
// /usr/local/etc/synergy
|
||||
path = "/usr/local/etc/symless/synergy/";
|
||||
// QT adds application and filename to the end of the path already on linux
|
||||
path = "/usr/local/etc/symless/";
|
||||
return path;
|
||||
#else
|
||||
assert("OS not supported");
|
||||
#endif
|
||||
|
|
@ -164,6 +165,10 @@ namespace GUI {
|
|||
}
|
||||
|
||||
bool ConfigWriter::unsavedChanges() const {
|
||||
if (m_unsavedChanges) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &i : m_pCallerList) {
|
||||
if (i->modified()){
|
||||
//If any class returns true there is no point checking more
|
||||
|
|
@ -174,6 +179,10 @@ namespace GUI {
|
|||
return false;
|
||||
}
|
||||
|
||||
void ConfigWriter::markUnsaved() {
|
||||
m_unsavedChanges = true;
|
||||
}
|
||||
|
||||
ConfigWriter::SaveChoice ConfigWriter::checkSystemSave() const {
|
||||
if (m_CurrentScope == kSystem) {
|
||||
|
||||
|
|
@ -201,6 +210,9 @@ namespace GUI {
|
|||
return kSave;
|
||||
}
|
||||
|
||||
|
||||
void ConfigWriter::save() {
|
||||
m_pSettingsCurrent->sync();
|
||||
m_unsavedChanges = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,12 +81,18 @@ namespace GUI {
|
|||
/// @brief trigger a config save across all registered classes
|
||||
void globalSave();
|
||||
|
||||
/// @brief Saves the settings to file
|
||||
void save();
|
||||
|
||||
/// @brief Returns the current scopes settings object
|
||||
/// If more specialize control into the settings is needed this can provide
|
||||
/// direct access to the settings file handler
|
||||
/// @return QSettings The Settings object as a reference
|
||||
QSettings& settings();
|
||||
|
||||
/// @brief This marks the settings as unsaved if the settings() was used to directly affect the config file
|
||||
void markUnsaved();
|
||||
|
||||
/// @brief Register a class to receives globalLoad and globalSave events
|
||||
/// @param [in] ConfigBase The class that will receive the events
|
||||
void registerClass(ConfigBase* receiver);
|
||||
|
|
@ -116,6 +122,9 @@ namespace GUI {
|
|||
/// on a save and reload by any other class
|
||||
std::list<ConfigBase*> m_pCallerList;
|
||||
|
||||
/// @brief if this class modified settings then set the flag
|
||||
bool m_unsavedChanges = false;
|
||||
|
||||
/// @brief The constructor, as this is a singolton we want to control who can call the constructor
|
||||
ConfigWriter();
|
||||
|
||||
|
|
@ -145,6 +154,7 @@ namespace GUI {
|
|||
m_pSettingsCurrent->setValue(name, value);
|
||||
break;
|
||||
}
|
||||
m_unsavedChanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue