TI-29: Fix issue "timew config can't add new value"

- Add code to enter a new value for a config which is defined by Rules.cpp
  but not found in the configuration file.
This commit is contained in:
Thomas Lauf 2017-03-09 20:41:20 +01:00
parent c1b0998887
commit cef51697ee

View file

@ -119,6 +119,30 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
} }
} }
} }
if (! found)
{
// Remove name
if (! confirmation ||
confirm (format ("Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?",
name,
rules.get (name),
value)))
{
// Add blank line required by rules.
if (lines.size () &&
lines.back () != "")
lines.push_back ("");
// Add new line.
lines.push_back (name + " = " + json::encode (value));
database.undoTxnStart ();
database.undoTxn ("config", "", lines.back());
database.undoTxnEnd ();
change = true;
}
}
} }
else else
{ {