1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 12:57:31 +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;
FileLister fl("skins/"+gmenu2x->confStr["skin"]+"/wallpapers");
FileLister fl;
fl.setFilter(".png,.jpg,.jpeg,.bmp");
vector<string> wallpapers;
if (fileExists("skins/"+gmenu2x->confStr["skin"]+"/wallpapers")) {
fl.browse();
wallpapers = fl.getFiles();
string filepath = GMENU2X_SYSTEM_DIR "/skins/"
+ gmenu2x->confStr["skin"] + "/wallpapers";
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") {
fl.setPath("skins/Default/wallpapers",true);
for (uint i=0; i<fl.getFiles().size(); i++)
wallpapers.push_back(fl.getFiles()[i]);
filepath = GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers";
if (fileExists(filepath)) {
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());
uint i, selected = 0, firstElement = 0, iY;
@ -57,10 +75,7 @@ bool WallpaperDialog::exec()
if (selected<firstElement) firstElement=selected;
//Wallpaper
if (selected<wallpapers.size()-fl.getFiles().size())
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->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(gmenu2x->s, 0, 0);
gmenu2x->drawTopBar(gmenu2x->s);
gmenu2x->drawBottomBar(gmenu2x->s);
@ -111,22 +126,16 @@ bool WallpaperDialog::exec()
break;
case ACCEPT:
close = true;
if (wallpapers.size() > 0) {
if (selected < wallpapers.size() - fl.getFiles().size())
wallpaper = "skins/" + gmenu2x->confStr["skin"] + "/wallpapers/" + wallpapers[selected];
else
wallpaper = "skins/Default/wallpapers/" + wallpapers[selected];
} else result = false;
if (wallpapers.size() > 0)
wallpaper = gmenu2x->sc.getSkinFilePath("wallpapers/" + wallpapers[selected]);
else result = false;
default:
break;
}
}
for (uint i=0; i<wallpapers.size(); i++)
if (i<wallpapers.size()-fl.getFiles().size())
gmenu2x->sc.del("skins/"+gmenu2x->confStr["skin"]+"/wallpapers/"+wallpapers[i]);
else
gmenu2x->sc.del("skins/Default/wallpapers/"+wallpapers[i]);
gmenu2x->sc.del("skin:wallpapers/" + wallpapers[i]);
return result;
}