mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
CThemes: add default theme from config and migrate theme settings if needed
This commit is contained in:
@@ -38,6 +38,13 @@ AC_ARG_ENABLE(reschange,
|
|||||||
AC_DEFINE(ENABLE_CHANGE_OSD_RESOLUTION, 1, [enable change the osd resolution]))
|
AC_DEFINE(ENABLE_CHANGE_OSD_RESOLUTION, 1, [enable change the osd resolution]))
|
||||||
AM_CONDITIONAL(ENABLE_RESCHANGE, test "$enable_reschange" = "yes")
|
AM_CONDITIONAL(ENABLE_RESCHANGE, test "$enable_reschange" = "yes")
|
||||||
|
|
||||||
|
# default theme
|
||||||
|
AC_ARG_WITH(default-theme,
|
||||||
|
AS_HELP_STRING([--with-default-theme=THEMENAME], [Default theme for gui. Default it is empty for internal fallback to default colors.]),
|
||||||
|
[default_theme="$withval"],
|
||||||
|
[default_theme=""])
|
||||||
|
AC_DEFINE_UNQUOTED([DEFAULT_THEME], ["$default_theme"], [Default theme for gui.])
|
||||||
|
|
||||||
AC_MSG_CHECKING(target)
|
AC_MSG_CHECKING(target)
|
||||||
|
|
||||||
if test "$TARGET" = "native"; then
|
if test "$TARGET" = "native"; then
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
#define USERDIR "/var" THEMESDIR
|
#define USERDIR "/var" THEMESDIR
|
||||||
#define FILE_SUFFIX ".theme"
|
#define FILE_SUFFIX ".theme"
|
||||||
|
|
||||||
static SNeutrinoTheme &t = g_settings.theme;
|
static SNeutrinoTheme &t = g_settings.theme;
|
||||||
CThemes::CThemes()
|
CThemes::CThemes()
|
||||||
: themefile('\t')
|
: themefile('\t')
|
||||||
@@ -252,13 +253,13 @@ void CThemes::saveFile(const char *themename)
|
|||||||
|
|
||||||
bool CThemes::applyDefaultTheme()
|
bool CThemes::applyDefaultTheme()
|
||||||
{
|
{
|
||||||
g_settings.theme_name = "Neutrino-3.0";
|
g_settings.theme_name = DEFAULT_THEME;
|
||||||
std::string default_theme = THEMESDIR "/" + g_settings.theme_name + ".theme";
|
std::string default_theme = THEMESDIR "/" + g_settings.theme_name + ".theme";
|
||||||
if(themefile.loadConfig(default_theme)){
|
if(themefile.loadConfig(default_theme)){
|
||||||
getTheme(themefile);
|
getTheme(themefile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
dprintf(DEBUG_NORMAL, "[CThemes]\t[%s - %d], default neutrino theme [ %s ] not found\n", __func__, __LINE__, default_theme.c_str());
|
dprintf(DEBUG_NORMAL, "[CThemes]\t[%s - %d], No default theme found, creating migrated theme from current theme settings\n", __func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,9 +379,6 @@ void CThemes::setTheme(CConfigFile &configfile)
|
|||||||
|
|
||||||
void CThemes::getTheme(CConfigFile &configfile)
|
void CThemes::getTheme(CConfigFile &configfile)
|
||||||
{
|
{
|
||||||
if (g_settings.theme_name.empty())
|
|
||||||
applyDefaultTheme();
|
|
||||||
|
|
||||||
t.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 );
|
t.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 );
|
||||||
t.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 );
|
t.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 );
|
||||||
t.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A );
|
t.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A );
|
||||||
@@ -489,6 +487,9 @@ void CThemes::getTheme(CConfigFile &configfile)
|
|||||||
t.progressbar_passive_red = configfile.getInt32( "progressbar_passive_red", 60 );
|
t.progressbar_passive_red = configfile.getInt32( "progressbar_passive_red", 60 );
|
||||||
t.progressbar_passive_green = configfile.getInt32( "progressbar_passive_green", 60 );
|
t.progressbar_passive_green = configfile.getInt32( "progressbar_passive_green", 60 );
|
||||||
t.progressbar_passive_blue = configfile.getInt32( "progressbar_passive_blue", 60 );
|
t.progressbar_passive_blue = configfile.getInt32( "progressbar_passive_blue", 60 );
|
||||||
|
|
||||||
|
if (g_settings.theme_name.empty())
|
||||||
|
applyDefaultTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CThemes::move_userDir()
|
void CThemes::move_userDir()
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
#include <sigc++/signal.h>
|
#include <sigc++/signal.h>
|
||||||
#include <sigc++/bind.h>
|
#include <sigc++/bind.h>
|
||||||
|
|
||||||
|
#define MIGRATE_THEME_NAME "Unknown-Migrated-Theme"
|
||||||
|
|
||||||
class CThemes : public CMenuTarget, CColorSetupNotifier, public sigc::trackable
|
class CThemes : public CMenuTarget, CColorSetupNotifier, public sigc::trackable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@@ -349,7 +349,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
|
|||||||
parentallocked = !access(NEUTRINO_PARENTALLOCKED_FILE, R_OK);
|
parentallocked = !access(NEUTRINO_PARENTALLOCKED_FILE, R_OK);
|
||||||
|
|
||||||
//theme/color options
|
//theme/color options
|
||||||
g_settings.theme_name = configfile.getString("theme_name","");
|
g_settings.theme_name = configfile.getString("theme_name", !access(NEUTRINO_SETTINGS_FILE, F_OK) ? MIGRATE_THEME_NAME : "");
|
||||||
CThemes::getInstance()->getTheme(configfile);
|
CThemes::getInstance()->getTheme(configfile);
|
||||||
|
|
||||||
g_settings.softupdate_autocheck = configfile.getBool("softupdate_autocheck" , false);
|
g_settings.softupdate_autocheck = configfile.getBool("softupdate_autocheck" , false);
|
||||||
|
Reference in New Issue
Block a user