From 3cdbc204e283f45bfd71ea6adacd3693e83c1255 Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 27 Oct 2013 16:17:24 +0100 Subject: Fixed a bug in theme specific configs --- config.c | 28 ++++++++++++++++------------ config.h | 1 + setup.c | 3 +++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/config.c b/config.c index 9fa449a..f7d7e10 100644 --- a/config.c +++ b/config.c @@ -341,24 +341,28 @@ bool cNopacityConfig::SetupParse(const char *Name, const char *Value) { std::map::iterator hit = conf.find(name); if (hit == conf.end()) return false; - //check if theme already in map - std::map >::iterator hit2 = themeConfigSetup.find(theme); - if (hit2 != themeConfigSetup.end()) { - std::map existingValues = (std::map)hit2->second; - existingValues.insert(std::pair(name, atoi(Value))); - themeConfigSetup.erase(theme); - themeConfigSetup.insert(std::pair >(theme, existingValues)); - } else { - std::map themeConf; - themeConf.insert(std::pair(name, atoi(Value))); - themeConfigSetup.insert(std::pair >(theme, themeConf)); - } + SetThemeConfigSetupValue(theme, name, atoi(Value)); } else { return false; } return true; } +void cNopacityConfig::SetThemeConfigSetupValue(std::string themeName, std::string key, int value) { + //check if theme already in map + std::map >::iterator hit = themeConfigSetup.find(themeName); + if (hit != themeConfigSetup.end()) { + std::map existingValues = (std::map)hit->second; + existingValues.insert(std::pair(key, value)); + themeConfigSetup.erase(themeName); + themeConfigSetup.insert(std::pair >(themeName, existingValues)); + } else { + std::map themeConf; + themeConf.insert(std::pair(key, value)); + themeConfigSetup.insert(std::pair >(themeName, themeConf)); + } +} + void cNopacityConfig::DumpConfig(void) { esyslog("nopacity: current config -----------------"); for(std::map::const_iterator it = conf.begin(); it != conf.end(); it++) { diff --git a/config.h b/config.h index 943f1d3..db77f87 100644 --- a/config.h +++ b/config.h @@ -23,6 +23,7 @@ class cNopacityConfig { std::map::const_iterator GetStart(void) { return conf.begin(); }; std::map::const_iterator GetEnd(void) { return conf.end(); }; bool SetupParse(const char *Name, const char *Value); + void SetThemeConfigSetupValue(std::string themeName, std::string key, int value); void SetLogoPath(cString path); void SetIconPath(cString path); void SetEpgImagePath(cString path); diff --git a/setup.c b/setup.c index e48dc41..2a607c9 100644 --- a/setup.c +++ b/setup.c @@ -84,7 +84,10 @@ void cNopacitySetup::Store(void) { int value = (int)it->second; int origValue = config.GetValue(name); if (value != origValue) { + //Save changed value in setup.conf SetupStore(*cString::sprintf("%s.%s", themeName, name.c_str()), value); + //Save changed value also in cConfig::themeConfigSetup + tmpConf.SetThemeConfigSetupValue(themeName, name, value); } } config = tmpConf; -- cgit v1.2.3