lcd4l_setup: move from ni_menu to own cpp|h

Origin commit data
------------------
Branch: ni/coolstream
Commit: 8c62cb6f68
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-05-24 (Tue, 24 May 2016)

Origin message was:
------------------
- lcd4l_setup: move from ni_menu to own cpp|h

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2016-05-24 16:08:24 +02:00
parent 53f3805e21
commit 545c18dec8
6 changed files with 244 additions and 104 deletions

View File

@@ -67,6 +67,7 @@ libneutrino_gui_a_SOURCES = \
infoviewer_bb.cpp \ infoviewer_bb.cpp \
keybind_setup.cpp \ keybind_setup.cpp \
lcd4l.cpp \ lcd4l.cpp \
lcd4l_setup.cpp \
mediaplayer.cpp \ mediaplayer.cpp \
mediaplayer_setup.cpp \ mediaplayer_setup.cpp \
miscsettings_menu.cpp \ miscsettings_menu.cpp \

183
src/gui/lcd4l_setup.cpp Normal file
View File

@@ -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 <config.h>
#endif
#include <iostream>
#include <fstream>
#include <sstream>
#include <signal.h>
#include <unistd.h>
#include <global.h>
#include <neutrino.h>
#include <mymenu.h>
#include <neutrino_menue.h>
#include <gui/filebrowser.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/icons.h>
#include <gui/widget/menue.h>
#include <gui/lcd4l_setup.h>
#include <system/helpers.h>
#include <driver/screen_max.h>
// 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;
}

52
src/gui/lcd4l_setup.h Normal file
View File

@@ -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 <gui/widget/menue.h>
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

View File

@@ -37,6 +37,7 @@
#include <neutrino_menue.h> #include <neutrino_menue.h>
#include <gui/infoicons_setup.h> #include <gui/infoicons_setup.h>
#include <gui/lcd4l_setup.h>
#include <gui/netfs_setup.h> #include <gui/netfs_setup.h>
#include <gui/filebrowser.h> #include <gui/filebrowser.h>
#include <gui/plugins_hide.h> #include <gui/plugins_hide.h>
@@ -50,28 +51,6 @@
#include <driver/screen_max.h> #include <driver/screen_max.h>
// 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 typedef struct emu_menu_data_t
{ {
neutrino_locale_t name; neutrino_locale_t name;
@@ -198,17 +177,13 @@ int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey)
return menu_return::RETURN_EXIT_ALL; 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(); res = show();
return res; return res;
} }
#if 0
bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/) bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/)
{ {
#if 0 #if 0
@@ -217,16 +192,9 @@ bool CNIMenu::changeNotify(const neutrino_locale_t OptionName, void * /*data*/)
if (data) if (data)
val = (*(int *)data); val = (*(int *)data);
#endif #endif
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCD4L_SUPPORT))
{
LCD4l->StopLCD4l();
if (g_settings.lcd4l_support)
LCD4l->StartLCD4l();
}
return false; return false;
} }
#endif
bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data) bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data)
{ {
@@ -283,14 +251,6 @@ bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data)
sleep(1); sleep(1);
delete hintbox; delete hintbox;
} }
else if (strstr(filename, "lcd-weather"))
{
// do nothing
}
else if (strstr(filename, "lcd-clock_a"))
{
// do nothing
}
else if (strstr(filename, "hddpower")) else if (strstr(filename, "hddpower"))
{ {
// do nothing // do nothing
@@ -348,14 +308,6 @@ bool CNITouchFileNotifier::changeNotify(const neutrino_locale_t, void * data)
sleep(1); sleep(1);
delete hintbox; delete hintbox;
} }
else if (strstr(filename, "lcd-weather"))
{
// do nothing
}
else if (strstr(filename, "lcd-clock_a"))
{
// do nothing
}
else if (strstr(filename, "hddpower")) else if (strstr(filename, "hddpower"))
{ {
// do nothing // do nothing
@@ -378,7 +330,6 @@ int CNIMenu::show()
int shortcut = 1; int shortcut = 1;
int cam_shortcut = 1; int cam_shortcut = 1;
int plugin_shortcut = 0; int plugin_shortcut = 0;
int lcd4l_shortcut = 1;
std::ostringstream buf; std::ostringstream buf;
char *buffer; char *buffer;
@@ -503,48 +454,8 @@ int CNIMenu::show()
mf->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, LOCALE_MENU_HINT_PLUGINS_CONTROL); mf->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, LOCALE_MENU_HINT_PLUGINS_CONTROL);
ni_menu->addItem(mf); ni_menu->addItem(mf);
// lcd4l menu CLCD4lSetup lcd4lSetup;
CMenuWidget* lcd4lMenu = new CMenuWidget(LOCALE_LCD4L_SUPPORT, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_LCD4L_CONTROL); mf = new CMenuForwarder(LOCALE_LCD4L_SUPPORT, true, NULL, &lcd4lSetup, "", CRCInput::convertDigitToKey(shortcut++));
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++));
mf->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SUPPORT); mf->setHint(NEUTRINO_ICON_HINT_LCD4L, LOCALE_MENU_HINT_LCD4L_SUPPORT);
ni_menu->addItem(mf); ni_menu->addItem(mf);
@@ -557,15 +468,6 @@ int CNIMenu::show()
delete ni_menu; delete ni_menu;
delete emuMenu; delete emuMenu;
delete pluginMenu; 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; return res;
} }

View File

@@ -56,7 +56,9 @@ class CNIMenu : public CMenuTarget, CChangeObserver
~CNIMenu(); ~CNIMenu();
static CNIMenu* getInstance(); static CNIMenu* getInstance();
int exec(CMenuTarget* parent, const std::string &actionkey); int exec(CMenuTarget* parent, const std::string &actionkey);
#if 0
virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/); virtual bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
#endif
}; };
#endif #endif

View File

@@ -172,7 +172,7 @@ enum MN_WIDGET_ID
MN_WIDGET_ID_INFOICONS_DELFLAG, MN_WIDGET_ID_INFOICONS_DELFLAG,
MN_WIDGET_ID_INFOICONS_SETFLAG, MN_WIDGET_ID_INFOICONS_SETFLAG,
MN_WIDGET_ID_HDD_INFO, MN_WIDGET_ID_HDD_INFO,
MN_WIDGET_ID_LCD4L_CONTROL, MN_WIDGET_ID_LCD4L_SETUP,
MN_WIDGET_ID_PLUGINS_CONTROL, MN_WIDGET_ID_PLUGINS_CONTROL,
MN_WIDGET_ID_PLUGINS_HIDE, MN_WIDGET_ID_PLUGINS_HIDE,