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

Conflicts:
	src/gui/keybind_setup.cpp

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-06 19:25:46 +01:00
committed by Thilo Graf
parent ed0ac34fa2
commit 469a3de228
2 changed files with 125 additions and 99 deletions

View File

@@ -92,21 +92,25 @@ int CKeybindSetup::exec(CMenuTarget* parent, const std::string &actionKey)
parent->hide(); parent->hide();
} }
if(actionKey == "loadkeys") { if (actionKey == "loadkeys")
{
CFileBrowser fileBrowser; CFileBrowser fileBrowser;
CFileFilter fileFilter; CFileFilter fileFilter;
fileFilter.addFilter("conf"); fileFilter.addFilter("conf");
fileBrowser.Filter = &fileFilter; fileBrowser.Filter = &fileFilter;
if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true) { if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true)
{
CNeutrinoApp::getInstance()->loadKeys(fileBrowser.getSelectedFile()->Name.c_str()); CNeutrinoApp::getInstance()->loadKeys(fileBrowser.getSelectedFile()->Name.c_str());
printf("[neutrino keybind_setup] new keys: %s\n", fileBrowser.getSelectedFile()->Name.c_str()); printf("[neutrino keybind_setup] new keys: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
for (int i = 0; i < KEYBINDS_COUNT; i++){ for (int i = 0; i < KEYBINDS_COUNT; i++)
{
keychooser[i]->reinitName(); keychooser[i]->reinitName();
} }
} }
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }
else if(actionKey == "savekeys") { else if (actionKey == "savekeys")
{
CFileBrowser fileBrowser; CFileBrowser fileBrowser;
char msgtxt[1024]; char msgtxt[1024];
@@ -307,7 +311,8 @@ int CKeybindSetup::showKeySetup()
keySettings->addItem(mc); keySettings->addItem(mc);
#endif #endif
if (RC_HW_SELECT) { if (RC_HW_SELECT)
{
CMenuOptionChooser *mc = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE, CMenuOptionChooser *mc = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE,
&g_settings.remote_control_hardware, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTIONS, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTION_COUNT, true, NULL, &g_settings.remote_control_hardware, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTIONS, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTION_COUNT, true, NULL,
CRCInput::convertDigitToKey(shortcut++)); CRCInput::convertDigitToKey(shortcut++));
@@ -334,13 +339,15 @@ int CKeybindSetup::showKeySetup()
int res = keySettings->exec(NULL, ""); int res = keySettings->exec(NULL, "");
// check if rc hardware selection has changed before leaving the menu // check if rc hardware selection has changed before leaving the menu
if (org_remote_control_hardware != g_settings.remote_control_hardware) { if (org_remote_control_hardware != g_settings.remote_control_hardware)
{
g_RCInput->CRCInput::set_rc_hw(); g_RCInput->CRCInput::set_rc_hw();
strcat(RC_HW_msg, RC_HW_str[org_remote_control_hardware]); strcat(RC_HW_msg, RC_HW_str[org_remote_control_hardware]);
strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART2)); strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART2));
strcat(RC_HW_msg, RC_HW_str[g_settings.remote_control_hardware]); strcat(RC_HW_msg, RC_HW_str[g_settings.remote_control_hardware]);
strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART3)); strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART3));
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMsgBox::mbrNo) { if (ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMsgBox::mbrNo)
{
g_settings.remote_control_hardware = org_remote_control_hardware; g_settings.remote_control_hardware = org_remote_control_hardware;
g_RCInput->CRCInput::set_rc_hw(); g_RCInput->CRCInput::set_rc_hw();
} }
@@ -375,7 +382,7 @@ void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
mf->setHint("", LOCALE_MENU_HINT_KEY_CHANNELLIST); mf->setHint("", LOCALE_MENU_HINT_KEY_CHANNELLIST);
bindSettings->addItem(mf); bindSettings->addItem(mf);
// Zapping keys quickzap // zapping keys quickzap
CMenuWidget *bindSettings_qzap = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP_KEYBINDING_QUICKZAP); CMenuWidget *bindSettings_qzap = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP_KEYBINDING_QUICKZAP);
showKeyBindQuickzapSetup(bindSettings_qzap); showKeyBindQuickzapSetup(bindSettings_qzap);
mf = new CMenuDForwarder(LOCALE_KEYBINDINGMENU_QUICKZAP, true, NULL, bindSettings_qzap, NULL, CRCInput::RC_yellow); mf = new CMenuDForwarder(LOCALE_KEYBINDINGMENU_QUICKZAP, true, NULL, bindSettings_qzap, NULL, CRCInput::RC_yellow);
@@ -398,7 +405,8 @@ void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
// video // video
bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_VIDEO)); bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_VIDEO));
for (int i = NKEY_NEXT43MODE; i <= NKEY_SWITCHFORMAT; i++) { for (int i = NKEY_NEXT43MODE; i <= NKEY_SWITCHFORMAT; i++)
{
mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings->addItem(mf); bindSettings->addItem(mf);
@@ -406,7 +414,8 @@ void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
// navigation // navigation
bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_NAVIGATION)); bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_NAVIGATION));
for (int i = NKEY_PAGE_UP; i <= NKEY_PAGE_DOWN; i++) { for (int i = NKEY_PAGE_UP; i <= NKEY_PAGE_DOWN; i++)
{
mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings->addItem(mf); bindSettings->addItem(mf);
@@ -424,7 +433,7 @@ void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_MISC)); bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_MISC));
//bindSettings->addItem(new CMenuForwarder(keydescription[NKEY_PLUGIN], true, NULL, keychooser[NKEY_PLUGIN])); //bindSettings->addItem(new CMenuForwarder(keydescription[NKEY_PLUGIN], true, NULL, keychooser[NKEY_PLUGIN]));
//Special keys // special keys
CMenuWidget *bindSettings_special = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP_KEYBINDING_SPECIAL); CMenuWidget *bindSettings_special = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP_KEYBINDING_SPECIAL);
showKeyBindSpecialSetup(bindSettings_special); showKeyBindSpecialSetup(bindSettings_special);
mf = new CMenuDForwarder(LOCALE_KEYBINDINGMENU_SPECIAL_ACTIVE, true, NULL, bindSettings_special, NULL, CRCInput::convertDigitToKey(shortcut++)); mf = new CMenuDForwarder(LOCALE_KEYBINDINGMENU_SPECIAL_ACTIVE, true, NULL, bindSettings_special, NULL, CRCInput::convertDigitToKey(shortcut++));
@@ -471,6 +480,7 @@ void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
bindSettings->addItem(new CMenuForwarder(key_settings[NKEY_RECORD].keydescription, true, keychooser[NKEY_RECORD]->getKeyName(), keychooser[NKEY_RECORD])); bindSettings->addItem(new CMenuForwarder(key_settings[NKEY_RECORD].keydescription, true, keychooser[NKEY_RECORD]->getKeyName(), keychooser[NKEY_RECORD]));
bindSettings->addItem(new CMenuSeparator()); bindSettings->addItem(new CMenuSeparator());
// left/right keys // left/right keys
mc = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV, &g_settings.mode_left_right_key_tv, KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV_OPTIONS, KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV_COUNT, true); mc = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV, &g_settings.mode_left_right_key_tv, KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV_OPTIONS, KEYBINDINGMENU_MODE_LEFT_RIGHT_KEY_TV_COUNT, true);
mc->setHint("", LOCALE_MENU_HINT_KEY_RIGHT); mc->setHint("", LOCALE_MENU_HINT_KEY_RIGHT);
@@ -503,7 +513,8 @@ void CKeybindSetup::showKeyBindChannellistSetup(CMenuWidget *bindSettings_chlist
CMenuOptionChooser *oj = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_BOUQUETHANDLING, &g_settings.bouquetlist_mode, KEYBINDINGMENU_BOUQUETHANDLING_OPTIONS, KEYBINDINGMENU_BOUQUETHANDLING_OPTION_COUNT, true); CMenuOptionChooser *oj = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_BOUQUETHANDLING, &g_settings.bouquetlist_mode, KEYBINDINGMENU_BOUQUETHANDLING_OPTIONS, KEYBINDINGMENU_BOUQUETHANDLING_OPTION_COUNT, true);
bindSettings_chlist->addItem(oj); bindSettings_chlist->addItem(oj);
#endif #endif
for (int i = NKEY_LIST_START; i <= NKEY_CURRENT_TRANSPONDER; i++) { for (int i = NKEY_LIST_START; i <= NKEY_CURRENT_TRANSPONDER; i++)
{
CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings_chlist->addItem(mf); bindSettings_chlist->addItem(mf);
@@ -518,7 +529,8 @@ void CKeybindSetup::showKeyBindQuickzapSetup(CMenuWidget *bindSettings_qzap)
{ {
bindSettings_qzap->addIntroItems(LOCALE_KEYBINDINGMENU_QUICKZAP); bindSettings_qzap->addIntroItems(LOCALE_KEYBINDINGMENU_QUICKZAP);
for (int i = NKEY_CHANNEL_UP; i <= NKEY_LASTCHANNEL; i++) { for (int i = NKEY_CHANNEL_UP; i <= NKEY_LASTCHANNEL; i++)
{
CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings_qzap->addItem(mf); bindSettings_qzap->addItem(mf);
@@ -529,18 +541,29 @@ void CKeybindSetup::showKeyBindMovieplayerSetup(CMenuWidget *bindSettings_mplaye
{ {
bindSettings_mplayer->addIntroItems(LOCALE_MAINMENU_MOVIEPLAYER); bindSettings_mplayer->addIntroItems(LOCALE_MAINMENU_MOVIEPLAYER);
for (int i = MPKEY_PLAY; i <= MPKEY_PLUGIN; i++) { for (int i = MPKEY_PLAY; i <= MPKEY_PLUGIN; i++)
{
CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings_mplayer->addItem(mf); bindSettings_mplayer->addItem(mf);
} }
#if 0
bindSettings_mplayer->addItem(GenericMenuSeparatorLine);
// bisectional jumps
CMenuOptionNumberChooser *nc = new CMenuOptionNumberChooser(LOCALE_MOVIEPLAYER_BISECTION_JUMP, &g_settings.movieplayer_bisection_jump, true, 0, 10, this, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF);
nc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE));
nc->setHint("", LOCALE_MENU_HINT_MOVIEPLAYER_BISECTION_JUMP);
bindSettings_mplayer->addItem(nc);
#endif
} }
void CKeybindSetup::showKeyBindMoviebrowserSetup(CMenuWidget *bindSettings_mbrowser) void CKeybindSetup::showKeyBindMoviebrowserSetup(CMenuWidget *bindSettings_mbrowser)
{ {
bindSettings_mbrowser->addIntroItems(LOCALE_MOVIEBROWSER_HEAD); bindSettings_mbrowser->addIntroItems(LOCALE_MOVIEBROWSER_HEAD);
for (int i = MBKEY_COPY_ONEFILE; i <= MBKEY_COVER; i++) { for (int i = MBKEY_COPY_ONEFILE; i <= MBKEY_COVER; i++)
{
CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]); CMenuForwarder *mf = new CMenuForwarder(key_settings[i].keydescription, true, keychooser[i]->getKeyName(), keychooser[i]);
mf->setHint("", key_settings[i].hint); mf->setHint("", key_settings[i].hint);
bindSettings_mbrowser->addItem(mf); bindSettings_mbrowser->addItem(mf);
@@ -560,7 +583,8 @@ void CKeybindSetup::showKeyBindSpecialSetup(CMenuWidget *bindSettings_special)
else else
nkey = NKEY_PIC_MODE; nkey = NKEY_PIC_MODE;
for (; nkey <= NKEY_PIC_SIZE; nkey++) { for (; nkey <= NKEY_PIC_SIZE; nkey++)
{
CMenuOptionChooser *mf = new CMenuOptionChooser(key_settings[nkey].keydescription, key_settings[nkey].keyvalue_p, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); CMenuOptionChooser *mf = new CMenuOptionChooser(key_settings[nkey].keydescription, key_settings[nkey].keyvalue_p, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true);
mf->setHint("", key_settings[nkey].hint); mf->setHint("", key_settings[nkey].hint);
bindSettings_special->addItem(mf); bindSettings_special->addItem(mf);
@@ -570,14 +594,17 @@ void CKeybindSetup::showKeyBindSpecialSetup(CMenuWidget *bindSettings_special)
bool CKeybindSetup::changeNotify(const neutrino_locale_t OptionName, void * /* data */) bool CKeybindSetup::changeNotify(const neutrino_locale_t OptionName, void * /* data */)
{ {
#if 0 #if 0
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_ACCEPT_OTHER_REMOTES)) { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_ACCEPT_OTHER_REMOTES))
{
struct sockaddr_un sun; struct sockaddr_un sun;
memset(&sun, 0, sizeof(sun)); memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX; sun.sun_family = AF_UNIX;
strcpy(sun.sun_path, "/var/run/lirc/lircd"); strcpy(sun.sun_path, "/var/run/lirc/lircd");
int lircd_sock = socket(AF_UNIX, SOCK_STREAM, 0); int lircd_sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (lircd_sock > -1) { if (lircd_sock > -1)
if (!connect(lircd_sock, (struct sockaddr *) &sun, sizeof(sun))) { {
if (!connect(lircd_sock, (struct sockaddr *) &sun, sizeof(sun)))
{
if (g_settings.accept_other_remotes) if (g_settings.accept_other_remotes)
write(lircd_sock, "PREDATA_UNLOCK\n", 16); write(lircd_sock, "PREDATA_UNLOCK\n", 16);
else else
@@ -591,8 +618,8 @@ bool CKeybindSetup::changeNotify(const neutrino_locale_t OptionName, void * /* d
return false; return false;
} }
#endif #endif
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC) || if (ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC) || ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCK))
ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCK)) { {
unsigned int fdelay = g_settings.repeat_blocker; unsigned int fdelay = g_settings.repeat_blocker;
unsigned int xdelay = g_settings.repeat_genericblocker; unsigned int xdelay = g_settings.repeat_genericblocker;

View File

@@ -126,4 +126,3 @@ class CKeybindSetup : public CMenuTarget, public CChangeObserver
}; };
#endif #endif