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

The wallpapers will now be loaded from the system and the user-specific skin directories.

This commit is contained in:
Ayla 2011-04-12 10:18:10 +02:00
parent f4b03108c1
commit f2b34f383b

View File

@ -35,19 +35,37 @@ bool WallpaperDialog::exec()
{ {
bool close = false, result = true; bool close = false, result = true;
FileLister fl("skins/"+gmenu2x->confStr["skin"]+"/wallpapers"); FileLister fl;
fl.setFilter(".png,.jpg,.jpeg,.bmp"); fl.setFilter(".png,.jpg,.jpeg,.bmp");
vector<string> wallpapers;
if (fileExists("skins/"+gmenu2x->confStr["skin"]+"/wallpapers")) { string filepath = GMENU2X_SYSTEM_DIR "/skins/"
fl.browse(); + gmenu2x->confStr["skin"] + "/wallpapers";
wallpapers = fl.getFiles(); if (fileExists(filepath))
fl.setPath(filepath, true);
filepath = GMenu2X::getHome() + "/skins/"
+ gmenu2x->confStr["skin"] + "/wallpapers";
if (fileExists(filepath)) {
fl.setPath(filepath, false);
fl.browse(false);
} }
if (gmenu2x->confStr["skin"] != "Default") { if (gmenu2x->confStr["skin"] != "Default") {
fl.setPath("skins/Default/wallpapers",true); filepath = GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers";
for (uint i=0; i<fl.getFiles().size(); i++) if (fileExists(filepath)) {
wallpapers.push_back(fl.getFiles()[i]); fl.setPath(filepath, false);
fl.browse(false);
} }
filepath = GMenu2X::getHome() + "/skins/Default/wallpapers";
if (fileExists(filepath)) {
fl.setPath(filepath, false);
fl.browse(false);
}
}
vector<string> wallpapers = fl.getFiles();
DEBUG("Wallpapers: %i\n", wallpapers.size()); DEBUG("Wallpapers: %i\n", wallpapers.size());
uint i, selected = 0, firstElement = 0, iY; uint i, selected = 0, firstElement = 0, iY;
@ -57,10 +75,7 @@ bool WallpaperDialog::exec()
if (selected<firstElement) firstElement=selected; if (selected<firstElement) firstElement=selected;
//Wallpaper //Wallpaper
if (selected<wallpapers.size()-fl.getFiles().size()) gmenu2x->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(gmenu2x->s, 0, 0);
gmenu2x->sc["skins/"+gmenu2x->confStr["skin"]+"/wallpapers/"+wallpapers[selected]]->blit(gmenu2x->s,0,0);
else
gmenu2x->sc["skins/Default/wallpapers/"+wallpapers[selected]]->blit(gmenu2x->s,0,0);
gmenu2x->drawTopBar(gmenu2x->s); gmenu2x->drawTopBar(gmenu2x->s);
gmenu2x->drawBottomBar(gmenu2x->s); gmenu2x->drawBottomBar(gmenu2x->s);
@ -111,22 +126,16 @@ bool WallpaperDialog::exec()
break; break;
case ACCEPT: case ACCEPT:
close = true; close = true;
if (wallpapers.size() > 0) { if (wallpapers.size() > 0)
if (selected < wallpapers.size() - fl.getFiles().size()) wallpaper = gmenu2x->sc.getSkinFilePath("wallpapers/" + wallpapers[selected]);
wallpaper = "skins/" + gmenu2x->confStr["skin"] + "/wallpapers/" + wallpapers[selected]; else result = false;
else
wallpaper = "skins/Default/wallpapers/" + wallpapers[selected];
} else result = false;
default: default:
break; break;
} }
} }
for (uint i=0; i<wallpapers.size(); i++) for (uint i=0; i<wallpapers.size(); i++)
if (i<wallpapers.size()-fl.getFiles().size()) gmenu2x->sc.del("skin:wallpapers/" + wallpapers[i]);
gmenu2x->sc.del("skins/"+gmenu2x->confStr["skin"]+"/wallpapers/"+wallpapers[i]);
else
gmenu2x->sc.del("skins/Default/wallpapers/"+wallpapers[i]);
return result; return result;
} }