*neutrino settings manager: moved settings manager into it's own modul

Note: settings reset only possible with scrolling to item and press 'OK'
or '>', because button 'RECALL' is broken, we should fix this!

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1337 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
thilo
2011-03-25 09:23:58 +00:00
parent 9fbfcecc11
commit b045b500a1
5 changed files with 235 additions and 106 deletions

View File

@@ -77,6 +77,7 @@ libneutrino_gui_a_SOURCES = \
scan.cpp \ scan.cpp \
scan_setup.cpp \ scan_setup.cpp \
screensetup.cpp \ screensetup.cpp \
settings_manager.cpp \
sleeptimer.cpp \ sleeptimer.cpp \
streaminfo2.cpp \ streaminfo2.cpp \
test_menu.cpp \ test_menu.cpp \

View File

@@ -0,0 +1,178 @@
/*
settings mangaer menue - Neutrino-GUI
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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include "gui/settings_manager.h"
#include "gui/filebrowser.h"
#include "gui/widget/messagebox.h"
#include "gui/widget/stringinput.h"
#include <driver/screen_max.h>
#include <system/setting_helpers.h>
#include <sys/vfs.h>
CSettingsManager::CSettingsManager()
{
width = w_max (40, 10);
selected = -1;
}
CSettingsManager::~CSettingsManager()
{
}
int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
{
printf("[neutrino] CSettingsManager %s: init...\n",__FUNCTION__);
int res = menu_return::RETURN_REPAINT;
if (parent)
parent->hide();
CFileBrowser fileBrowser;
CFileFilter fileFilter;
if(actionKey == "loadconfig")
{
fileFilter.addFilter("conf");
fileBrowser.Filter = &fileFilter;
if (fileBrowser.exec("/var/tuxbox/config") == true)
{
CNeutrinoApp::getInstance()->loadSetup(fileBrowser.getSelectedFile()->Name.c_str());
CColorSetupNotifier *colorSetupNotifier = new CColorSetupNotifier;
colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
CVFD::getInstance()->setlcdparameter();
printf("[neutrino] new settings: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
delete colorSetupNotifier;
}
return res;
}
else if(actionKey == "saveconfig")
{
fileBrowser.Dir_Mode = true;
if (fileBrowser.exec("/var/tuxbox") == true)
{
char fname[256] = "neutrino.conf", sname[256];
CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. ");
sms->exec(NULL, "");
sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname);
printf("[neutrino] save settings: %s\n", sname);
CNeutrinoApp::getInstance()->saveSetup(sname);
delete sms;
}
return res;
}
else if(actionKey == "backup")
{
fileBrowser.Dir_Mode = true;
if (fileBrowser.exec("/media") == true)
{
char fname[256];
struct statfs s;
int ret = ::statfs(fileBrowser.getSelectedFile()->Name.c_str(), &s);
if(ret == 0 && s.f_type != 0x72b6L) /*jffs2*/
{
sprintf(fname, "/bin/backup.sh %s", fileBrowser.getSelectedFile()->Name.c_str());
printf("backup: executing [%s]\n", fname);
system(fname);
}
else
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR);
}
return res;
}
else if(actionKey == "restore")
{
fileFilter.addFilter("tar");
fileBrowser.Filter = &fileFilter;
if (fileBrowser.exec("/media") == true)
{
int result = ShowMsgUTF(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo);
if(result == CMessageBox::mbrYes)
{
char fname[256];
sprintf(fname, "/bin/restore.sh %s", fileBrowser.getSelectedFile()->Name.c_str());
printf("restore: executing [%s]\n", fname);
system(fname);
}
}
return res;
}
showMenu();
return res;
}
void CSettingsManager::showMenu()
{
printf("[neutrino] CSettingsManager call %s...\n", __FUNCTION__);
CDataResetNotifier * resetNotifier = new CDataResetNotifier();
CMenuWidget * mset = new CMenuWidget(LOCALE_MAINSETTINGS_MANAGE, NEUTRINO_ICON_SETTINGS, width);
mset->setSelected(selected);
mset->addIntroItems();
mset->addItem(new CMenuForwarder(LOCALE_RESET_SETTINGS, true, NULL, resetNotifier, "settings", CRCInput::RC_recall));// FIXME: RC-button RECALL is broken
mset->addItem(GenericMenuSeparatorLine);
mset->addItem(new CMenuForwarder(LOCALE_EXTRA_LOADCONFIG, true, NULL, this, "loadconfig", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
mset->addItem(new CMenuForwarder(LOCALE_EXTRA_SAVECONFIG, true, NULL, this, "saveconfig", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
mset->addItem(GenericMenuSeparatorLine);
mset->addItem(new CMenuForwarder(LOCALE_SETTINGS_BACKUP, true, NULL, this, "backup", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
mset->addItem(new CMenuForwarder(LOCALE_SETTINGS_RESTORE, true, NULL, this, "restore", CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE));
mset->addItem(GenericMenuSeparatorLine);
mset->addItem(new CMenuForwarder(LOCALE_RESET_ALL, true, NULL, resetNotifier, "all", CRCInput::RC_standby, NEUTRINO_ICON_BUTTON_POWER));
mset->exec(NULL, "");
mset->hide();
selected = mset->getSelected();
delete resetNotifier;
delete mset;
}

View File

@@ -0,0 +1,52 @@
/*
settings manager menue - Neutrino-GUI
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 __SETTINGS_MANAGER__
#define __SETTINGS_MANAGER__
#include <gui/widget/menue.h>
#include <string>
class CSettingsManager : public CMenuTarget
{
private:
int width, selected;
void showMenu();
public:
CSettingsManager();
~CSettingsManager();
int exec(CMenuTarget* parent, const std::string & actionKey = "");
};
#endif

View File

@@ -47,7 +47,7 @@
#include <signal.h> #include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <sys/vfs.h>
#include <sys/socket.h> #include <sys/socket.h>
@@ -4279,35 +4279,6 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
MoviePluginSelector.exec(NULL, ""); MoviePluginSelector.exec(NULL, "");
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }
else if(actionKey == "loadconfig") {
parent->hide();
CFileBrowser fileBrowser;
CFileFilter fileFilter;
fileFilter.addFilter("conf");
fileBrowser.Filter = &fileFilter;
if (fileBrowser.exec("/var/tuxbox/config") == true) {
loadSetup(fileBrowser.getSelectedFile()->Name.c_str());
colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
CVFD::getInstance()->setlcdparameter();
printf("[neutrino] new settings: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
}
return menu_return::RETURN_REPAINT;
}
else if(actionKey == "saveconfig") {
parent->hide();
CFileBrowser fileBrowser;
fileBrowser.Dir_Mode = true;
if (fileBrowser.exec("/var/tuxbox") == true) {
char fname[256] = "neutrino.conf", sname[256];
CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. ");
sms->exec(NULL, "");
sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname);
printf("[neutrino] save settings: %s\n", sname);
saveSetup(sname);
delete sms;
}
return menu_return::RETURN_REPAINT;
}
else if(actionKey == "loadcolors") { else if(actionKey == "loadcolors") {
parent->hide(); parent->hide();
CFileBrowser fileBrowser; CFileBrowser fileBrowser;
@@ -4335,33 +4306,6 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
} }
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }
// else if(actionKey == "loadkeys") {
// parent->hide();
// CFileBrowser fileBrowser;
// CFileFilter fileFilter;
// fileFilter.addFilter("conf");
// fileBrowser.Filter = &fileFilter;
// if (fileBrowser.exec("/var/tuxbox/config") == true) {
// loadKeys(fileBrowser.getSelectedFile()->Name.c_str());
// printf("[neutrino] new keys: %s\n", fileBrowser.getSelectedFile()->Name.c_str());
// }
// return menu_return::RETURN_REPAINT;
// }
// else if(actionKey == "savekeys") {
// parent->hide();
// 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] save keys: %s\n", sname);
// saveKeys(sname);
// delete sms;
// }
// return menu_return::RETURN_REPAINT;
// }
else if(actionKey == "autolink") { else if(actionKey == "autolink") {
if(autoshift) { if(autoshift) {
char buf[512]; char buf[512];
@@ -4378,41 +4322,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
{ {
g_Sectionsd->freeMemory(); g_Sectionsd->freeMemory();
} }
else if(actionKey == "backup") {
if(parent)
parent->hide();
CFileBrowser fileBrowser;
fileBrowser.Dir_Mode = true;
if (fileBrowser.exec("/media") == true) {
char fname[256];
struct statfs s;
int ret = ::statfs(fileBrowser.getSelectedFile()->Name.c_str(), &s);
if(ret == 0 && s.f_type != 0x72b6L) { /*jffs2*/
sprintf(fname, "/bin/backup.sh %s", fileBrowser.getSelectedFile()->Name.c_str());
printf("backup: executing [%s]\n", fname);
system(fname);
} else
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),
CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR);
}
}
else if(actionKey == "restore") {
if(parent)
parent->hide();
CFileBrowser fileBrowser;
CFileFilter fileFilter;
fileFilter.addFilter("tar");
fileBrowser.Filter = &fileFilter;
if (fileBrowser.exec("/media") == true) {
int result = ShowMsgUTF(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo);
if(result == CMessageBox::mbrYes) {
char fname[256];
sprintf(fname, "/bin/restore.sh %s", fileBrowser.getSelectedFile()->Name.c_str());
printf("restore: executing [%s]\n", fname);
system(fname);
}
}
}
return returnval; return returnval;
} }

