From 7fb564c7b54b4410e8a4c8a8ef4c3704d0f8eca6 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 30 Mar 2019 00:06:26 +0100 Subject: [PATCH] CMenueWidget: add overloaded version of addIntroItems() Allows additional usage of strings as text parameter. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/167531e412a6d52415d5c26d569ec281f1ab7e36 Author: Thilo Graf Date: 2019-03-30 (Sat, 30 Mar 2019) --- src/gui/widget/menue.cpp | 12 +++++++++--- src/gui/widget/menue.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index a6f51efda..a246698e1 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1486,12 +1486,12 @@ void CMenuWidget::paintItems() } /*adds the typical menu intro with optional subhead, separator, back or cancel button and separatorline to menu*/ -void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_t section_text, int buttontype, bool brief_hint) +void CMenuWidget::addIntroItems(const std::string& s_subhead_text, neutrino_locale_t section_text, int buttontype, bool brief_hint) { brief_hints = brief_hint; - if (subhead_text != NONEXISTANT_LOCALE) - addItem(new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING, subhead_text)); + if (!s_subhead_text.empty()) + addItem(new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING, s_subhead_text)); addItem(GenericMenuSeparator); @@ -1514,6 +1514,12 @@ void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_ addItem(GenericMenuSeparatorLine); } +void CMenuWidget::addIntroItems(neutrino_locale_t l_subhead_text, neutrino_locale_t section_text, int buttontype, bool brief_hint) +{ + std::string str = l_subhead_text == NONEXISTANT_LOCALE ? "" : g_Locale->getText(l_subhead_text); + addIntroItems(str, section_text, buttontype, brief_hint); +} + void CMenuWidget::saveScreen() { if(!savescreen) diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 0938e0d8f..f501d35c2 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -630,7 +630,8 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals BRIEF_HINT_NO = 0, BRIEF_HINT_YES = 1 }; - virtual void addIntroItems(neutrino_locale_t subhead_text = NONEXISTANT_LOCALE, neutrino_locale_t section_text = NONEXISTANT_LOCALE, int buttontype = BTN_TYPE_BACK, bool brief_hint = BRIEF_HINT_NO); + void addIntroItems(neutrino_locale_t l_subhead_text = NONEXISTANT_LOCALE, neutrino_locale_t section_text = NONEXISTANT_LOCALE, int buttontype = BTN_TYPE_BACK, bool brief_hint = BRIEF_HINT_NO); + void addIntroItems(const std::string& s_subhead_text, neutrino_locale_t section_text = NONEXISTANT_LOCALE, int buttontype = BTN_TYPE_BACK, bool brief_hint = BRIEF_HINT_NO); bool hasItem(); void resetWidget(bool delete_items = false); void insertItem(const uint& item_id, CMenuItem* menuItem);