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