From 81c29dc7c42cca8dddfcbdeee14ae84ee6090c8b Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Sat, 7 Dec 2013 23:02:09 +0100 Subject: Add support for persistent variables in theme's section * Add support for variables with persist="1", which will cause them saved into settings file and reloaded on next boot. * This is handy for theme makers, who can use this to implement "theme settings". Signed-off-by: Vojtech Bocek Change-Id: I6415979011b38cbb15dec9909c445b02da6eadc0 --- gui/pages.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gui/pages.cpp b/gui/pages.cpp index d02dd216d..d662f18f8 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -611,16 +611,21 @@ Page* PageSet::FindPage(std::string name) int PageSet::LoadVariables(xml_node<>* vars) { xml_node<>* child; + xml_attribute<> *name, *value, *persist; + int p; child = vars->first_node("variable"); while (child) { - if (!child->first_attribute("name")) - break; - if (!child->first_attribute("value")) - break; + name = child->first_attribute("name"); + value = child->first_attribute("value"); + persist = child->first_attribute("persist"); + if(name && value) + { + p = persist ? atoi(persist->value()) : 0; + DataManager::SetValue(name->value(), value->value(), p); + } - DataManager::SetValue(child->first_attribute("name")->value(), child->first_attribute("value")->value()); child = child->next_sibling("variable"); } return 0; -- cgit v1.2.3