diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index cc30301c0..173c1effe 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -81,6 +81,7 @@ libneutrino_gui_a_SOURCES = \ sleeptimer.cpp \ software_update.cpp \ streaminfo2.cpp \ + subchannel_select.cpp \ test_menu.cpp \ themes.cpp \ timeosd.cpp \ diff --git a/src/gui/subchannel_select.cpp b/src/gui/subchannel_select.cpp new file mode 100644 index 000000000..c059e8344 --- /dev/null +++ b/src/gui/subchannel_select.cpp @@ -0,0 +1,123 @@ +/* + Neutrino-GUI - DBoxII-Project + Copyright (C) 2001 Steffen Hehn 'McClean' + Homepage: http://dbox.cyberphoria.org/ + + Rework: + Outsourced subchannel select modul for Neutrino-HD + Copyright (C) 2011 T.Graf 'dbt' + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + + + NOTE for ignorant distributors: + It's not allowed to distribute any compiled parts of this code, if you don't accept the terms of GPL. + Please read it and understand it right! + This means for you: Hold it, if not, leave it! You could face legal action! + Otherwise ask the copyright owners, anything else would be theft! +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include +#include +#include + +#include "gui/subchannel_select.h" +#include + +extern CRemoteControl * g_RemoteControl; + +CSubChannelSelectMenu::CSubChannelSelectMenu() +{ + +} + +CSubChannelSelectMenu::~CSubChannelSelectMenu() +{ + +} + +int CSubChannelSelectMenu::getNVODMenu(CMenuWidget* menu) +{ + if (menu == NULL) + return false; + if (g_RemoteControl->subChannels.empty()) + return false; + + menu->addItem(GenericMenuSeparator); + + int count = 0; + char nvod_id[5]; + + for ( CSubServiceListSorted::iterator e=g_RemoteControl->subChannels.begin(); e!=g_RemoteControl->subChannels.end(); ++e) + { + sprintf(nvod_id, "%d", count); + + t_channel_id subid = e->getChannelID(); + bool enabled = CRecordManager::getInstance()->SameTransponder(subid); + + if ( !g_RemoteControl->are_subchannels ) + { + char nvod_time_a[50], nvod_time_e[50], nvod_time_x[50]; + char nvod_s[100]; + struct tm *tmZeit; + + tmZeit= localtime(&e->startzeit); + sprintf(nvod_time_a, "%02d:%02d", tmZeit->tm_hour, tmZeit->tm_min); + + time_t endtime = e->startzeit+ e->dauer; + tmZeit= localtime(&endtime); + sprintf(nvod_time_e, "%02d:%02d", tmZeit->tm_hour, tmZeit->tm_min); + + time_t jetzt=time(NULL); + if (e->startzeit > jetzt) + { + int mins=(e->startzeit- jetzt)/ 60; + sprintf(nvod_time_x, g_Locale->getText(LOCALE_NVOD_STARTING), mins); + } + else if ( (e->startzeit<= jetzt) && (jetzt < endtime) ) + { + int proz=(jetzt- e->startzeit)*100/ e->dauer; + sprintf(nvod_time_x, g_Locale->getText(LOCALE_NVOD_PERCENTAGE), proz); + } + else + nvod_time_x[0]= 0; + + sprintf(nvod_s, "%s - %s %s", nvod_time_a, nvod_time_e, nvod_time_x); + menu->addItem(new CMenuForwarderNonLocalized(nvod_s, enabled, NULL, &NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); + } + else + { + menu->addItem(new CMenuForwarderNonLocalized(e->subservice_name.c_str(), enabled, NULL, &NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); + } + + count++; + } + + if ( g_RemoteControl->are_subchannels ) { + menu->addItem(GenericMenuSeparatorLine); + CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_NVODSELECTOR_DIRECTORMODE, &g_RemoteControl->director_mode, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW); + menu->addItem(oj); + } + return true; +} + + + + diff --git a/src/gui/subchannel_select.h b/src/gui/subchannel_select.h new file mode 100644 index 000000000..0f102f28b --- /dev/null +++ b/src/gui/subchannel_select.h @@ -0,0 +1,56 @@ +/* + Neutrino-GUI - DBoxII-Project + Copyright (C) 2001 Steffen Hehn 'McClean' + Homepage: http://dbox.cyberphoria.org/ + + Rework: + Outsourced subchannel select modul for Neutrino-HD + Copyright (C) 2011 T.Graf 'dbt' + 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., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + + + NOTE for ignorant distributors: + It's not allowed to distribute any compiled parts of this code, if you don't accept the terms of GPL. + Please read it and understand it right! + This means for you: Hold it, if not, leave it! You could face legal action! + Otherwise ask the copyright owners, anything else would be theft! +*/ + + +#ifndef __subchannel_selector__ +#define __subchannel_selector__ + + +#include "widget/menue.h" + + + +class CSubChannelSelectMenu +{ + private: + CNVODChangeExec NVODChanger; + + public: + CSubChannelSelectMenu(); + ~CSubChannelSelectMenu(); + + int getNVODMenu(CMenuWidget* menu); + +}; + + +#endif + diff --git a/src/gui/user_menue.h b/src/gui/user_menue.h new file mode 100644 index 000000000..c09248566 --- /dev/null +++ b/src/gui/user_menue.h @@ -0,0 +1,128 @@ +/* + $id$ + + user_menue setup implementation - Neutrino-GUI + based up implementation by Günther + + Copyright (C) 2001 Steffen Hehn 'McClean' + and some other guys + Homepage: http://dbox.cyberphoria.org/ + + Copyright (C) 2011 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. + +*/ + +#ifndef __user_menue__ +#define __user_menue__ + +#include +#include +#include + +#include + +// USERMENU: colorbuttons only +typedef struct user_menu_data_t +{ + neutrino_locale_t caption; + const neutrino_msg_t key_helper_msg_def; + const char * key_helper_icon_def; + const char * menu_icon_def; + int selected; +} user_menu_data_struct; + +#define COL_BUTTONMAX SNeutrinoSettings::BUTTON_MAX +static user_menu_data_t user_menu[COL_BUTTONMAX]= +{ + {LOCALE_INFOVIEWER_EVENTLIST , CRCInput::RC_red , NEUTRINO_ICON_BUTTON_RED , NEUTRINO_ICON_RED, -1}, + {LOCALE_INFOVIEWER_LANGUAGES , CRCInput::RC_green , NEUTRINO_ICON_BUTTON_GREEN , NEUTRINO_ICON_GREEN, -1}, + {NONEXISTANT_LOCALE , CRCInput::RC_yellow , NEUTRINO_ICON_BUTTON_YELLOW , NEUTRINO_ICON_YELLOW, -1}, + {LOCALE_INFOVIEWER_STREAMINFO , CRCInput::RC_blue , NEUTRINO_ICON_BUTTON_BLUE , NEUTRINO_ICON_FEATURES, -1} +}; + + +// This is just a quick helper for the usermenu only. +class CColorKeyHelper +{ + private: + int number_key; + bool color_key_used[COL_BUTTONMAX]; + public: + CColorKeyHelper() + { + reset(); + }; + + void reset(void) + { + number_key = 1; + for (int i= 0; i < COL_BUTTONMAX; i++ ) + color_key_used[i] = false; + }; + + /* Returns the next available button, to be used in menu as 'direct' keys. Appropriate + * definitions are returnd in msp and icon + * A color button could be requested as prefered button (other buttons are not supported yet). + * If the appropriate button is already in used, the next number_key button is returned instead + * (first 1-9 and than 0). */ + bool get(neutrino_msg_t* msg, const char** icon, neutrino_msg_t prefered_key = CRCInput::RC_nokey) + { + bool result = false; + int button = -1; + if (prefered_key == CRCInput::RC_red) + button = 0; + if (prefered_key == CRCInput::RC_green) + button = 1; + if (prefered_key == CRCInput::RC_yellow) + button = 2; + if (prefered_key == CRCInput::RC_blue) + button = 3; + + *msg = CRCInput::RC_nokey; + *icon = ""; + if (button >= 0 && button < COL_BUTTONMAX) + { // try to get color button + if ( color_key_used[button] == false) + { + color_key_used[button] = true; + *msg = user_menu[button].key_helper_msg_def; + *icon = user_menu[button].key_helper_icon_def; + result = true; + } + } + + if ( result == false && number_key < 10) // no key defined yet, at least try to get a numbered key + { + // there is still a available number_key + *msg = CRCInput::convertDigitToKey(number_key); + *icon = ""; + if (number_key == 9) + number_key = 0; + else if (number_key == 0) + number_key = 10; + else + number_key++; + result = true; + } + return (result); + }; +}; + +#endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1825be7a3..30b34ee3b 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1974,7 +1974,6 @@ int CNeutrinoApp::run(int argc, char **argv) g_PluginList->loadPlugins(); APIDChanger = new CAPIDChangeExec; - NVODChanger = new CNVODChangeExec; StreamFeaturesChanger = new CStreamFeaturesChangeExec; MoviePluginChanger = new CMoviePluginChangeExec; ConsoleDestinationChanger = new CConsoleDestChangeNotifier; diff --git a/src/neutrino.h b/src/neutrino.h index f6eb794f5..f8e6c7656 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -138,7 +138,6 @@ private: bool pbBlinkChange; CColorSetupNotifier *colorSetupNotifier; CNetworkSetup *networksetup; - CNVODChangeExec *NVODChanger; CStreamFeaturesChangeExec *StreamFeaturesChanger; CMoviePluginChangeExec *MoviePluginChanger; COnekeyPluginChangeExec *OnekeyPluginChanger; @@ -149,7 +148,6 @@ private: CTimerList *Timerlist; bool showUserMenu(int button); - bool getNVODMenu(CMenuWidget* menu); void firstChannel(); void setupNetwork( bool force= false ); @@ -171,8 +169,6 @@ private: void InitMainMenu(CMenuWidget &mainMenu, CMenuWidget &mainSettings, CMenuWidget &service); void SetupFrameBuffer(); - void SelectAPID(); - void SelectNVOD(); void CmdParser(int argc, char **argv); void saveColors(const char * fname); CNeutrinoApp(); diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 6d244312a..5a1d13499 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -73,10 +73,12 @@ #include "gui/sleeptimer.h" #include "gui/software_update.h" #include +#include "gui/subchannel_select.h" #ifdef TEST_MENU #include "gui/test_menu.h" #endif /*TEST_MENU*/ #include "gui/update.h" +#include "gui/user_menue.h" #include "gui/vfd_setup.h" #include @@ -272,99 +274,6 @@ void CNeutrinoApp::InitServiceSettings(CMenuWidget &service) } -// USERMENU -// leave this functions, somebody might want to use it in the future again -void CNeutrinoApp::SelectNVOD() -{ - if (!(g_RemoteControl->subChannels.empty())) - { - // NVOD/SubService- Kanal! - CMenuWidget NVODSelector(g_RemoteControl->are_subchannels ? LOCALE_NVODSELECTOR_SUBSERVICE : LOCALE_NVODSELECTOR_HEAD, NEUTRINO_ICON_VIDEO); - if (getNVODMenu(&NVODSelector)) - NVODSelector.exec(NULL, ""); - } -} - -bool CNeutrinoApp::getNVODMenu(CMenuWidget* menu) -{ - if (menu == NULL) - return false; - if (g_RemoteControl->subChannels.empty()) - return false; - - menu->addItem(GenericMenuSeparator); - - int count = 0; - char nvod_id[5]; - - for ( CSubServiceListSorted::iterator e=g_RemoteControl->subChannels.begin(); e!=g_RemoteControl->subChannels.end(); ++e) - { - sprintf(nvod_id, "%d", count); - - t_channel_id subid = e->getChannelID(); - bool enabled = CRecordManager::getInstance()->SameTransponder(subid); - - if ( !g_RemoteControl->are_subchannels ) { - char nvod_time_a[50], nvod_time_e[50], nvod_time_x[50]; - char nvod_s[100]; - struct tm *tmZeit; - - tmZeit= localtime(&e->startzeit); - sprintf(nvod_time_a, "%02d:%02d", tmZeit->tm_hour, tmZeit->tm_min); - - time_t endtime = e->startzeit+ e->dauer; - tmZeit= localtime(&endtime); - sprintf(nvod_time_e, "%02d:%02d", tmZeit->tm_hour, tmZeit->tm_min); - - time_t jetzt=time(NULL); - if (e->startzeit > jetzt) { - int mins=(e->startzeit- jetzt)/ 60; - sprintf(nvod_time_x, g_Locale->getText(LOCALE_NVOD_STARTING), mins); - } - else if ( (e->startzeit<= jetzt) && (jetzt < endtime) ) { - int proz=(jetzt- e->startzeit)*100/ e->dauer; - sprintf(nvod_time_x, g_Locale->getText(LOCALE_NVOD_PERCENTAGE), proz); - } - else - nvod_time_x[0]= 0; - - sprintf(nvod_s, "%s - %s %s", nvod_time_a, nvod_time_e, nvod_time_x); - menu->addItem(new CMenuForwarderNonLocalized(nvod_s, enabled, NULL, NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); - } else { - menu->addItem(new CMenuForwarderNonLocalized(e->subservice_name.c_str(), enabled, NULL, NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); - } - - count++; - } - - if ( g_RemoteControl->are_subchannels ) { - menu->addItem(GenericMenuSeparatorLine); - CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_NVODSELECTOR_DIRECTORMODE, &g_RemoteControl->director_mode, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW); - menu->addItem(oj); - } - return true; -} - -void CNeutrinoApp::SelectAPID() -{ -#if 0 - if ( g_RemoteControl->current_PIDs.APIDs.size()> 1 ) - { - // we have APIDs for this channel! - - CMenuWidget APIDSelector(LOCALE_APIDSELECTOR_HEAD, NEUTRINO_ICON_AUDIO); - APIDSelector.addItem(GenericMenuSeparator); - - for ( unsigned int count=0; countcurrent_PIDs.APIDs.size(); count++ ) - { - char apid[5]; - sprintf(apid, "%d", count); - APIDSelector.addItem(new CMenuForwarderNonLocalized(g_RemoteControl->current_PIDs.APIDs[count].desc, true, NULL, APIDChanger, apid, CRCInput::convertDigitToKey(count + 1)), (count == g_RemoteControl->current_PIDs.PIDs.selected_apid)); - } - APIDSelector.exec(NULL, ""); - } -#endif -} #define MAINMENU_RECORDING_OPTION_COUNT 2 const CMenuOptionChooser::keyval MAINMENU_RECORDING_OPTIONS[MAINMENU_RECORDING_OPTION_COUNT] = @@ -373,98 +282,15 @@ const CMenuOptionChooser::keyval MAINMENU_RECORDING_OPTIONS[MAINMENU_RECORDING_O { 1, LOCALE_MAINMENU_RECORDING_STOP } }; -// USERMENU -typedef struct user_menu_data_t -{ - neutrino_locale_t caption; - const neutrino_msg_t key_helper_msg_def; - const char * key_helper_icon_def; - const char * menu_icon_def; - int selected; -} user_menu_data_struct; - -#define BUTTONMAX SNeutrinoSettings::BUTTON_MAX -static user_menu_data_t user_menu[BUTTONMAX]= -{ - {LOCALE_INFOVIEWER_EVENTLIST , CRCInput::RC_red , NEUTRINO_ICON_BUTTON_RED , NEUTRINO_ICON_RED, -1}, - {LOCALE_INFOVIEWER_LANGUAGES , CRCInput::RC_green , NEUTRINO_ICON_BUTTON_GREEN , NEUTRINO_ICON_GREEN, -1}, - {NONEXISTANT_LOCALE , CRCInput::RC_yellow , NEUTRINO_ICON_BUTTON_YELLOW , NEUTRINO_ICON_YELLOW, -1}, - {LOCALE_INFOVIEWER_STREAMINFO , CRCInput::RC_blue , NEUTRINO_ICON_BUTTON_BLUE , NEUTRINO_ICON_FEATURES, -1} -}; - -// This is just a quick helper for the usermenu only. I already made it a class for future use. -class CKeyHelper -{ -private: - int number_key; - bool color_key_used[BUTTONMAX]; -public: - CKeyHelper() { - reset(); - }; - void reset(void) - { - number_key = 1; - for (int i= 0; i < BUTTONMAX; i++ ) - color_key_used[i] = false; - }; - - /* Returns the next available button, to be used in menu as 'direct' keys. Appropriate - * definitions are returnd in msp and icon - * A color button could be requested as prefered button (other buttons are not supported yet). - * If the appropriate button is already in used, the next number_key button is returned instead - * (first 1-9 and than 0). */ - bool get(neutrino_msg_t* msg, const char** icon, neutrino_msg_t prefered_key = CRCInput::RC_nokey) - { - bool result = false; - int button = -1; - if (prefered_key == CRCInput::RC_red) - button = 0; - if (prefered_key == CRCInput::RC_green) - button = 1; - if (prefered_key == CRCInput::RC_yellow) - button = 2; - if (prefered_key == CRCInput::RC_blue) - button = 3; - - *msg = CRCInput::RC_nokey; - *icon = ""; - if (button >= 0 && button < BUTTONMAX) - { // try to get color button - if ( color_key_used[button] == false) - { - color_key_used[button] = true; - *msg = user_menu[button].key_helper_msg_def; - *icon = user_menu[button].key_helper_icon_def; - result = true; - } - } - - if ( result == false && number_key < 10) // no key defined yet, at least try to get a numbered key - { - // there is still a available number_key - *msg = CRCInput::convertDigitToKey(number_key); - *icon = ""; - if (number_key == 9) - number_key = 0; - else if (number_key == 0) - number_key = 10; - else - number_key++; - result = true; - } - return (result); - }; -}; // USERMENU bool CNeutrinoApp::showUserMenu(int button) { - if (button < 0 || button >= BUTTONMAX) + if (button < 0 || button >= COL_BUTTONMAX) return false; CMenuItem* menu_item = NULL; - CKeyHelper keyhelper; + CColorKeyHelper keyhelper; neutrino_msg_t key = CRCInput::RC_nokey; const char * icon = NULL; int dummy; @@ -477,6 +303,7 @@ bool CNeutrinoApp::showUserMenu(int button) CPauseSectionsdNotifier* tmpPauseSectionsdNotifier = NULL; CAudioSelectMenuHandler* tmpAudioSelectMenuHandler = NULL; CMenuWidget* tmpNVODSelector = NULL; + CSubChannelSelectMenu subchanselect; CStreamInfo2Handler* tmpStreamInfo2Handler = NULL; CEventListHandler* tmpEventListHandler = NULL; CEPGplusHandler* tmpEPGplusHandler = NULL; @@ -625,7 +452,7 @@ bool CNeutrinoApp::showUserMenu(int button) if (!(g_RemoteControl->subChannels.empty())) { // NVOD/SubService- Kanal! tmpNVODSelector = new CMenuWidget(g_RemoteControl->are_subchannels ? LOCALE_NVODSELECTOR_SUBSERVICE : LOCALE_NVODSELECTOR_HEAD, NEUTRINO_ICON_VIDEO); - if (getNVODMenu(tmpNVODSelector)) { + if (subchanselect.getNVODMenu(tmpNVODSelector)) { menu_items++; menu_prev = SNeutrinoSettings::ITEM_SUBCHANNEL; keyhelper.get(&key,&icon);