mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 02:11:11 +02:00
- usermenu-setup: formatting code using astyle; some manual code nicenings
Conflicts: src/gui/user_menue_setup.cpp Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
static bool usermenu_show = true;
|
static bool usermenu_show = true;
|
||||||
static bool usermenu_show_cam = true; // FIXME -- use hwcaps?
|
static bool usermenu_show_cam = true; // FIXME -- use hwcaps?
|
||||||
|
|
||||||
struct keyvals
|
struct keyvals
|
||||||
{
|
{
|
||||||
const int key;
|
const int key;
|
||||||
@@ -100,6 +101,9 @@ static keyvals usermenu_items[] =
|
|||||||
{ SNeutrinoSettings::ITEM_SWUPDATE, LOCALE_SERVICEMENU_UPDATE, usermenu_show },
|
{ SNeutrinoSettings::ITEM_SWUPDATE, LOCALE_SERVICEMENU_UPDATE, usermenu_show },
|
||||||
{ SNeutrinoSettings::ITEM_LIVESTREAM_RESOLUTION, LOCALE_LIVESTREAM_RESOLUTION, usermenu_show },
|
{ SNeutrinoSettings::ITEM_LIVESTREAM_RESOLUTION, LOCALE_LIVESTREAM_RESOLUTION, usermenu_show },
|
||||||
{ SNeutrinoSettings::ITEM_ADZAP, LOCALE_USERMENU_ITEM_ADZAP, usermenu_show },
|
{ SNeutrinoSettings::ITEM_ADZAP, LOCALE_USERMENU_ITEM_ADZAP, usermenu_show },
|
||||||
|
#if 0
|
||||||
|
{ SNeutrinoSettings::ITEM_TESTMENU, LOCALE_TESTMENU, usermenu_show },
|
||||||
|
#endif
|
||||||
{ SNeutrinoSettings::ITEM_FILEPLAY_AUDIO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_AUDIO, usermenu_show },
|
{ SNeutrinoSettings::ITEM_FILEPLAY_AUDIO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_AUDIO, usermenu_show },
|
||||||
{ SNeutrinoSettings::ITEM_TIMESHIFT, LOCALE_RECORDINGMENU_TIMESHIFT, usermenu_show },
|
{ SNeutrinoSettings::ITEM_TIMESHIFT, LOCALE_RECORDINGMENU_TIMESHIFT, usermenu_show },
|
||||||
{ SNeutrinoSettings::ITEM_MAX, NONEXISTANT_LOCALE, usermenu_show }
|
{ SNeutrinoSettings::ITEM_MAX, NONEXISTANT_LOCALE, usermenu_show }
|
||||||
@@ -115,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
|
pref_name = g_settings.usermenu[button]->title; // set current button name as prefered name
|
||||||
forwarder = NULL;
|
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);
|
const char *loc = g_Locale->getText(usermenu_items[i].value);
|
||||||
if (usermenu_items[i].show)
|
if (usermenu_items[i].show)
|
||||||
options.push_back(loc);
|
options.push_back(loc);
|
||||||
@@ -124,10 +129,12 @@ CUserMenuSetup::CUserMenuSetup(neutrino_locale_t menue_title, int menue_button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int number_of_plugins = g_Plugins->getNumberOfPlugins();
|
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 *loc = g_Plugins->getName(count);
|
||||||
const char *key = g_Plugins->getFileName(count);
|
const char *key = g_Plugins->getFileName(count);
|
||||||
if (loc && *loc && key && *key) {
|
if (loc && *loc && key && *key)
|
||||||
|
{
|
||||||
options.push_back(loc);
|
options.push_back(loc);
|
||||||
keys[loc] = key;
|
keys[loc] = key;
|
||||||
vals[keys[loc]] = loc;
|
vals[keys[loc]] = loc;
|
||||||
@@ -142,9 +149,11 @@ CUserMenuSetup::~CUserMenuSetup()
|
|||||||
|
|
||||||
int CUserMenuSetup::exec(CMenuTarget *parent, const std::string &actionKey)
|
int CUserMenuSetup::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||||
{
|
{
|
||||||
if (actionKey == ">d") {
|
if (actionKey == ">d")
|
||||||
|
{
|
||||||
int selected = ums->getSelected();
|
int selected = ums->getSelected();
|
||||||
if (selected >= item_offset) {
|
if (selected >= item_offset)
|
||||||
|
{
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
ums->removeItem(selected);
|
ums->removeItem(selected);
|
||||||
@@ -157,7 +166,8 @@ int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
if (actionKey == ">a") {
|
if (actionKey == ">a")
|
||||||
|
{
|
||||||
int selected = ums->getSelected();
|
int selected = ums->getSelected();
|
||||||
CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
|
CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
|
||||||
c->setOptions(options);
|
c->setOptions(options);
|
||||||
@@ -180,12 +190,14 @@ int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
static neutrino_locale_t locals[SNeutrinoSettings::ITEM_MAX];
|
static neutrino_locale_t locals[SNeutrinoSettings::ITEM_MAX];
|
||||||
neutrino_locale_t CUserMenuSetup::getLocale(unsigned int key)
|
neutrino_locale_t CUserMenuSetup::getLocale(unsigned int key)
|
||||||
{
|
{
|
||||||
if(key >= SNeutrinoSettings::ITEM_MAX){
|
if (key >= SNeutrinoSettings::ITEM_MAX)
|
||||||
|
{
|
||||||
key = SNeutrinoSettings::ITEM_NONE;
|
key = SNeutrinoSettings::ITEM_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if (!initialized) {
|
if (!initialized)
|
||||||
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
for (int i = 0; i < SNeutrinoSettings::ITEM_MAX; i++)
|
for (int i = 0; i < SNeutrinoSettings::ITEM_MAX; i++)
|
||||||
locals[i] = NONEXISTANT_LOCALE;
|
locals[i] = NONEXISTANT_LOCALE;
|
||||||
@@ -208,7 +220,8 @@ int CUserMenuSetup::showSetup()
|
|||||||
|
|
||||||
ums->addItem(mf);
|
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);
|
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);
|
CMenuDForwarder *kf = new CMenuDForwarder(LOCALE_USERMENU_KEY, true, kc->getKeyName(), kc);
|
||||||
ums->addItem(kf);
|
ums->addItem(kf);
|
||||||
@@ -218,7 +231,8 @@ int CUserMenuSetup::showSetup()
|
|||||||
|
|
||||||
std::vector<std::string> items = ::split(g_settings.usermenu[button]->items, ',');
|
std::vector<std::string> items = ::split(g_settings.usermenu[button]->items, ',');
|
||||||
item_offset = ums->getItemsCount();
|
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);
|
CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
|
||||||
c->setTitle(LOCALE_USERMENU_ITEMS);
|
c->setTitle(LOCALE_USERMENU_ITEMS);
|
||||||
c->setOptions(options);
|
c->setOptions(options);
|
||||||
@@ -226,7 +240,8 @@ int CUserMenuSetup::showSetup()
|
|||||||
ums->addItem(c);
|
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_RED, LOCALE_BOUQUETEDITOR_DELETE },
|
||||||
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD }
|
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD }
|
||||||
};
|
};
|
||||||
@@ -240,7 +255,8 @@ int CUserMenuSetup::showSetup()
|
|||||||
const char *delim = "";
|
const char *delim = "";
|
||||||
g_settings.usermenu[button]->items = "";
|
g_settings.usermenu[button]->items = "";
|
||||||
std::string none = to_string(SNeutrinoSettings::ITEM_NONE);
|
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()];
|
std::string lk = keys[static_cast<CMenuOptionStringChooser *>(ums->getItem(count))->getOptionValue()];
|
||||||
if (lk == none)
|
if (lk == none)
|
||||||
continue;
|
continue;
|
||||||
@@ -265,7 +281,8 @@ void CUserMenuSetup::checkButtonName()
|
|||||||
// warn if no items defined and reset menu name, if empty
|
// warn if no items defined and reset menu name, if empty
|
||||||
if (used_items == 0)
|
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));
|
//DisplayInfoMessage(g_Locale->getText(LOCALE_USERMENU_MSG_WARNING_NO_ITEMS));
|
||||||
g_settings.usermenu[button]->title = "";
|
g_settings.usermenu[button]->title = "";
|
||||||
}
|
}
|
||||||
@@ -275,7 +292,8 @@ void CUserMenuSetup::checkButtonName()
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// if found only 1 configured item, ensure that the caption of usermenu is the same like this
|
// 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;
|
bool dummy;
|
||||||
g_settings.usermenu[button]->title = CUserMenu::getUserMenuButtonName(button, dummy);
|
g_settings.usermenu[button]->title = CUserMenu::getUserMenuButtonName(button, dummy);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user