gui/personalize.cpp: try to fix usermenu delete

This commit is contained in:
[CST] Focus
2014-09-09 15:28:20 +04:00
parent 9b82162e6f
commit d2c836049b
2 changed files with 21 additions and 14 deletions

View File

@@ -231,9 +231,19 @@ int CPersonalizeGui::exec(CMenuTarget* parent, const string & actionKey)
if (ak && *ak && std::string(ak).find_first_not_of("0123456789") == std::string::npos) { if (ak && *ak && std::string(ak).find_first_not_of("0123456789") == std::string::npos) {
int i = atoi(ak); int i = atoi(ak);
if (i > -1) { if (i > -1) {
for (unsigned int j = 4; j < g_settings.usermenu.size(); j++) {
std::string name = to_string(j);
std::string usermenu_key("usermenu_key_");
usermenu_key += name;
CNeutrinoApp::getInstance()->getConfigFile()->deleteKey(usermenu_key);
std::string txt1("usermenu_tv_");
txt1 += name;
CNeutrinoApp::getInstance()->getConfigFile()->deleteKey(txt1);
txt1 += "_text";
CNeutrinoApp::getInstance()->getConfigFile()->deleteKey(txt1);
}
delete g_settings.usermenu[i]; delete g_settings.usermenu[i];
g_settings.usermenu[i] = NULL; g_settings.usermenu[i] = NULL;
CNeutrinoApp::getInstance()->getConfigFile()->clear();
} }
} }
uMenu->removeItem(selected); uMenu->removeItem(selected);
@@ -247,8 +257,6 @@ int CPersonalizeGui::exec(CMenuTarget* parent, const string & actionKey)
parent->hide(); parent->hide();
if (actionKey == ">a") { if (actionKey == ">a") {
int selected = uMenu->getSelected();
unsigned int i = g_settings.usermenu.size(); unsigned int i = g_settings.usermenu.size();
CUserMenuSetup *cms = new CUserMenuSetup(LOCALE_USERMENU_HEAD, i); CUserMenuSetup *cms = new CUserMenuSetup(LOCALE_USERMENU_HEAD, i);
SNeutrinoSettings::usermenu_t *um = new SNeutrinoSettings::usermenu_t; SNeutrinoSettings::usermenu_t *um = new SNeutrinoSettings::usermenu_t;
@@ -257,10 +265,13 @@ int CPersonalizeGui::exec(CMenuTarget* parent, const string & actionKey)
CMenuDForwarder *fw = new CMenuDForwarder(CRCInput::getKeyName(um->key), true, um->title, cms, to_string(i).c_str()); CMenuDForwarder *fw = new CMenuDForwarder(CRCInput::getKeyName(um->key), true, um->title, cms, to_string(i).c_str());
cms->setCaller(fw); cms->setCaller(fw);
#if 0
int selected = uMenu->getSelected();
if (selected >= customkey_offset) if (selected >= customkey_offset)
uMenu->insertItem(selected, fw); uMenu->insertItem(selected, fw);
else else
uMenu->addItem(fw); #endif
uMenu->addItem(fw, true);
uMenu->hide(); uMenu->hide();
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }

View File

@@ -833,6 +833,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
// USERMENU -> in system/settings.h // USERMENU -> in system/settings.h
//------------------------------------------- //-------------------------------------------
g_settings.usermenu.clear();
if (configfile.getString("usermenu_key_red", "").empty() || if (configfile.getString("usermenu_key_red", "").empty() ||
configfile.getString("usermenu_key_green", "").empty() || configfile.getString("usermenu_key_green", "").empty() ||
configfile.getString("usermenu_key_yellow", "").empty() || configfile.getString("usermenu_key_yellow", "").empty() ||
@@ -844,14 +845,17 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.usermenu.push_back(u); g_settings.usermenu.push_back(u);
} }
} else { } else {
bool unknown = configfile.getUnknownKeyQueryedFlag();
for (unsigned int i = 0; ; i++) { for (unsigned int i = 0; ; i++) {
std::string name = (i < 4) ? usermenu_default[i].name : to_string(i); std::string name = (i < 4) ? usermenu_default[i].name : to_string(i);
std::string usermenu_key("usermenu_key_"); std::string usermenu_key("usermenu_key_");
usermenu_key += name; usermenu_key += name;
int uk = configfile.getInt32(usermenu_key, CRCInput::RC_nokey); int uk = configfile.getInt32(usermenu_key, CRCInput::RC_nokey);
if (!uk || uk == (int)CRCInput::RC_nokey) { if (!uk || uk == (int)CRCInput::RC_nokey) {
if (i > 3) if (i > 3) {
configfile.setUnknownKeyQueryedFlag(unknown);
break; break;
}
continue; continue;
} }
SNeutrinoSettings::usermenu_t *u = new SNeutrinoSettings::usermenu_t; SNeutrinoSettings::usermenu_t *u = new SNeutrinoSettings::usermenu_t;
@@ -919,8 +923,6 @@ void CNeutrinoApp::saveSetup(const char * fname)
if(!scansettings.saveSettings(NEUTRINO_SCAN_SETTINGS_FILE)) { if(!scansettings.saveSettings(NEUTRINO_SCAN_SETTINGS_FILE)) {
dprintf(DEBUG_NORMAL, "error while saving scan-settings!\n"); dprintf(DEBUG_NORMAL, "error while saving scan-settings!\n");
} }
/* clear old values */
configfile.clear();
//video //video
configfile.setInt32( "video_Mode", g_settings.video_Mode ); configfile.setInt32( "video_Mode", g_settings.video_Mode );
@@ -1366,14 +1368,8 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setInt32("infoClockSeconds", g_settings.infoClockSeconds); configfile.setInt32("infoClockSeconds", g_settings.infoClockSeconds);
configfile.setInt32("easymenu", g_settings.easymenu); configfile.setInt32("easymenu", g_settings.easymenu);
if(strcmp(fname, NEUTRINO_SETTINGS_FILE)) if(strcmp(fname, NEUTRINO_SETTINGS_FILE) || configfile.getModifiedFlag())
configfile.saveConfig(fname); configfile.saveConfig(fname);
else if (configfile.getModifiedFlag())
{
configfile.saveConfig(fname);
configfile.setModifiedFlag(false);
}
} }
/************************************************************************************** /**************************************************************************************