From b314d9329fd6f550e32ec2d14fae91e31da96495 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 7 May 2012 14:55:29 +0400 Subject: [PATCH] gui/widget/menue.cpp: simplify CMenuOptionLanguageChooser - we have one option for every instance --- src/gui/widget/menue.cpp | 39 +++++---------------------------------- src/gui/widget/menue.h | 4 +--- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index ecbb5ea1d..d2cfebdd2 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1437,38 +1437,14 @@ CMenuOptionLanguageChooser::CMenuOptionLanguageChooser(char* OptionValue, CChang CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser() { - options.clear(); -} - -void CMenuOptionLanguageChooser::addOption(const char * const value) -{ - options.push_back(std::string(value)); } int CMenuOptionLanguageChooser::exec(CMenuTarget*) { - bool wantsRepaint = false; - - //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); + strncpy(g_settings.language, optionValue.c_str(), sizeof(g_settings.language)); if(observ) - { - wantsRepaint = observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, optionValue); - } + observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str()); return menu_return::RETURN_EXIT; - if ( wantsRepaint ) - return menu_return::RETURN_REPAINT; - else - return menu_return::RETURN_NONE; } int CMenuOptionLanguageChooser::paint( bool selected ) @@ -1481,20 +1457,15 @@ int CMenuOptionLanguageChooser::paint( bool selected ) paintItemButton(selected, height, iconName); //convert first letter to large - string s_optionValue = static_cast (optionValue); - string ts = s_optionValue.substr(0, 1); - string s(ts); - s = toupper(s_optionValue[0]); - s_optionValue.replace(0, 1, s); - + std::string s_optionValue = optionValue; + if(!s_optionValue.empty()) + s_optionValue[0] = 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 char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) { diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index f1ea45e33..2b1774849 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -362,15 +362,13 @@ class CMenuOptionStringChooser : public CMenuItem class CMenuOptionLanguageChooser : public CMenuItem { int height; - char * optionValue; - std::vector options; + std::string optionValue; CChangeObserver * observ; public: CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ = NULL, const char * const IconName = NULL); ~CMenuOptionLanguageChooser(); - void addOption(const char * value); int paint(bool selected); int getHeight(void) const {