1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 12:48:26 +02:00

Remove unnecessary file existence check in GMenu2X::setSkin(2)

The existence of modifications to the skin configuration in the home
directory is now checked with ifstream::is_open, and the system's skin
configuration is used if that returns false.
This commit is contained in:
Nebuleon Fumika 2014-08-10 23:11:13 +00:00 committed by Maarten ter Huurne
parent ebb34f3e00
commit d6b2643610
2 changed files with 39 additions and 34 deletions

View File

@ -783,12 +783,35 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
/* Load skin settings from user directory if present,
* or from the system directory. */
string skinconfname = getHome() + "/skins/" + skin + "/skin.conf";
if (!fileExists(skinconfname))
skinconfname = GMENU2X_SYSTEM_DIR "/skins/" + skin + "/skin.conf";
if (!readSkinConfig(getHome() + "/skins/" + skin + "/skin.conf")) {
readSkinConfig(GMENU2X_SYSTEM_DIR "/skins/" + skin + "/skin.conf");
}
if (fileExists(skinconfname)) {
ifstream skinconf(skinconfname.c_str(), ios_base::in);
if (setWallpaper && !skinConfStr["wallpaper"].empty()) {
string fp = sc.getSkinFilePath("wallpapers/" + skinConfStr["wallpaper"]);
if (!fp.empty())
confStr["wallpaper"] = fp;
else
WARNING("Unable to find wallpaper defined on skin %s\n", skin.c_str());
}
evalIntConf(skinConfInt, "topBarHeight", 50, 32, 120);
evalIntConf(skinConfInt, "bottomBarHeight", 20, 20, 120);
evalIntConf(skinConfInt, "linkHeight", 50, 32, 120);
evalIntConf(skinConfInt, "linkWidth", 80, 32, 120);
if (menu != NULL) menu->skinUpdated();
//Selection png
useSelectionPng = sc.addSkinRes("imgs/selection.png", false) != NULL;
//font
initFont();
}
bool GMenu2X::readSkinConfig(const string& conffile)
{
ifstream skinconf(conffile.c_str(), ios_base::in);
if (skinconf.is_open()) {
string line;
while (getline(skinconf, line, '\n')) {
@ -809,30 +832,11 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
}
}
skinconf.close();
if (setWallpaper && !skinConfStr["wallpaper"].empty()) {
string fp = sc.getSkinFilePath("wallpapers/" + skinConfStr["wallpaper"]);
if (!fp.empty())
confStr["wallpaper"] = fp;
else
WARNING("Unable to find wallpaper defined on skin %s\n", skin.c_str());
return true;
} else {
return false;
}
}
}
evalIntConf(skinConfInt, "topBarHeight", 50, 32, 120);
evalIntConf(skinConfInt, "bottomBarHeight", 20, 20, 120);
evalIntConf(skinConfInt, "linkHeight", 50, 32, 120);
evalIntConf(skinConfInt, "linkWidth", 80, 32, 120);
if (menu != NULL) menu->skinUpdated();
//Selection png
useSelectionPng = sc.addSkinRes("imgs/selection.png", false) != NULL;
//font
initFont();
}
void GMenu2X::showManual() {
menu->selLinkApp()->showManual();

View File

@ -154,6 +154,7 @@ public:
//Configuration settings
bool useSelectionPng;
void setSkin(const std::string &skin, bool setWallpaper = true);
bool readSkinConfig(const std::string& conffile);
SurfaceCollection sc;
Translator tr;