mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 08:51:04 +02:00
themes: set default theme instead static colors, but hold fallback
Origin commit data
------------------
Branch: ni/coolstream
Commit: 8498f29202
Author: Thilo Graf <dbt@novatux.de>
Date: 2018-04-11 (Wed, 11 Apr 2018)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -787,7 +787,7 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors)
|
||||
{
|
||||
menu_colors->addIntroItems(LOCALE_COLORMENU_MENUCOLORS);
|
||||
|
||||
CMenuForwarder * mf = new CMenuDForwarder(LOCALE_COLORMENU_THEMESELECT, true, NULL, new CThemes(), NULL, CRCInput::RC_red);
|
||||
CMenuForwarder * mf = new CMenuDForwarder(LOCALE_COLORMENU_THEMESELECT, true, NULL, CThemes::getInstance(), NULL, CRCInput::RC_red);
|
||||
mf->setHint("", LOCALE_MENU_HINT_THEME);
|
||||
menu_colors->addItem(mf);
|
||||
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include <neutrino.h>
|
||||
#include "widget/menue.h"
|
||||
#include <system/helpers.h>
|
||||
#include <system/debug.h>
|
||||
#include <system/setting_helpers.h>
|
||||
#include <gui/widget/stringinput.h>
|
||||
#include <gui/widget/stringinput_ext.h>
|
||||
@@ -51,7 +52,7 @@
|
||||
#include "themes.h"
|
||||
|
||||
#define USERDIR "/var" THEMESDIR
|
||||
#define FILE_PREFIX ".theme"
|
||||
#define FILE_SUFFIX ".theme"
|
||||
static SNeutrinoTheme &t = g_settings.theme;
|
||||
CThemes::CThemes()
|
||||
: themefile('\t')
|
||||
@@ -61,15 +62,27 @@ CThemes::CThemes()
|
||||
hasThemeChanged = false;
|
||||
}
|
||||
|
||||
CThemes* CThemes::getInstance()
|
||||
{
|
||||
static CThemes* th = NULL;
|
||||
|
||||
if(!th) {
|
||||
th = new CThemes();
|
||||
dprintf(DEBUG_DEBUG, "CThemes Instance created\n");
|
||||
}
|
||||
return th;
|
||||
}
|
||||
|
||||
int CThemes::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
{
|
||||
int res = menu_return::RETURN_REPAINT;
|
||||
|
||||
if( !actionKey.empty() )
|
||||
{
|
||||
if (actionKey=="theme_neutrino")
|
||||
if (actionKey=="default_theme")
|
||||
{
|
||||
setupDefaultColors();
|
||||
if(!applyDefaultTheme())
|
||||
setupDefaultColors(); // fallback
|
||||
notifier = new CColorSetupNotifier();
|
||||
notifier->changeNotify(NONEXISTANT_LOCALE, NULL);
|
||||
delete notifier;
|
||||
@@ -80,10 +93,10 @@ int CThemes::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
if ( strstr(themeFile.c_str(), "{U}") != 0 )
|
||||
{
|
||||
themeFile.erase(0, 3);
|
||||
readFile(((std::string)THEMESDIR_VAR + "/" + themeFile + FILE_PREFIX).c_str());
|
||||
readFile(((std::string)THEMESDIR_VAR + "/" + themeFile + FILE_SUFFIX).c_str());
|
||||
}
|
||||
else
|
||||
readFile(((std::string)THEMESDIR + "/" + themeFile + FILE_PREFIX).c_str());
|
||||
readFile(((std::string)THEMESDIR + "/" + themeFile + FILE_SUFFIX).c_str());
|
||||
g_settings.theme_name = themeFile;
|
||||
}
|
||||
return res;
|
||||
@@ -157,7 +170,7 @@ int CThemes::Show()
|
||||
themes.addIntroItems(LOCALE_COLORTHEMEMENU_HEAD2);
|
||||
|
||||
//set default theme
|
||||
themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "theme_neutrino", CRCInput::RC_red));
|
||||
themes.addItem(new CMenuForwarder(LOCALE_COLORTHEMEMENU_NEUTRINO_THEME, true, NULL, this, "default_theme", CRCInput::RC_red));
|
||||
|
||||
readThemes(themes);
|
||||
|
||||
@@ -179,7 +192,7 @@ int CThemes::Show()
|
||||
int res = themes.exec(NULL, "");
|
||||
|
||||
if (!file_name.empty()) {
|
||||
saveFile(((std::string)THEMESDIR_VAR + "/" + file_name + FILE_PREFIX).c_str());
|
||||
saveFile(((std::string)THEMESDIR_VAR + "/" + file_name + FILE_SUFFIX).c_str());
|
||||
}
|
||||
|
||||
if (hasThemeChanged) {
|
||||
@@ -231,6 +244,18 @@ void CThemes::saveFile(const char *themename)
|
||||
}
|
||||
}
|
||||
|
||||
bool CThemes::applyDefaultTheme()
|
||||
{
|
||||
g_settings.theme_name = "Neutrino-3.0";
|
||||
std::string default_theme = THEMESDIR "/" + g_settings.theme_name + ".theme";
|
||||
if(themefile.loadConfig(default_theme)){
|
||||
getTheme(themefile);
|
||||
return true;
|
||||
}
|
||||
dprintf(DEBUG_NORMAL, "[CThemes]\t[%s - %d], default neutrino theme [ %s ] not found\n", __func__, __LINE__, default_theme.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// setup default Colors
|
||||
void CThemes::setupDefaultColors()
|
||||
{
|
||||
@@ -347,6 +372,9 @@ void CThemes::setTheme(CConfigFile &configfile)
|
||||
|
||||
void CThemes::getTheme(CConfigFile &configfile)
|
||||
{
|
||||
if (g_settings.theme_name.empty())
|
||||
applyDefaultTheme();
|
||||
|
||||
t.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 10 );
|
||||
t.menu_Head_red = configfile.getInt32( "menu_Head_red", 0 );
|
||||
t.menu_Head_green = configfile.getInt32( "menu_Head_green", 0 );
|
||||
|
@@ -45,13 +45,15 @@ class CThemes : public CMenuTarget, CChangeObserver
|
||||
void readThemes(CMenuWidget &);
|
||||
void rememberOldTheme(bool remember);
|
||||
void move_userDir();
|
||||
bool applyDefaultTheme();
|
||||
|
||||
public:
|
||||
CThemes();
|
||||
static CThemes* getInstance();
|
||||
void setupDefaultColors();
|
||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
||||
static void setTheme(CConfigFile &configfile);
|
||||
static void getTheme(CConfigFile &configfile);
|
||||
void setTheme(CConfigFile &configfile);
|
||||
void getTheme(CConfigFile &configfile);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -363,8 +363,8 @@ int CNeutrinoApp::loadSetup(const char * fname)
|
||||
parentallocked = !access(NEUTRINO_PARENTALLOCKED_FILE, R_OK);
|
||||
|
||||
//theme/color options
|
||||
CThemes::getTheme(configfile);
|
||||
g_settings.theme_name = configfile.getString("theme_name","");
|
||||
CThemes::getInstance()->getTheme(configfile);
|
||||
|
||||
//NI
|
||||
g_settings.inetradio_autostart = configfile.getInt32("inetradio_autostart" , 0);
|
||||
@@ -1234,8 +1234,8 @@ void CNeutrinoApp::saveSetup(const char * fname)
|
||||
}
|
||||
|
||||
//theme/color options
|
||||
configfile.getString( "theme_name",g_settings.theme_name );
|
||||
CThemes::setTheme(configfile);
|
||||
CThemes::getInstance()->setTheme(configfile);
|
||||
configfile.setString( "theme_name", g_settings.theme_name );
|
||||
|
||||
//NI
|
||||
configfile.setInt32("inetradio_autostart" , g_settings.inetradio_autostart);
|
||||
|
Reference in New Issue
Block a user