View File

@@ -69,6 +69,7 @@
#include "gui/plugins.h" #include "gui/plugins.h"
#include "gui/record_setup.h" #include "gui/record_setup.h"
#include "gui/scan_setup.h" #include "gui/scan_setup.h"
#include "gui/settings_manager.h"
#include "gui/sleeptimer.h" #include "gui/sleeptimer.h"
#include <gui/streaminfo2.h> #include <gui/streaminfo2.h>
#ifdef TEST_MENU #ifdef TEST_MENU
@@ -154,20 +155,7 @@ void CNeutrinoApp::InitMainMenu(CMenuWidget &mainMenu, CMenuWidget &mainSettings
mainSettings.addItem(new CMenuForwarder(LOCALE_MAINSETTINGS_SAVESETTINGSNOW, true, NULL, this, "savesettings", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); mainSettings.addItem(new CMenuForwarder(LOCALE_MAINSETTINGS_SAVESETTINGSNOW, true, NULL, this, "savesettings", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
CDataResetNotifier * resetNotifier = new CDataResetNotifier(); mainSettings.addItem(new CMenuForwarder(LOCALE_MAINSETTINGS_MANAGE, true, NULL, new CSettingsManager()));
CMenuWidget * mset = new CMenuWidget(LOCALE_MAINSETTINGS_MANAGE, NEUTRINO_ICON_SETTINGS);
mset->addIntroItems();
mset->addItem(new CMenuForwarder(LOCALE_RESET_SETTINGS, true, NULL, resetNotifier, "settings"));
mset->addItem(new CMenuForwarder(LOCALE_EXTRA_LOADCONFIG, true, NULL, this, "loadconfig"));
mset->addItem(new CMenuForwarder(LOCALE_EXTRA_SAVECONFIG, true, NULL, this, "saveconfig"));
mset->addItem(new CMenuForwarder(LOCALE_SETTINGS_BACKUP, true, NULL, this, "backup"));
mset->addItem(new CMenuForwarder(LOCALE_SETTINGS_RESTORE, true, NULL, this, "restore"));
mset->addItem(new CMenuForwarder(LOCALE_RESET_ALL, true, NULL, resetNotifier, "all"));
mainSettings.addItem(new CMenuForwarder(LOCALE_MAINSETTINGS_MANAGE, true, NULL, mset));
//mainSettings.addItem(new CMenuForwarder(LOCALE_RESET_SETTINGS , true, NULL, resetNotifier, "settings"));
mainSettings.addItem(GenericMenuSeparatorLine); mainSettings.addItem(GenericMenuSeparatorLine);