usermenu-setup: formatting code using astyle; some manual code nicenings

Origin commit data
------------------
Commit: 0c50377eee
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-12-04 (Sat, 04 Dec 2021)

Origin message was:
------------------
- usermenu-setup: formatting code using astyle; some manual code nicenings
This commit is contained in:
vanhofen
2021-12-04 23:22:35 +01:00
parent a4537ed42b
commit 5bf04504e3
2 changed files with 64 additions and 49 deletions

View File

@@ -55,6 +55,7 @@
static bool usermenu_show = true;
static bool usermenu_show_cam = true; // FIXME -- use hwcaps?
struct keyvals
{
const int key;
@@ -86,14 +87,14 @@ static keyvals usermenu_items[] =
{ SNeutrinoSettings::ITEM_CLOCK, LOCALE_CLOCK_SWITCH_ON, usermenu_show },
{ SNeutrinoSettings::ITEM_GAMES, LOCALE_MAINMENU_GAMES, usermenu_show },
{ SNeutrinoSettings::ITEM_SCRIPTS, LOCALE_MAINMENU_SCRIPTS, usermenu_show },
{ SNeutrinoSettings::ITEM_ECMINFO, LOCALE_ECMINFO_SHOW, usermenu_show }, //NI
{ SNeutrinoSettings::ITEM_CAMD_RESET, LOCALE_CAMD_RESET, usermenu_show }, //NI
{ SNeutrinoSettings::ITEM_INFOICONS, LOCALE_INFOICONS_SWITCH_ON, usermenu_show }, //NI
{ SNeutrinoSettings::ITEM_ECMINFO, LOCALE_ECMINFO_SHOW, usermenu_show },
{ SNeutrinoSettings::ITEM_CAMD_RESET, LOCALE_CAMD_RESET, usermenu_show },
{ SNeutrinoSettings::ITEM_INFOICONS, LOCALE_INFOICONS_SWITCH_ON, usermenu_show },
{ SNeutrinoSettings::ITEM_YOUTUBE, LOCALE_MOVIEPLAYER_YTPLAYBACK, usermenu_show },
{ SNeutrinoSettings::ITEM_FILEPLAY_VIDEO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_VIDEO, usermenu_show },
{ SNeutrinoSettings::ITEM_TOOLS, LOCALE_MAINMENU_TOOLS, usermenu_show },
{ SNeutrinoSettings::ITEM_LUA, LOCALE_MAINMENU_LUA, usermenu_show },
{ SNeutrinoSettings::ITEM_TUNER_RESTART, LOCALE_SERVICEMENU_RESTART_TUNER, usermenu_show }, //NI
{ SNeutrinoSettings::ITEM_TUNER_RESTART, LOCALE_SERVICEMENU_RESTART_TUNER, usermenu_show },
{ SNeutrinoSettings::ITEM_HDDMENU, LOCALE_HDD_SETTINGS, usermenu_show },
{ SNeutrinoSettings::ITEM_AUDIOPLAY, LOCALE_AUDIOPLAYER_NAME, usermenu_show },
{ SNeutrinoSettings::ITEM_INETPLAY, LOCALE_INETRADIO_NAME, usermenu_show },
@@ -102,7 +103,7 @@ static keyvals usermenu_items[] =
{ SNeutrinoSettings::ITEM_SWUPDATE, LOCALE_SERVICEMENU_UPDATE, usermenu_show },
{ SNeutrinoSettings::ITEM_LIVESTREAM_RESOLUTION, LOCALE_LIVESTREAM_RESOLUTION, usermenu_show },
{ SNeutrinoSettings::ITEM_ADZAP, LOCALE_USERMENU_ITEM_ADZAP, usermenu_show },
{ SNeutrinoSettings::ITEM_TESTMENU, LOCALE_TESTMENU, usermenu_show }, //NI
{ SNeutrinoSettings::ITEM_TESTMENU, LOCALE_TESTMENU, usermenu_show },
{ SNeutrinoSettings::ITEM_FILEPLAY_AUDIO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_AUDIO, usermenu_show },
{ SNeutrinoSettings::ITEM_TIMESHIFT, LOCALE_RECORDINGMENU_TIMESHIFT, usermenu_show },
{ SNeutrinoSettings::ITEM_MAX, NONEXISTANT_LOCALE, usermenu_show }
@@ -118,7 +119,8 @@ CUserMenuSetup::CUserMenuSetup(neutrino_locale_t menue_title, int menue_button)
pref_name = g_settings.usermenu[button]->title; // set current button name as prefered name
forwarder = NULL;
for (int i = 0; usermenu_items[i].key != SNeutrinoSettings::ITEM_MAX; i++) {
for (int i = 0; usermenu_items[i].key != SNeutrinoSettings::ITEM_MAX; i++)
{
const char *loc = g_Locale->getText(usermenu_items[i].value);
if (usermenu_items[i].show)
options.push_back(loc);
@@ -127,10 +129,12 @@ CUserMenuSetup::CUserMenuSetup(neutrino_locale_t menue_title, int menue_button)
}
int number_of_plugins = g_Plugins->getNumberOfPlugins();
for (int count = 0; count < number_of_plugins; count++) {
for (int count = 0; count < number_of_plugins; count++)
{
const char *loc = g_Plugins->getName(count);
const char *key = g_Plugins->getFileName(count);
if (loc && *loc && key && *key) {
if (loc && *loc && key && *key)
{
options.push_back(loc);
keys[loc] = key;
vals[keys[loc]] = loc;
@@ -145,9 +149,11 @@ CUserMenuSetup::~CUserMenuSetup()
int CUserMenuSetup::exec(CMenuTarget *parent, const std::string &actionKey)
{
if (actionKey == ">d") {
if (actionKey == ">d")
{
int selected = ums->getSelected();
if (selected >= item_offset) {
if (selected >= item_offset)
{
if (parent)
parent->hide();
ums->removeItem(selected);
@@ -160,7 +166,8 @@ int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &actionKey)
if (parent)
parent->hide();
if (actionKey == ">a") {
if (actionKey == ">a")
{
int selected = ums->getSelected();
CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
c->setOptions(options);
@@ -183,12 +190,14 @@ int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &actionKey)
static neutrino_locale_t locals[SNeutrinoSettings::ITEM_MAX];
neutrino_locale_t CUserMenuSetup::getLocale(unsigned int key)
{
if(key >= SNeutrinoSettings::ITEM_MAX){
if (key >= SNeutrinoSettings::ITEM_MAX)
{
key = SNeutrinoSettings::ITEM_NONE;
}
static bool initialized = false;
if (!initialized) {
if (!initialized)
{
initialized = true;
for (int i = 0; i < SNeutrinoSettings::ITEM_MAX; i++)
locals[i] = NONEXISTANT_LOCALE;
@@ -211,7 +220,8 @@ int CUserMenuSetup::showSetup()
ums->addItem(mf);
if (button >= SNeutrinoSettings::BUTTON_MAX) {
if (button >= SNeutrinoSettings::BUTTON_MAX)
{
CKeyChooser *kc = new CKeyChooser(&g_settings.usermenu[button]->key, LOCALE_USERMENU_KEY_SELECT, NEUTRINO_ICON_SETTINGS);
CMenuDForwarder *kf = new CMenuDForwarder(LOCALE_USERMENU_KEY, true, kc->getKeyName(), kc);
ums->addItem(kf);
@@ -221,7 +231,8 @@ int CUserMenuSetup::showSetup()
std::vector<std::string> items = ::split(g_settings.usermenu[button]->items, ',');
item_offset = ums->getItemsCount();
for (std::vector<std::string>::iterator it = items.begin(); it != items.end(); ++it) {
for (std::vector<std::string>::iterator it = items.begin(); it != items.end(); ++it)
{
CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
c->setTitle(LOCALE_USERMENU_ITEMS);
c->setOptions(options);
@@ -229,7 +240,8 @@ int CUserMenuSetup::showSetup()
ums->addItem(c);
}
const struct button_label footerButtons[2] = {
const struct button_label footerButtons[2] =
{
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_BOUQUETEDITOR_DELETE },
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD }
};
@@ -243,7 +255,8 @@ int CUserMenuSetup::showSetup()
const char *delim = "";
g_settings.usermenu[button]->items = "";
std::string none = to_string(SNeutrinoSettings::ITEM_NONE);
for (int count = item_offset; count < items_end; count++) {
for (int count = item_offset; count < items_end; count++)
{
std::string lk = keys[static_cast<CMenuOptionStringChooser *>(ums->getItem(count))->getOptionValue()];
if (lk == none)
continue;
@@ -268,7 +281,8 @@ void CUserMenuSetup::checkButtonName()
// warn if no items defined and reset menu name, if empty
if (used_items == 0)
{
if (!g_settings.usermenu[button]->title.empty()){
if (!g_settings.usermenu[button]->title.empty())
{
//DisplayInfoMessage(g_Locale->getText(LOCALE_USERMENU_MSG_WARNING_NO_ITEMS));
g_settings.usermenu[button]->title = "";
}
@@ -278,7 +292,8 @@ void CUserMenuSetup::checkButtonName()
#if 0
// if found only 1 configured item, ensure that the caption of usermenu is the same like this
if (used_items == 1) {
if (used_items == 1)
{
bool dummy;
g_settings.usermenu[button]->title = CUserMenu::getUserMenuButtonName(button, dummy);
}