mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
tuxbox-port: modul files added
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@894 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
283
src/gui/keybind_setup.cpp
Normal file
283
src/gui/keybind_setup.cpp
Normal file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
$port: keybind_setup.cpp,v 1.4 2010/09/20 10:24:12 tuxbox-cvs Exp $
|
||||
|
||||
keybindings setup implementation - Neutrino-GUI
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
and some other guys
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
Copyright (C) 2010 T. Graf 'dbt'
|
||||
Homepage: http://www.dbox2-tuning.net/
|
||||
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "gui/keybind_setup.h"
|
||||
#include "gui/user_menue_setup.h"
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include <mymenu.h>
|
||||
|
||||
#include <gui/widget/icons.h>
|
||||
#include <gui/widget/stringinput.h>
|
||||
|
||||
#include "gui/filebrowser.h"
|
||||
|
||||
#include <driver/screen_max.h>
|
||||
|
||||
#include <system/debug.h>
|
||||
|
||||
|
||||
CKeybindSetup::CKeybindSetup()
|
||||
{
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
|
||||
keySetupNotifier = new CKeySetupNotifier;
|
||||
keySetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
|
||||
|
||||
width = w_max (30, 10);
|
||||
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
|
||||
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
height = hheight+13*mheight+ 10;
|
||||
x = getScreenStartX (width);
|
||||
y = getScreenStartY (height);
|
||||
}
|
||||
|
||||
CKeybindSetup::~CKeybindSetup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CKeybindSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
{
|
||||
dprintf(DEBUG_DEBUG, "init keybindings setup\n");
|
||||
int res = menu_return::RETURN_REPAINT;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
parent->hide();
|
||||
}
|
||||
|
||||
if(actionKey == "loadkeys") {
|
||||
CFileBrowser fileBrowser;
|
||||
CFileFilter fileFilter;
|
||||
fileFilter.addFilter("conf");
|
||||
fileBrowser.Filter = &fileFilter;
|
||||
if (fileBrowser.exec("/var/tuxbox/config") == true) {
|
||||
CNeutrinoApp::getInstance()->loadKeys(fileBrowser.getSelectedFile()->Name.c_str());
|
||||
printf("[neutrino keybind_setup] new keys: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
|
||||
}
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
else if(actionKey == "savekeys") {
|
||||
CFileBrowser fileBrowser;
|
||||
fileBrowser.Dir_Mode = true;
|
||||
if (fileBrowser.exec("/var/tuxbox") == true) {
|
||||
char fname[256] = "keys.conf", sname[256];
|
||||
CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVEKEYS, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. ");
|
||||
sms->exec(NULL, "");
|
||||
sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname);
|
||||
printf("[neutrino keybind_setup] save keys: %s\n", sname);
|
||||
CNeutrinoApp::getInstance()->saveKeys(sname);
|
||||
delete sms;
|
||||
}
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
showKeySetup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void CKeybindSetup::hide()
|
||||
{
|
||||
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
|
||||
}
|
||||
|
||||
#define KEYBINDINGMENU_BOUQUETHANDLING_OPTION_COUNT 3
|
||||
const CMenuOptionChooser::keyval KEYBINDINGMENU_BOUQUETHANDLING_OPTIONS[KEYBINDINGMENU_BOUQUETHANDLING_OPTION_COUNT] =
|
||||
{
|
||||
{ 0, LOCALE_KEYBINDINGMENU_BOUQUETCHANNELS_ON_OK },
|
||||
{ 1, LOCALE_KEYBINDINGMENU_BOUQUETLIST_ON_OK },
|
||||
{ 2, LOCALE_KEYBINDINGMENU_ALLCHANNELS_ON_OK }
|
||||
};
|
||||
|
||||
typedef struct key_settings_t
|
||||
{
|
||||
const neutrino_locale_t keydescription;
|
||||
int * keyvalue_p;
|
||||
|
||||
} key_settings_struct_t;
|
||||
|
||||
const key_settings_struct_t key_settings[CKeybindSetup::KEYBINDS_COUNT] =
|
||||
{
|
||||
{LOCALE_KEYBINDINGMENU_TVRADIOMODE, &g_settings.key_tvradio_mode, },
|
||||
{LOCALE_KEYBINDINGMENU_POWEROFF, &g_settings.key_power_off, },
|
||||
{LOCALE_KEYBINDINGMENU_PAGEUP, &g_settings.key_channelList_pageup, },
|
||||
{LOCALE_KEYBINDINGMENU_PAGEDOWN, &g_settings.key_channelList_pagedown, },
|
||||
{LOCALE_EXTRA_KEY_LIST_START, &g_settings.key_list_start, },
|
||||
{LOCALE_EXTRA_KEY_LIST_END, &g_settings.key_list_end, },
|
||||
{LOCALE_KEYBINDINGMENU_CANCEL, &g_settings.key_channelList_cancel, },
|
||||
{LOCALE_KEYBINDINGMENU_SORT, &g_settings.key_channelList_sort, },
|
||||
{LOCALE_KEYBINDINGMENU_ADDRECORD, &g_settings.key_channelList_addrecord, },
|
||||
{LOCALE_KEYBINDINGMENU_ADDREMIND, &g_settings.key_channelList_addremind, },
|
||||
{LOCALE_KEYBINDINGMENU_BOUQUETUP, &g_settings.key_bouquet_up, },
|
||||
{LOCALE_KEYBINDINGMENU_BOUQUETDOWN, &g_settings.key_bouquet_down, },
|
||||
{LOCALE_KEYBINDINGMENU_CHANNELUP, &g_settings.key_quickzap_up, },
|
||||
{LOCALE_KEYBINDINGMENU_CHANNELDOWN, &g_settings.key_quickzap_down, },
|
||||
{LOCALE_KEYBINDINGMENU_SUBCHANNELUP, &g_settings.key_subchannel_up, },
|
||||
{LOCALE_KEYBINDINGMENU_SUBCHANNELDOWN, &g_settings.key_subchannel_down, },
|
||||
{LOCALE_KEYBINDINGMENU_ZAPHISTORY, &g_settings.key_zaphistory, },
|
||||
{LOCALE_KEYBINDINGMENU_LASTCHANNEL, &g_settings.key_lastchannel, },
|
||||
{LOCALE_MPKEY_REWIND, &g_settings.mpkey_rewind, },
|
||||
{LOCALE_MPKEY_FORWARD, &g_settings.mpkey_forward, },
|
||||
{LOCALE_MPKEY_PAUSE, &g_settings.mpkey_pause, },
|
||||
{LOCALE_MPKEY_STOP, &g_settings.mpkey_stop, },
|
||||
{LOCALE_MPKEY_PLAY, &g_settings.mpkey_play, },
|
||||
{LOCALE_MPKEY_AUDIO, &g_settings.mpkey_audio, },
|
||||
{LOCALE_MPKEY_TIME, &g_settings.mpkey_time, },
|
||||
{LOCALE_MPKEY_BOOKMARK, &g_settings.mpkey_bookmark, },
|
||||
{LOCALE_EXTRA_KEY_TIMESHIFT, &g_settings.key_timeshift, },
|
||||
{LOCALE_MPKEY_PLUGIN, &g_settings.mpkey_plugin, },
|
||||
{LOCALE_EXTRA_KEY_PLUGIN, &g_settings.key_plugin, },
|
||||
{LOCALE_EXTRA_KEY_UNLOCK, &g_settings.key_unlock, },
|
||||
};
|
||||
|
||||
|
||||
void CKeybindSetup::showKeySetup()
|
||||
{
|
||||
//keysetup menu
|
||||
CMenuWidget* keySettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
|
||||
//keybindings menu
|
||||
CMenuWidget* bindSettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
|
||||
keySettings->addIntroItems(LOCALE_MAINSETTINGS_KEYBINDING);
|
||||
|
||||
//keybindings
|
||||
int shortcut = 1;
|
||||
showKeyBindSetup(bindSettings);
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_HEAD, true, NULL, bindSettings, NULL, CRCInput::convertDigitToKey(shortcut++)));
|
||||
keySettings->addItem(GenericMenuSeparator);
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_EXTRA_LOADKEYS, true, NULL, this, "loadkeys", CRCInput::convertDigitToKey(shortcut++)));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_EXTRA_SAVEKEYS, true, NULL, this, "savekeys", CRCInput::convertDigitToKey(shortcut++)));
|
||||
|
||||
//rc tuning
|
||||
keySetupNotifier = new CKeySetupNotifier;
|
||||
CStringInput * keySettings_repeat_genericblocker = new CStringInput(LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC, g_settings.repeat_genericblocker, 3, LOCALE_REPEATBLOCKER_HINT_1, LOCALE_REPEATBLOCKER_HINT_2, "0123456789 ", keySetupNotifier);
|
||||
CStringInput * keySettings_repeatBlocker = new CStringInput(LOCALE_KEYBINDINGMENU_REPEATBLOCK, g_settings.repeat_blocker, 3, LOCALE_REPEATBLOCKER_HINT_1, LOCALE_REPEATBLOCKER_HINT_2, "0123456789 ", keySetupNotifier);
|
||||
keySetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
|
||||
|
||||
keySettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_RC));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_REPEATBLOCK, true, g_settings.repeat_blocker, keySettings_repeatBlocker));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC, true, g_settings.repeat_genericblocker, keySettings_repeat_genericblocker));
|
||||
|
||||
//user menues
|
||||
keySettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_USERMENU_HEAD));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_USERMENU_BUTTON_RED, true, NULL, new CUserMenuSetup(LOCALE_USERMENU_BUTTON_RED,0), NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_USERMENU_BUTTON_GREEN, true, NULL, new CUserMenuSetup(LOCALE_USERMENU_BUTTON_GREEN,1), NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_USERMENU_BUTTON_YELLOW, true, NULL, new CUserMenuSetup(LOCALE_USERMENU_BUTTON_YELLOW,2), NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
|
||||
keySettings->addItem(new CMenuForwarder(LOCALE_USERMENU_BUTTON_BLUE, true, NULL, new CUserMenuSetup(LOCALE_USERMENU_BUTTON_BLUE,3), NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE));
|
||||
|
||||
keySettings->exec(NULL, "");
|
||||
keySettings->hide();
|
||||
delete keySettings;
|
||||
}
|
||||
|
||||
|
||||
void CKeybindSetup::showKeyBindSetup(CMenuWidget *bindSettings)
|
||||
{
|
||||
bindSettings->addIntroItems(LOCALE_KEYBINDINGMENU_HEAD);
|
||||
|
||||
for (int i = 0; i < KEYBINDS_COUNT; i++)
|
||||
keychooser[i] = new CKeyChooser(key_settings[i].keyvalue_p, key_settings[i].keydescription/*as head caption*/, NEUTRINO_ICON_SETTINGS);
|
||||
|
||||
//modes
|
||||
CMenuWidget* bindSettings_modes = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
showKeyBindModeSetup(bindSettings_modes);
|
||||
bindSettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_MODECHANGE, true, NULL, bindSettings_modes, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
|
||||
|
||||
// channellist keybindings
|
||||
CMenuWidget* bindSettings_chlist = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
showKeyBindChannellistSetup(bindSettings_chlist);
|
||||
bindSettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_CHANNELLIST, true, NULL, bindSettings_chlist, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
|
||||
|
||||
// Zapping keys quickzap
|
||||
CMenuWidget* bindSettings_qzap = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
showKeyBindQuickzapSetup(bindSettings_qzap);
|
||||
bindSettings->addItem(new CMenuForwarder(LOCALE_KEYBINDINGMENU_QUICKZAP, true, NULL, bindSettings_qzap, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
|
||||
|
||||
//movieplayer
|
||||
CMenuWidget* bindSettings_mplayer = new CMenuWidget(LOCALE_KEYBINDINGMENU_HEAD, NEUTRINO_ICON_KEYBINDING, width);
|
||||
showKeyBindMovieplayerSetup(bindSettings_mplayer);
|
||||
bindSettings->addItem(new CMenuForwarder(LOCALE_MAINMENU_MOVIEPLAYER, true, NULL, bindSettings_mplayer, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE));
|
||||
|
||||
//misc
|
||||
bindSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_MISC));
|
||||
//bindSettings->addItem(new CMenuForwarder(keydescription[KEY_PLUGIN], true, NULL, keychooser[KEY_PLUGIN]));
|
||||
bindSettings->addItem(new CMenuForwarder(key_settings[KEY_UNLOCK].keydescription, true, NULL, keychooser[KEY_UNLOCK]));
|
||||
//bindSettings->addItem(new CMenuOptionChooser(LOCALE_EXTRA_ZAP_CYCLE, &g_settings.zap_cycle, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
|
||||
bindSettings->addItem(new CMenuOptionChooser(LOCALE_EXTRA_MENU_LEFT_EXIT, &g_settings.menu_left_exit, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
|
||||
|
||||
bindSettings->addItem(new CMenuOptionChooser(LOCALE_EXTRA_AUDIO_RUN_PLAYER, &g_settings.audio_run_player, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
|
||||
}
|
||||
|
||||
void CKeybindSetup::showKeyBindModeSetup(CMenuWidget *bindSettings_modes)
|
||||
{
|
||||
bindSettings_modes->addIntroItems(LOCALE_KEYBINDINGMENU_MODECHANGE);
|
||||
|
||||
bindSettings_modes->addItem(new CMenuForwarder(key_settings[KEY_TV_RADIO_MODE].keydescription, true, NULL, keychooser[KEY_TV_RADIO_MODE], NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
|
||||
bindSettings_modes->addItem(new CMenuForwarder(key_settings[KEY_POWER_OFF].keydescription, true, NULL, keychooser[KEY_POWER_OFF], NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
|
||||
}
|
||||
|
||||
void CKeybindSetup::showKeyBindChannellistSetup(CMenuWidget *bindSettings_chlist)
|
||||
{
|
||||
bindSettings_chlist->addIntroItems(LOCALE_KEYBINDINGMENU_CHANNELLIST);
|
||||
CMenuOptionChooser *oj = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_BOUQUETHANDLING, &g_settings.bouquetlist_mode, KEYBINDINGMENU_BOUQUETHANDLING_OPTIONS, KEYBINDINGMENU_BOUQUETHANDLING_OPTION_COUNT, true );
|
||||
bindSettings_chlist->addItem(oj);
|
||||
|
||||
for (int i = KEY_PAGE_UP; i <= KEY_BOUQUET_DOWN; i++)
|
||||
bindSettings_chlist->addItem(new CMenuForwarder(key_settings[i].keydescription, true, NULL, keychooser[i]));
|
||||
|
||||
bindSettings_chlist->addItem(new CMenuOptionChooser(LOCALE_EXTRA_SMS_CHANNEL, &g_settings.sms_channel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
|
||||
}
|
||||
|
||||
void CKeybindSetup::showKeyBindQuickzapSetup(CMenuWidget *bindSettings_qzap)
|
||||
{
|
||||
bindSettings_qzap->addIntroItems(LOCALE_KEYBINDINGMENU_QUICKZAP);
|
||||
|
||||
for (int i = KEY_CHANNEL_UP; i <= KEY_LASTCHANNEL; i++)
|
||||
bindSettings_qzap->addItem(new CMenuForwarder(key_settings[i].keydescription, true, NULL, keychooser[i]));
|
||||
}
|
||||
|
||||
void CKeybindSetup::showKeyBindMovieplayerSetup(CMenuWidget *bindSettings_mplayer)
|
||||
{
|
||||
bindSettings_mplayer->addIntroItems(LOCALE_MAINMENU_MOVIEPLAYER);
|
||||
|
||||
for (int i = MPKEY_REWIND; i <= MPKEY_PLUGIN; i++)
|
||||
bindSettings_mplayer->addItem(new CMenuForwarder(key_settings[i].keydescription, true, NULL, keychooser[i]));
|
||||
}
|
||||
|
Reference in New Issue
Block a user