diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index a50a0bdc0..57fa26b96 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -67,6 +67,7 @@ libneutrino_gui_a_SOURCES = \ infoviewer_bb.cpp \ keybind_setup.cpp \ lcd4l.cpp \ + lcd4l_setup.cpp \ mediaplayer.cpp \ mediaplayer_setup.cpp \ miscsettings_menu.cpp \ diff --git a/src/gui/lcd4l_setup.cpp b/src/gui/lcd4l_setup.cpp new file mode 100644 index 000000000..abd5335a7 --- /dev/null +++ b/src/gui/lcd4l_setup.cpp @@ -0,0 +1,183 @@ +/* + lcd4l setup + + Copyright (C) 2012 'defans' + Homepage: http://www.bluepeercrew.us/ + + Copyright (C) 2012-2016 'vanhofen' + Homepage: http://www.neutrino-images.de/ + + Modded (C) 2016 'TangoCash' + + 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 +#endif +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +// lcd4l-support +#include "gui/lcd4l.h" +extern CLCD4l *LCD4l; + +#define FLAG_DIR "/var/etc/" + +const CMenuOptionChooser::keyval LCD4L_SUPPORT_OPTIONS[] = +{ + { 0, LOCALE_LCD4L_SUPPORT_OFF }, + { 1, LOCALE_LCD4L_SUPPORT_AUTO }, + { 2, LOCALE_LCD4L_SUPPORT_ON } +}; +#define LCD4L_SUPPORT_OPTION_COUNT (sizeof(LCD4L_SUPPORT_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) + +const CMenuOptionChooser::keyval LCD4L_SKIN_OPTIONS[] = +{ + { 0, LOCALE_LCD4L_SKIN_0 }, + { 1, LOCALE_LCD4L_SKIN_1 }, + { 2, LOCALE_LCD4L_SKIN_2 }, + { 3, LOCALE_LCD4L_SKIN_3 }, + { 4, LOCALE_LCD4L_SKIN_4 } +}; +#define LCD4L_SKIN_OPTION_COUNT (sizeof(LCD4L_SKIN_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) + +CLCD4lSetup::CLCD4lSetup() +{ + width = 40; +} + +CLCD4lSetup::~CLCD4lSetup() +{ +} + +int CLCD4lSetup::exec(CMenuTarget* parent, const std::string &actionkey) +{ + printf("CLCD4lSetup::exec: actionkey %s\n", actionkey.c_str()); + int res = menu_return::RETURN_REPAINT; + + if (parent) + parent->hide(); + + if (actionkey == "lcd4l_logodir") { + const char *action_str = "lcd4l_logodir"; + chooserDir(g_settings.lcd4l_logodir, false, action_str); + return menu_return::RETURN_REPAINT; + } + + res = show(); + + return res; +} + +bool CLCD4lSetup::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) +{ +#if 0 + int value = 0; + + if (data) + value = (*(int *)data); +#endif + + if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCD4L_SUPPORT)) + { + LCD4l->StopLCD4l(); + if (g_settings.lcd4l_support) + LCD4l->StartLCD4l(); + } + + return false; +} + +int CLCD4lSetup::show() +{ + int shortcut = 1; + + int temp_lcd4l_skin = g_settings.lcd4l_skin; + + // lcd4l setup + CMenuWidget* lcd4lSetup = new CMenuWidget(LOCALE_LCD4L_SUPPORT, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_LCD4L_SETUP); + lcd4lSetup->addIntroItems(); + + mc = new CMenuOptionChooser(LOCALE_LCD4L_SUPPORT, &g_settings.lcd4l_support, LCD4L_SUPPORT_OPTIONS, LCD4L_SUPPORT_OPTION_COUNT, true, this, CRCInput::RC_red); + mc->setHint("", LOCALE_MENU_HINT_LCD4L_SUPPORT); + lcd4lSetup->addItem(mc); + lcd4lSetup->addItem(GenericMenuSeparatorLine); + + mf = new CMenuForwarder(LOCALE_LCD4L_LOGODIR, true, g_settings.lcd4l_logodir, this, "lcd4l_logodir", CRCInput::convertDigitToKey(shortcut++)); + mf->setHint("", LOCALE_MENU_HINT_LCD4L_LOGODIR); + lcd4lSetup->addItem(mf); + + mc = new CMenuOptionChooser(LOCALE_LCD4L_SKIN, &temp_lcd4l_skin, LCD4L_SKIN_OPTIONS, LCD4L_SKIN_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); + mc->setHint("", LOCALE_MENU_HINT_LCD4L_SKIN); + lcd4lSetup->addItem(mc); + + const char *flag_lcd4l_weather = FLAG_DIR ".lcd-weather"; + int fake_lcd4l_weather = file_exists(flag_lcd4l_weather); + CTouchFileNotifier * lcd_weather = new CTouchFileNotifier(flag_lcd4l_weather); + mc = new CMenuOptionChooser(LOCALE_LCD4L_WEATHER, &fake_lcd4l_weather, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, (file_exists("/share/lcd/scripts/weather")), lcd_weather, CRCInput::convertDigitToKey(shortcut++)); + mc->setHint("", LOCALE_MENU_HINT_LCD4L_WEATHER); + lcd4lSetup->addItem(mc); + + const char *flag_lcd4l_clock_a = FLAG_DIR ".lcd-clock_a"; + int fake_lcd4l_clock_a = file_exists(flag_lcd4l_clock_a); + CTouchFileNotifier * lcd_clock_a = new CTouchFileNotifier(FLAG_DIR ".lcd-clock_a"); + mc = new CMenuOptionChooser(LOCALE_LCD4L_CLOCK_A, &fake_lcd4l_clock_a, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, lcd_clock_a, CRCInput::convertDigitToKey(shortcut++)); + mc->setHint("", LOCALE_MENU_HINT_LCD4L_CLOCK_A); + lcd4lSetup->addItem(mc); + + lcd4lSetup->addItem(GenericMenuSeparator); + + mc = new CMenuOptionChooser(LOCALE_LCD4L_CONVERT, &g_settings.lcd4l_convert, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); + mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_CONVERT); + lcd4lSetup->addItem(mc); + + int res = lcd4lSetup->exec(NULL, ""); + + lcd4lSetup->hide(); + delete lcd4lSetup; + + // the things to do on exit + + if (g_settings.lcd4l_skin != temp_lcd4l_skin) + { + g_settings.lcd4l_skin = temp_lcd4l_skin; + LCD4l->InitLCD4l(); + } + + return res; +} diff --git a/src/gui/lcd4l_setup.h b/src/gui/lcd4l_setup.h new file mode 100644 index 000000000..88734d875 --- /dev/null +++ b/src/gui/lcd4l_setup.h @@ -0,0 +1,52 @@ +/* + lcd4l setup + + Copyright (C) 2012 'defans' + Homepage: http://www.bluepeercrew.us/ + + Copyright (C) 2012-2016 'vanhofen' + Homepage: http://www.neutrino-images.de/ + + Modded (C) 2016 'TangoCash' + + 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 __lcd4l_setup__ +#define __lcd4l_setup__ + +#include + +class CLCD4lSetup : public CMenuTarget, CChangeObserver +{ + private: + CMenuOptionChooser *mc; + CMenuForwarder * mf; + + int width; + int show(); + + public: + CLCD4lSetup(); + ~CLCD4lSetup(); + int exec(CMenuTarget* parent, const std::string &actionkey); + virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/); +}; + +#endif diff --git a/src/gui/ni_menu.cpp b/src/gui/ni_menu.cpp index 3b1e6a4ac..32b881bd9 100644 --- a/src/gui/ni_menu.cpp +++ b/src/gui/ni_menu.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -50,28 +51,6 @@ #include -// lcd4l-support -#include "gui/lcd4l.h" -extern CLCD4l *LCD4l; - -const CMenuOptionChooser::keyval LCD4L_SUPPORT_OPTIONS[] = -{ - { 0, LOCALE_LCD4L_SUPPORT_OFF }, - { 1, LOCALE_LCD4L_SUPPORT_AUTO }, - { 2, LOCALE_LCD4L_SUPPORT_ON } -}; -#define LCD4L_SUPPORT_OPTION_COUNT (sizeof(LCD4L_SUPPORT_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) - -const CMenuOptionChooser::keyval LCD4L_SKIN_OPTIONS[] = -{ - { 0, LOCALE_LCD4L_SKIN_0 }, - { 1, LOCALE_LCD4L_SKIN_1 }, - { 2, LOCALE_LCD4L_SKIN_2 }, - { 3, LOCALE_LCD4L_SKIN_3 }, - { 4, LOCALE_LCD4L_SKIN_4 } -}; -#define LCD4L_SKIN_OPTION_COUNT (sizeof(LCD4L_SKIN_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) - typedef struct emu_menu_data_t { neutrino_locale_t name; @@ -198,17 +177,13 @@ int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey) return menu_return::RETURN_EXIT_ALL; } - else if (actionkey=="lcd4l_logodir") { - const char *action_str = "lcd4l_logodir"; - chooserDir(g_settings.lcd4l_logodir, false, action_str); - return menu_return::RETURN_REPAINT; - } res = show(); return res; } +#if 0 bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) { #if 0 @@ -217,16 +192,9 @@ bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) if (data) val = (*(int *)data); #endif - - if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCD4L_SUPPORT)) - { - LCD4l->StopLCD4l(); - if (g_settings.lcd4l_support) - LCD4l->StartLCD4l(); - } - return false; } +#endif bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) { @@ -283,14 +251,6 @@ bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) sleep(1); delete hintbox; } - else if (strstr(filename, "lcd-weather")) - { - // do nothing - } - else if (strstr(filename, "lcd-clock_a")) - { - // do nothing - } else if (strstr(filename, "hddpower")) { // do nothing @@ -348,14 +308,6 @@ bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) sleep(1); delete hintbox; } - else if (strstr(filename, "lcd-weather")) - { - // do nothing - } - else if (strstr(filename, "lcd-clock_a")) - { - // do nothing - } else if (strstr(filename, "hddpower")) { // do nothing @@ -378,7 +330,6 @@ int CNIMenu::show() int shortcut = 1; int cam_shortcut = 1; int plugin_shortcut = 0; - int lcd4l_shortcut = 1; std::ostringstream buf; char *buffer; @@ -503,48 +454,8 @@ int CNIMenu::show() mf->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, LOCALE_MENU_HINT_PLUGINS_CONTROL); ni_menu->addItem(mf); - // lcd4l menu - CMenuWidget* lcd4lMenu = new CMenuWidget(LOCALE_LCD4L_SUPPORT, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_LCD4L_CONTROL); - lcd4lMenu->addIntroItems(); - - int temp_lcd4l_skin = g_settings.lcd4l_skin; - int flag_lcd4l_weather = file_exists(FLAG_DIR ".lcd-weather"); - int flag_lcd4l_clock_a = file_exists(FLAG_DIR ".lcd-clock_a"); - - mc = new CMenuOptionChooser(LOCALE_LCD4L_SUPPORT, &g_settings.lcd4l_support, LCD4L_SUPPORT_OPTIONS, LCD4L_SUPPORT_OPTION_COUNT, true, this, CRCInput::RC_red); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SUPPORT); - lcd4lMenu->addItem(mc); - lcd4lMenu->addItem(GenericMenuSeparatorLine); - - mf = new CMenuForwarder(LOCALE_LCD4L_LOGODIR, true, g_settings.lcd4l_logodir, this, "lcd4l_logodir", CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mf->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_LOGODIR); - lcd4lMenu->addItem(mf); - - mc = new CMenuOptionChooser(LOCALE_LCD4L_SKIN, &temp_lcd4l_skin, LCD4L_SKIN_OPTIONS, LCD4L_SKIN_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SKIN); - lcd4lMenu->addItem(mc); - - mc = new CMenuOptionChooser(LOCALE_LCD4L_SKIN_RADIO, &g_settings.lcd4l_skin_radio, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SKIN_RADIO); - lcd4lMenu->addItem(mc); - - CNITouchFileNotifier * lcd_weatherFileNotifier = new CNITouchFileNotifier("lcd-weather"); - mc = new CMenuOptionChooser(LOCALE_LCD4L_WEATHER, &flag_lcd4l_weather, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, (file_exists("/share/lcd/scripts/weather")), lcd_weatherFileNotifier, CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_WEATHER); - lcd4lMenu->addItem(mc); - - CNITouchFileNotifier * lcd_clock_aFileNotifier = new CNITouchFileNotifier("lcd-clock_a"); - mc = new CMenuOptionChooser(LOCALE_LCD4L_CLOCK_A, &flag_lcd4l_clock_a, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, lcd_clock_aFileNotifier, CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_CLOCK_A); - lcd4lMenu->addItem(mc); - - lcd4lMenu->addItem(GenericMenuSeparator); - - mc = new CMenuOptionChooser(LOCALE_LCD4L_CONVERT, &g_settings.lcd4l_convert, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(lcd4l_shortcut++)); - mc->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_CONVERT); - lcd4lMenu->addItem(mc); - - mf = new CMenuForwarder(LOCALE_LCD4L_SUPPORT, true, NULL, lcd4lMenu, "", CRCInput::convertDigitToKey(shortcut++)); + CLCD4lSetup lcd4lSetup; + mf = new CMenuForwarder(LOCALE_LCD4L_SUPPORT, true, NULL, &lcd4lSetup, "", CRCInput::convertDigitToKey(shortcut++)); mf->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SUPPORT); ni_menu->addItem(mf); @@ -557,15 +468,6 @@ int CNIMenu::show() delete ni_menu; delete emuMenu; delete pluginMenu; - delete lcd4lMenu; - - // the things to do on exit - - if (g_settings.lcd4l_skin != temp_lcd4l_skin) - { - g_settings.lcd4l_skin = temp_lcd4l_skin; - LCD4l->InitLCD4l(); - } return res; } diff --git a/src/gui/ni_menu.h b/src/gui/ni_menu.h index 8ad6aa750..34a498081 100644 --- a/src/gui/ni_menu.h +++ b/src/gui/ni_menu.h @@ -56,7 +56,9 @@ class CNIMenu : public CMenuTarget, CChangeObserver ~CNIMenu(); static CNIMenu* getInstance(); int exec(CMenuTarget* parent, const std::string &actionkey); +#if 0 virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/); +#endif }; #endif diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index 8be0c97f7..c9cdbe9d8 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -172,7 +172,7 @@ enum MN_WIDGET_ID MN_WIDGET_ID_INFOICONS_DELFLAG, MN_WIDGET_ID_INFOICONS_SETFLAG, MN_WIDGET_ID_HDD_INFO, - MN_WIDGET_ID_LCD4L_CONTROL, + MN_WIDGET_ID_LCD4L_SETUP, MN_WIDGET_ID_PLUGINS_CONTROL, MN_WIDGET_ID_PLUGINS_HIDE,