int CUserMenuSetup::showSetup()
{
	mn_widget_id_t widget_id = (button < SNeutrinoSettings::BUTTON_MAX) ? MN_WIDGET_ID_USERMENU_RED + button : NO_WIDGET_ID;
	ums = new CMenuWidget(local, NEUTRINO_ICON_KEYBINDING, width, widget_id);

	ums->addIntroItems();

	int old_key = g_settings.usermenu[button]->key;
	CKeyboardInput name(LOCALE_USERMENU_NAME, &g_settings.usermenu[button]->title);
	CMenuForwarder * mf = new CMenuForwarder(LOCALE_USERMENU_NAME, true, NULL, &name);

	ums->addItem(mf);

	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);
	}

	ums->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, LOCALE_USERMENU_ITEMS));

	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) {
		CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
		c->setTitle(LOCALE_USERMENU_ITEMS);
		c->setOptions(options);
		c->setOptionValue(vals[*it]);
		ums->addItem(c);
	}

	const struct button_label footerButtons[2] = {
		{ NEUTRINO_ICON_BUTTON_RED, LOCALE_BOUQUETEDITOR_DELETE },
		{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_BOUQUETEDITOR_ADD }
	};
	ums->setFooter(footerButtons, 2);
	ums->addKey(CRCInput::RC_red, this, ">d");
	ums->addKey(CRCInput::RC_green, this, ">a");

	int res = ums->exec(NULL, "");
	int items_end = ums->getItemsCount();

	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++) {
		std::string lk = keys[static_cast<CMenuOptionStringChooser*>(ums->getItem(count))->getOptionValue()];
		if (lk == none)
			continue;
		g_settings.usermenu[button]->items += delim + lk;
		delim = ",";
	}

	delete ums;

	if (forwarder && (old_key != (int) g_settings.usermenu[button]->key))
		forwarder->setName(CRCInput::getKeyName(g_settings.usermenu[button]->key));

	return res;
}
int CUserMenuSetup::exec(CMenuTarget* parent, const std::string &actionKey)
{
	if (actionKey == ">d") {
		int selected = ums->getSelected();
		if (selected >= item_offset) {
			if(parent)
				parent->hide();
			ums->removeItem(selected);
			ums->hide();
			return menu_return::RETURN_REPAINT;
		}
		return menu_return::RETURN_NONE;
	}

	if(parent)
		parent->hide();

	if (actionKey == ">a") {
		int selected = ums->getSelected();
		CMenuOptionStringChooser *c = new CMenuOptionStringChooser(std::string(""), NULL, true, NULL, CRCInput::RC_nokey, NULL, true);
		c->setOptions(options);
		std::string n(g_Locale->getText(LOCALE_USERMENU_ITEM_NONE));
		c->setOptionValue(n);
		if (selected >= item_offset)
			ums->insertItem(selected, c);
		else
			ums->addItem(c);
		ums->hide();
		return menu_return::RETURN_REPAINT;
	}

	int res = showSetup();
	checkButtonName();
	
	return res; 
}