Save settings on change
Dieser Commit ist enthalten in:
Ursprung
3fd0aa18be
Commit
51ca7aa3c5
@ -54,8 +54,8 @@ class Property : public AbstractProperty
|
||||
m_onChanged = onChanged;
|
||||
}
|
||||
|
||||
Property(Object* object, const std::string& name, const T& value, PropertyFlags flags, OnSet onSet) :
|
||||
Property(object, name, value, flags)
|
||||
Property(Object* object, const std::string& name, const T& value, PropertyFlags flags, OnChanged onChanged, OnSet onSet) :
|
||||
Property(object, name, value, flags, onChanged)
|
||||
{
|
||||
m_onSet = onSet;
|
||||
}
|
||||
@ -71,6 +71,8 @@ class Property : public AbstractProperty
|
||||
if(isWriteable() && (!m_onSet || m_onSet(value)) && m_value != value)
|
||||
{
|
||||
m_value = value;
|
||||
if(m_onChanged)
|
||||
m_onChanged(m_value);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,10 +32,10 @@ const std::string Settings::id{Settings::classId};
|
||||
Settings::Settings(const std::filesystem::path& filename) :
|
||||
Object{},
|
||||
m_filename{filename},
|
||||
localhostOnly{this, "localhost_only", true, PropertyFlags::AccessWCC},
|
||||
port{this, "port", defaultPort, PropertyFlags::AccessWCC},
|
||||
discoverable{this, "discoverable", true, PropertyFlags::AccessWWW},
|
||||
defaultWorld{this, "default_world", "", PropertyFlags::AccessWWW}
|
||||
localhostOnly{this, "localhost_only", true, PropertyFlags::AccessWCC, [this](const bool&){ save(); }},
|
||||
port{this, "port", defaultPort, PropertyFlags::AccessWCC, [this](const uint16_t&){ save(); }},
|
||||
discoverable{this, "discoverable", true, PropertyFlags::AccessWWW, [this](const bool&){ save(); }},
|
||||
defaultWorld{this, "default_world", "", PropertyFlags::AccessWWW, [this](const std::string&){ save(); }}
|
||||
{
|
||||
m_interfaceItems.add(localhostOnly);
|
||||
m_interfaceItems.add(port);
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren