neutrino.cpp: move theme loading to gui/themes.cpp

original commit (C) martii:
commit cf48e04c02224af37098359d1788f65edd6a7060
gui/themes, neutrino: de-duplicate get/set code
This commit is contained in:
[CST] Focus
2014-09-12 19:42:31 +04:00
parent 64ef858923
commit 58198b3f55
3 changed files with 115 additions and 217 deletions

View File

@@ -172,7 +172,7 @@ int CThemes::Show()
int res = themes.exec(NULL, "");
if (file_name.length() > 1) {
if (file_name.length() > 0) {
saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str());
}
@@ -203,54 +203,7 @@ void CThemes::readFile(char* themename)
{
if(themefile.loadConfig(themename))
{
g_settings.theme.menu_Head_alpha = themefile.getInt32( "menu_Head_alpha", 0x00 );
g_settings.theme.menu_Head_red = themefile.getInt32( "menu_Head_red", 0x00 );
g_settings.theme.menu_Head_green = themefile.getInt32( "menu_Head_green", 0x0A );
g_settings.theme.menu_Head_blue = themefile.getInt32( "menu_Head_blue", 0x19 );
g_settings.theme.menu_Head_Text_alpha = themefile.getInt32( "menu_Head_Text_alpha", 0x00 );
g_settings.theme.menu_Head_Text_red = themefile.getInt32( "menu_Head_Text_red", 0x5f );
g_settings.theme.menu_Head_Text_green = themefile.getInt32( "menu_Head_Text_green", 0x46 );
g_settings.theme.menu_Head_Text_blue = themefile.getInt32( "menu_Head_Text_blue", 0x00 );
g_settings.theme.menu_Content_alpha = themefile.getInt32( "menu_Content_alpha", 0x14 );
g_settings.theme.menu_Content_red = themefile.getInt32( "menu_Content_red", 0x00 );
g_settings.theme.menu_Content_green = themefile.getInt32( "menu_Content_green", 0x0f );
g_settings.theme.menu_Content_blue = themefile.getInt32( "menu_Content_blue", 0x23 );
g_settings.theme.menu_Content_Text_alpha = themefile.getInt32( "menu_Content_Text_alpha", 0x00 );
g_settings.theme.menu_Content_Text_red = themefile.getInt32( "menu_Content_Text_red", 0x64 );
g_settings.theme.menu_Content_Text_green = themefile.getInt32( "menu_Content_Text_green", 0x64 );
g_settings.theme.menu_Content_Text_blue = themefile.getInt32( "menu_Content_Text_blue", 0x64 );
g_settings.theme.menu_Content_Selected_alpha = themefile.getInt32( "menu_Content_Selected_alpha", 0x14 );
g_settings.theme.menu_Content_Selected_red = themefile.getInt32( "menu_Content_Selected_red", 0x19 );
g_settings.theme.menu_Content_Selected_green = themefile.getInt32( "menu_Content_Selected_green", 0x37 );
g_settings.theme.menu_Content_Selected_blue = themefile.getInt32( "menu_Content_Selected_blue", 0x64 );
g_settings.theme.menu_Content_Selected_Text_alpha = themefile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 );
g_settings.theme.menu_Content_Selected_Text_red = themefile.getInt32( "menu_Content_Selected_Text_red", 0x00 );
g_settings.theme.menu_Content_Selected_Text_green = themefile.getInt32( "menu_Content_Selected_Text_green", 0x00 );
g_settings.theme.menu_Content_Selected_Text_blue = themefile.getInt32( "menu_Content_Selected_Text_blue", 0x00 );
g_settings.theme.menu_Content_inactive_alpha = themefile.getInt32( "menu_Content_inactive_alpha", 0x14 );
g_settings.theme.menu_Content_inactive_red = themefile.getInt32( "menu_Content_inactive_red", 0x00 );
g_settings.theme.menu_Content_inactive_green = themefile.getInt32( "menu_Content_inactive_green", 0x0f );
g_settings.theme.menu_Content_inactive_blue = themefile.getInt32( "menu_Content_inactive_blue", 0x23 );
g_settings.theme.menu_Content_inactive_Text_alpha = themefile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 );
g_settings.theme.menu_Content_inactive_Text_red = themefile.getInt32( "menu_Content_inactive_Text_red", 55 );
g_settings.theme.menu_Content_inactive_Text_green = themefile.getInt32( "menu_Content_inactive_Text_green", 70 );
g_settings.theme.menu_Content_inactive_Text_blue = themefile.getInt32( "menu_Content_inactive_Text_blue", 85 );
g_settings.theme.infobar_alpha = themefile.getInt32( "infobar_alpha", 0x14 );
g_settings.theme.infobar_red = themefile.getInt32( "infobar_red", 0x00 );
g_settings.theme.infobar_green = themefile.getInt32( "infobar_green", 0x0e );
g_settings.theme.infobar_blue = themefile.getInt32( "infobar_blue", 0x23 );
g_settings.theme.infobar_Text_alpha = themefile.getInt32( "infobar_Text_alpha", 0x00 );
g_settings.theme.infobar_Text_red = themefile.getInt32( "infobar_Text_red", 0x64 );
g_settings.theme.infobar_Text_green = themefile.getInt32( "infobar_Text_green", 0x64 );
g_settings.theme.infobar_Text_blue = themefile.getInt32( "infobar_Text_blue", 0x64 );
g_settings.theme.colored_events_alpha = themefile.getInt32( "colored_events_alpha", 0x00 );
g_settings.theme.colored_events_red = themefile.getInt32( "colored_events_red", 95 );
g_settings.theme.colored_events_green = themefile.getInt32( "colored_events_green", 70 );
g_settings.theme.colored_events_blue = themefile.getInt32( "colored_events_blue", 0 );
g_settings.theme.clock_Digit_alpha = themefile.getInt32( "clock_Digit_alpha", g_settings.theme.menu_Content_Text_alpha );
g_settings.theme.clock_Digit_red = themefile.getInt32( "clock_Digit_red", g_settings.theme.menu_Content_Text_red );
g_settings.theme.clock_Digit_green = themefile.getInt32( "clock_Digit_green", g_settings.theme.menu_Content_Text_green );
g_settings.theme.clock_Digit_blue = themefile.getInt32( "clock_Digit_blue", g_settings.theme.menu_Content_Text_blue );
getTheme(themefile);
notifier = new CColorSetupNotifier;
notifier->changeNotify(NONEXISTANT_LOCALE, NULL);
@@ -263,64 +216,121 @@ void CThemes::readFile(char* themename)
void CThemes::saveFile(char * themename)
{
themefile.setInt32( "menu_Head_alpha", g_settings.theme.menu_Head_alpha );
themefile.setInt32( "menu_Head_red", g_settings.theme.menu_Head_red );
themefile.setInt32( "menu_Head_green", g_settings.theme.menu_Head_green );
themefile.setInt32( "menu_Head_blue", g_settings.theme.menu_Head_blue );
themefile.setInt32( "menu_Head_Text_alpha", g_settings.theme.menu_Head_Text_alpha );
themefile.setInt32( "menu_Head_Text_red", g_settings.theme.menu_Head_Text_red );
themefile.setInt32( "menu_Head_Text_green", g_settings.theme.menu_Head_Text_green );
themefile.setInt32( "menu_Head_Text_blue", g_settings.theme.menu_Head_Text_blue );
themefile.setInt32( "menu_Content_alpha", g_settings.theme.menu_Content_alpha );
themefile.setInt32( "menu_Content_red", g_settings.theme.menu_Content_red );
themefile.setInt32( "menu_Content_green", g_settings.theme.menu_Content_green );
themefile.setInt32( "menu_Content_blue", g_settings.theme.menu_Content_blue );
themefile.setInt32( "menu_Content_Text_alpha", g_settings.theme.menu_Content_Text_alpha );
themefile.setInt32( "menu_Content_Text_red", g_settings.theme.menu_Content_Text_red );
themefile.setInt32( "menu_Content_Text_green", g_settings.theme.menu_Content_Text_green );
themefile.setInt32( "menu_Content_Text_blue", g_settings.theme.menu_Content_Text_blue );
themefile.setInt32( "menu_Content_Selected_alpha", g_settings.theme.menu_Content_Selected_alpha );
themefile.setInt32( "menu_Content_Selected_red", g_settings.theme.menu_Content_Selected_red );
themefile.setInt32( "menu_Content_Selected_green", g_settings.theme.menu_Content_Selected_green );
themefile.setInt32( "menu_Content_Selected_blue", g_settings.theme.menu_Content_Selected_blue );
themefile.setInt32( "menu_Content_Selected_Text_alpha", g_settings.theme.menu_Content_Selected_Text_alpha );
themefile.setInt32( "menu_Content_Selected_Text_red", g_settings.theme.menu_Content_Selected_Text_red );
themefile.setInt32( "menu_Content_Selected_Text_green", g_settings.theme.menu_Content_Selected_Text_green );
themefile.setInt32( "menu_Content_Selected_Text_blue", g_settings.theme.menu_Content_Selected_Text_blue );
themefile.setInt32( "menu_Content_inactive_alpha", g_settings.theme.menu_Content_inactive_alpha );
themefile.setInt32( "menu_Content_inactive_red", g_settings.theme.menu_Content_inactive_red );
themefile.setInt32( "menu_Content_inactive_green", g_settings.theme.menu_Content_inactive_green );
themefile.setInt32( "menu_Content_inactive_blue", g_settings.theme.menu_Content_inactive_blue );
themefile.setInt32( "menu_Content_inactive_Text_alpha", g_settings.theme.menu_Content_inactive_Text_alpha );
themefile.setInt32( "menu_Content_inactive_Text_red", g_settings.theme.menu_Content_inactive_Text_red );
themefile.setInt32( "menu_Content_inactive_Text_green", g_settings.theme.menu_Content_inactive_Text_green );
themefile.setInt32( "menu_Content_inactive_Text_blue", g_settings.theme.menu_Content_inactive_Text_blue );
themefile.setInt32( "infobar_alpha", g_settings.theme.infobar_alpha );
themefile.setInt32( "infobar_red", g_settings.theme.infobar_red );
themefile.setInt32( "infobar_green", g_settings.theme.infobar_green );
themefile.setInt32( "infobar_blue", g_settings.theme.infobar_blue );
themefile.setInt32( "infobar_Text_alpha", g_settings.theme.infobar_Text_alpha );
themefile.setInt32( "infobar_Text_red", g_settings.theme.infobar_Text_red );
themefile.setInt32( "infobar_Text_green", g_settings.theme.infobar_Text_green );
themefile.setInt32( "infobar_Text_blue", g_settings.theme.infobar_Text_blue );
themefile.setInt32( "colored_events_alpha", g_settings.theme.colored_events_alpha );
themefile.setInt32( "colored_events_red", g_settings.theme.colored_events_red );
themefile.setInt32( "colored_events_green", g_settings.theme.colored_events_green );
themefile.setInt32( "colored_events_blue", g_settings.theme.colored_events_blue );
themefile.setInt32( "clock_Digit_alpha", g_settings.theme.clock_Digit_alpha );
themefile.setInt32( "clock_Digit_red", g_settings.theme.clock_Digit_red );
themefile.setInt32( "clock_Digit_green", g_settings.theme.clock_Digit_green );
themefile.setInt32( "clock_Digit_blue", g_settings.theme.clock_Digit_blue );
setTheme(themefile);
if (!themefile.saveConfig(themename))
printf("[neutrino theme] %s write error\n", themename);
}
// setup default Colors
void CThemes::setupDefaultColors()
{
CConfigFile empty(':');
CNeutrinoApp::getInstance()->getTheme(empty);
getTheme(empty);
}
void CThemes::setTheme(CConfigFile &configfile)
{
SNeutrinoTheme &t = g_settings.theme;
configfile.setInt32( "menu_Head_alpha", t.menu_Head_alpha );
configfile.setInt32( "menu_Head_red", t.menu_Head_red );
configfile.setInt32( "menu_Head_green", t.menu_Head_green );
configfile.setInt32( "menu_Head_blue", t.menu_Head_blue );
configfile.setInt32( "menu_Head_Text_alpha", t.menu_Head_Text_alpha );
configfile.setInt32( "menu_Head_Text_red", t.menu_Head_Text_red );
configfile.setInt32( "menu_Head_Text_green", t.menu_Head_Text_green );
configfile.setInt32( "menu_Head_Text_blue", t.menu_Head_Text_blue );
configfile.setInt32( "menu_Content_alpha", t.menu_Content_alpha );
configfile.setInt32( "menu_Content_red", t.menu_Content_red );
configfile.setInt32( "menu_Content_green", t.menu_Content_green );
configfile.setInt32( "menu_Content_blue", t.menu_Content_blue );
configfile.setInt32( "menu_Content_Text_alpha", t.menu_Content_Text_alpha );
configfile.setInt32( "menu_Content_Text_red", t.menu_Content_Text_red );
configfile.setInt32( "menu_Content_Text_green", t.menu_Content_Text_green );
configfile.setInt32( "menu_Content_Text_blue", t.menu_Content_Text_blue );
configfile.setInt32( "menu_Content_Selected_alpha", t.menu_Content_Selected_alpha );
configfile.setInt32( "menu_Content_Selected_red", t.menu_Content_Selected_red );
configfile.setInt32( "menu_Content_Selected_green", t.menu_Content_Selected_green );
configfile.setInt32( "menu_Content_Selected_blue", t.menu_Content_Selected_blue );
configfile.setInt32( "menu_Content_Selected_Text_alpha", t.menu_Content_Selected_Text_alpha );
configfile.setInt32( "menu_Content_Selected_Text_red", t.menu_Content_Selected_Text_red );
configfile.setInt32( "menu_Content_Selected_Text_green", t.menu_Content_Selected_Text_green );
configfile.setInt32( "menu_Content_Selected_Text_blue", t.menu_Content_Selected_Text_blue );
configfile.setInt32( "menu_Content_inactive_alpha", t.menu_Content_inactive_alpha );
configfile.setInt32( "menu_Content_inactive_red", t.menu_Content_inactive_red );
configfile.setInt32( "menu_Content_inactive_green", t.menu_Content_inactive_green );
configfile.setInt32( "menu_Content_inactive_blue", t.menu_Content_inactive_blue );
configfile.setInt32( "menu_Content_inactive_Text_alpha", t.menu_Content_inactive_Text_alpha );
configfile.setInt32( "menu_Content_inactive_Text_red", t.menu_Content_inactive_Text_red );
configfile.setInt32( "menu_Content_inactive_Text_green", t.menu_Content_inactive_Text_green );
configfile.setInt32( "menu_Content_inactive_Text_blue", t.menu_Content_inactive_Text_blue );
configfile.setInt32( "infobar_alpha", t.infobar_alpha );
configfile.setInt32( "infobar_red", t.infobar_red );
configfile.setInt32( "infobar_green", t.infobar_green );
configfile.setInt32( "infobar_blue", t.infobar_blue );
configfile.setInt32( "infobar_Text_alpha", t.infobar_Text_alpha );
configfile.setInt32( "infobar_Text_red", t.infobar_Text_red );
configfile.setInt32( "infobar_Text_green", t.infobar_Text_green );
configfile.setInt32( "infobar_Text_blue", t.infobar_Text_blue );
configfile.setInt32( "colored_events_alpha", t.colored_events_alpha );
configfile.setInt32( "colored_events_red", t.colored_events_red );
configfile.setInt32( "colored_events_green", t.colored_events_green );
configfile.setInt32( "colored_events_blue", t.colored_events_blue );
configfile.setInt32( "clock_Digit_alpha", t.clock_Digit_alpha );
configfile.setInt32( "clock_Digit_red", t.clock_Digit_red );
configfile.setInt32( "clock_Digit_green", t.clock_Digit_green );
configfile.setInt32( "clock_Digit_blue", t.clock_Digit_blue );
}
void CThemes::getTheme(CConfigFile &configfile)
{
SNeutrinoTheme &t = g_settings.theme;
t.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 );
t.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 );
t.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A );
t.menu_Head_blue = configfile.getInt32( "menu_Head_blue", 0x19 );
t.menu_Head_Text_alpha = configfile.getInt32( "menu_Head_Text_alpha", 0x00 );
t.menu_Head_Text_red = configfile.getInt32( "menu_Head_Text_red", 0x5f );
t.menu_Head_Text_green = configfile.getInt32( "menu_Head_Text_green", 0x46 );
t.menu_Head_Text_blue = configfile.getInt32( "menu_Head_Text_blue", 0x00 );
t.menu_Content_alpha = configfile.getInt32( "menu_Content_alpha", 0x14 );
t.menu_Content_red = configfile.getInt32( "menu_Content_red", 0x00 );
t.menu_Content_green = configfile.getInt32( "menu_Content_green", 0x0f );
t.menu_Content_blue = configfile.getInt32( "menu_Content_blue", 0x23 );
t.menu_Content_Text_alpha = configfile.getInt32( "menu_Content_Text_alpha", 0x00 );
t.menu_Content_Text_red = configfile.getInt32( "menu_Content_Text_red", 0x64 );
t.menu_Content_Text_green = configfile.getInt32( "menu_Content_Text_green", 0x64 );
t.menu_Content_Text_blue = configfile.getInt32( "menu_Content_Text_blue", 0x64 );
t.menu_Content_Selected_alpha = configfile.getInt32( "menu_Content_Selected_alpha", 0x14 );
t.menu_Content_Selected_red = configfile.getInt32( "menu_Content_Selected_red", 0x19 );
t.menu_Content_Selected_green = configfile.getInt32( "menu_Content_Selected_green", 0x37 );
t.menu_Content_Selected_blue = configfile.getInt32( "menu_Content_Selected_blue", 0x64 );
t.menu_Content_Selected_Text_alpha = configfile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 );
t.menu_Content_Selected_Text_red = configfile.getInt32( "menu_Content_Selected_Text_red", 0x00 );
t.menu_Content_Selected_Text_green = configfile.getInt32( "menu_Content_Selected_Text_green", 0x00 );
t.menu_Content_Selected_Text_blue = configfile.getInt32( "menu_Content_Selected_Text_blue", 0x00 );
t.menu_Content_inactive_alpha = configfile.getInt32( "menu_Content_inactive_alpha", 0x14 );
t.menu_Content_inactive_red = configfile.getInt32( "menu_Content_inactive_red", 0x00 );
t.menu_Content_inactive_green = configfile.getInt32( "menu_Content_inactive_green", 0x0f );
t.menu_Content_inactive_blue = configfile.getInt32( "menu_Content_inactive_blue", 0x23 );
t.menu_Content_inactive_Text_alpha = configfile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 );
t.menu_Content_inactive_Text_red = configfile.getInt32( "menu_Content_inactive_Text_red", 55 );
t.menu_Content_inactive_Text_green = configfile.getInt32( "menu_Content_inactive_Text_green", 70 );
t.menu_Content_inactive_Text_blue = configfile.getInt32( "menu_Content_inactive_Text_blue", 85 );
t.infobar_alpha = configfile.getInt32( "infobar_alpha", 0x14 );
t.infobar_red = configfile.getInt32( "infobar_red", 0x00 );
t.infobar_green = configfile.getInt32( "infobar_green", 0x0e );
t.infobar_blue = configfile.getInt32( "infobar_blue", 0x23 );
t.infobar_Text_alpha = configfile.getInt32( "infobar_Text_alpha", 0x00 );
t.infobar_Text_red = configfile.getInt32( "infobar_Text_red", 0x64 );
t.infobar_Text_green = configfile.getInt32( "infobar_Text_green", 0x64 );
t.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 );
t.colored_events_alpha = configfile.getInt32( "colored_events_alpha", 0x00 );
t.colored_events_red = configfile.getInt32( "colored_events_red", 95 );
t.colored_events_green = configfile.getInt32( "colored_events_green", 70 );
t.colored_events_blue = configfile.getInt32( "colored_events_blue", 0 );
t.clock_Digit_alpha = configfile.getInt32( "clock_Digit_alpha", t.menu_Content_Text_alpha );
t.clock_Digit_red = configfile.getInt32( "clock_Digit_red", t.menu_Content_Text_red );
t.clock_Digit_green = configfile.getInt32( "clock_Digit_green", t.menu_Content_Text_green );
t.clock_Digit_blue = configfile.getInt32( "clock_Digit_blue", t.menu_Content_Text_blue );
}