mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
gui/widget/menue.cpp: simplify CMenuOptionLanguageChooser - we have one option for every instance
This commit is contained in:
@@ -1437,38 +1437,14 @@ CMenuOptionLanguageChooser::CMenuOptionLanguageChooser(char* OptionValue, CChang
|
|||||||
|
|
||||||
CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser()
|
CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser()
|
||||||
{
|
{
|
||||||
options.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMenuOptionLanguageChooser::addOption(const char * const value)
|
|
||||||
{
|
|
||||||
options.push_back(std::string(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionLanguageChooser::exec(CMenuTarget*)
|
int CMenuOptionLanguageChooser::exec(CMenuTarget*)
|
||||||
{
|
{
|
||||||
bool wantsRepaint = false;
|
strncpy(g_settings.language, optionValue.c_str(), sizeof(g_settings.language));
|
||||||
|
|
||||||
//select value
|
|
||||||
for(unsigned int count = 0; count < options.size(); count++)
|
|
||||||
{
|
|
||||||
if (strcmp(options[count].c_str(), optionValue) == 0)
|
|
||||||
{
|
|
||||||
strcpy(g_settings.language, options[(count + 1) % options.size()].c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
paint(true);
|
|
||||||
if(observ)
|
if(observ)
|
||||||
{
|
observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str());
|
||||||
wantsRepaint = observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, optionValue);
|
|
||||||
}
|
|
||||||
return menu_return::RETURN_EXIT;
|
return menu_return::RETURN_EXIT;
|
||||||
if ( wantsRepaint )
|
|
||||||
return menu_return::RETURN_REPAINT;
|
|
||||||
else
|
|
||||||
return menu_return::RETURN_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenuOptionLanguageChooser::paint( bool selected )
|
int CMenuOptionLanguageChooser::paint( bool selected )
|
||||||
@@ -1481,20 +1457,15 @@ int CMenuOptionLanguageChooser::paint( bool selected )
|
|||||||
paintItemButton(selected, height, iconName);
|
paintItemButton(selected, height, iconName);
|
||||||
|
|
||||||
//convert first letter to large
|
//convert first letter to large
|
||||||
string s_optionValue = static_cast<std::string> (optionValue);
|
std::string s_optionValue = optionValue;
|
||||||
string ts = s_optionValue.substr(0, 1);
|
if(!s_optionValue.empty())
|
||||||
string s(ts);
|
s_optionValue[0] = toupper(s_optionValue[0]);
|
||||||
s = toupper(s_optionValue[0]);
|
|
||||||
s_optionValue.replace(0, 1, s);
|
|
||||||
|
|
||||||
//paint text
|
//paint text
|
||||||
paintItemCaption(selected, height , s_optionValue.c_str());
|
paintItemCaption(selected, height , s_optionValue.c_str());
|
||||||
|
|
||||||
return y+height;
|
return y+height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right)
|
CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right)
|
||||||
{
|
{
|
||||||
|
@@ -362,15 +362,13 @@ class CMenuOptionStringChooser : public CMenuItem
|
|||||||
class CMenuOptionLanguageChooser : public CMenuItem
|
class CMenuOptionLanguageChooser : public CMenuItem
|
||||||
{
|
{
|
||||||
int height;
|
int height;
|
||||||
char * optionValue;
|
std::string optionValue;
|
||||||
std::vector<std::string> options;
|
|
||||||
CChangeObserver * observ;
|
CChangeObserver * observ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ = NULL, const char * const IconName = NULL);
|
CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ = NULL, const char * const IconName = NULL);
|
||||||
~CMenuOptionLanguageChooser();
|
~CMenuOptionLanguageChooser();
|
||||||
|
|
||||||
void addOption(const char * value);
|
|
||||||
int paint(bool selected);
|
int paint(bool selected);
|
||||||
int getHeight(void) const
|
int getHeight(void) const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user