gui/widget/menue, gui/osdlang_setup: drop CMenuOptionLanguageChooser class

This commit is contained in:
martii
2014-03-02 21:31:26 +01:00
committed by svenhoefer
parent c161760670
commit eb206ae523
4 changed files with 16 additions and 72 deletions

View File

@@ -67,12 +67,18 @@ COsdLangSetup::~COsdLangSetup()
} }
int COsdLangSetup::exec(CMenuTarget* parent, const std::string &/*actionKey*/) int COsdLangSetup::exec(CMenuTarget* parent, const std::string &actionKey)
{ {
dprintf(DEBUG_DEBUG, "init international setup\n"); dprintf(DEBUG_DEBUG, "init international setup\n");
if(parent != NULL) if(parent != NULL)
parent->hide(); parent->hide();
if (actionKey != "") {
g_settings.language = actionKey;
g_Locale->loadLocale(g_settings.language.c_str());
return menu_return::RETURN_REPAINT;
}
int res = showLocalSetup(); int res = showLocalSetup();
return res; return res;
@@ -92,7 +98,7 @@ int COsdLangSetup::showLocalSetup()
CMenuWidget osdl_setup(LOCALE_LANGUAGESETUP_OSD, NEUTRINO_ICON_LANGUAGE, width, MN_WIDGET_ID_LANGUAGESETUP_LOCALE); CMenuWidget osdl_setup(LOCALE_LANGUAGESETUP_OSD, NEUTRINO_ICON_LANGUAGE, width, MN_WIDGET_ID_LANGUAGESETUP_LOCALE);
showLanguageSetup(&osdl_setup); showLanguageSetup(&osdl_setup);
CMenuForwarder * mf = new CMenuForwarder(LOCALE_LANGUAGESETUP_OSD, true, NULL, &osdl_setup, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); CMenuForwarder * mf = new CMenuForwarder(LOCALE_LANGUAGESETUP_OSD, true, g_settings.language, &osdl_setup, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
mf->setHint("", LOCALE_MENU_HINT_OSD_LANGUAGE); mf->setHint("", LOCALE_MENU_HINT_OSD_LANGUAGE);
localSettings->addItem(mf); localSettings->addItem(mf);
@@ -186,8 +192,12 @@ void COsdLangSetup::showLanguageSetup(CMenuWidget *osdl_setup)
if (pos != NULL) if (pos != NULL)
{ {
*pos = '\0'; *pos = '\0';
CMenuOptionLanguageChooser* oj = new CMenuOptionLanguageChooser((char*)locale, this, locale); std::string loc(locale);
osdl_setup->addItem( oj ); loc.at(0) = toupper(loc.at(0));
CMenuForwarder *mf = new CMenuForwarder(loc, true, NULL, this, locale);
mf->iconName = mf->getActionKey();
osdl_setup->addItem(mf, !strcmp(locale, g_settings.language.c_str()));
} }
free(namelist[count]); free(namelist[count]);
} }

View File

@@ -874,7 +874,7 @@ void CPersonalizeGui::addPersonalizedItems()
//convert item to locked forwarder and use generated pin mode for usage as ask parameter //convert item to locked forwarder and use generated pin mode for usage as ask parameter
v_item[i].menuItem = new CLockedMenuForwarder(fw->getTextLocale(), v_item[i].menuItem = new CLockedMenuForwarder(fw->getTextLocale(),
g_settings.easymenu ? g_settings.parentallock_pincode : g_settings.personalize_pincode, g_settings.easymenu ? g_settings.parentallock_pincode : g_settings.personalize_pincode,
use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey().c_str(), d_key, fw->iconName.c_str(), lock_icon); use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey(), d_key, fw->iconName.c_str(), lock_icon);
v_item[i].menuItem->hintIcon = fw->hintIcon; v_item[i].menuItem->hintIcon = fw->hintIcon;
v_item[i].menuItem->hint = fw->hint; v_item[i].menuItem->hint = fw->hint;
//add item if it's set to visible or pin protected and allow to add an forwarder as next //add item if it's set to visible or pin protected and allow to add an forwarder as next

View File

@@ -1769,49 +1769,6 @@ int CMenuOptionStringChooser::paint( bool selected )
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
CMenuOptionLanguageChooser::CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ, const char * const IconName)
{
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
optionValue = OptionValue;
observ = Observ;
directKey = CRCInput::RC_nokey;
iconName = IconName ? IconName : "";
}
CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser()
{
}
int CMenuOptionLanguageChooser::exec(CMenuTarget*)
{
g_settings.language = optionValue;
if(observ)
observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str());
return menu_return::RETURN_EXIT;
}
int CMenuOptionLanguageChooser::paint( bool selected )
{
active = true;
//paint item
prepareItem(selected, height);
paintItemButton(selected, height, iconName);
//convert first letter to large
std::string s_optionValue = optionValue;
if(!s_optionValue.empty())
s_optionValue[0] = (char)toupper(s_optionValue[0]);
//paint text
paintItemCaption(selected, height , s_optionValue.c_str());
return y+height;
}
//-------------------------------------------------------------------------------------------------------------------------------
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic)
{ {
option_string = &Option; option_string = &Option;

View File

@@ -245,7 +245,7 @@ class CMenuForwarder : public CMenuItem
int getWidth(void); int getWidth(void);
neutrino_locale_t getTextLocale() const {return name;} neutrino_locale_t getTextLocale() const {return name;}
CMenuTarget* getTarget() const {return jumpTarget;} CMenuTarget* getTarget() const {return jumpTarget;}
std::string getActionKey(){return actionKey;} const char *getActionKey(){return actionKey.c_str();}
int exec(CMenuTarget* parent); int exec(CMenuTarget* parent);
bool isSelectable(void) const { return active; } bool isSelectable(void) const { return active; }
@@ -444,29 +444,6 @@ class CMenuOptionStringChooser : public CMenuItem
int isMenueOptionChooser(void) const{return 1;} int isMenueOptionChooser(void) const{return 1;}
}; };
class CMenuOptionLanguageChooser : public CMenuItem
{
int height;
std::string optionValue;
CChangeObserver * observ;
public:
CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ = NULL, const char * const IconName = NULL);
~CMenuOptionLanguageChooser();
int paint(bool selected);
int getHeight(void) const
{
return height;
}
bool isSelectable(void) const
{
return true;
}
int exec(CMenuTarget* parent);
};
class CMenuGlobal class CMenuGlobal
{ {
public: public: