1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 19:03:44 +02:00

The FileLister won't list a file if a previous one has the same file name (without path).

This is useful when the files/directories lists are not cleared; then it is possible to define priorities between the files.
For instance, the skin "Default" will be shown only once, even if the directory "Default" exists both in the system and the user directories.
As the skin and translation loading functions does check both directories, there is no problem in doing that.
This commit is contained in:
Ayla 2011-04-14 11:16:16 +02:00
parent f10bb60717
commit 6c97139113
3 changed files with 18 additions and 10 deletions

View File

@ -88,8 +88,8 @@ void FileLister::browse(bool clean)
while ((dptr = readdir(dirp))) {
file = dptr->d_name;
file_lowercase = file;
std::transform(file_lowercase.begin(), file_lowercase.end(), file_lowercase.begin(), ::tolower);
file_lowercase = file;
std::transform(file_lowercase.begin(), file_lowercase.end(), file_lowercase.begin(), ::tolower);
if (file[0] == '.' && file != "..")
continue;
@ -106,10 +106,18 @@ void FileLister::browse(bool clean)
if (S_ISDIR(st.st_mode)) {
if (!showDirectories)
continue;
if (std::find(directories.begin(), directories.end(), file) != directories.end())
continue;
directories.push_back(file);
} else {
if (!showFiles)
continue;
if (std::find(files.begin(), files.end(), file) != files.end())
continue;
for (vector<string>::iterator it = vfilter.begin(); it != vfilter.end(); ++it) {
if (it->length() <= file.length()) {
if (file_lowercase.compare(file.length() - it->length(), it->length(), *it) == 0) {

View File

@ -1128,9 +1128,9 @@ void GMenu2X::options() {
int prevbacklight = confInt["backlight"];
bool showRootFolder = fileExists(CARD_ROOT);
FileLister fl_tr(GMENU2X_SYSTEM_DIR "/translations");
FileLister fl_tr(getHome() + "/translations");
fl_tr.browse();
fl_tr.setPath(getHome() + "/translations", false);
fl_tr.setPath(GMENU2X_SYSTEM_DIR "/translations", false);
fl_tr.browse(false);
fl_tr.insertFile("English");
@ -1197,10 +1197,10 @@ void GMenu2X::settingsOpen2x() {
}
void GMenu2X::skinMenu() {
FileLister fl_sk(GMENU2X_SYSTEM_DIR "/skins", true, false);
FileLister fl_sk(getHome() + "/skins", true, false);
fl_sk.addExclude("..");
fl_sk.browse();
fl_sk.setPath(getHome() + "/skins", false);
fl_sk.setPath(GMENU2X_SYSTEM_DIR "/skins", false);
fl_sk.browse(false);
string curSkin = confStr["skin"];

View File

@ -38,12 +38,12 @@ bool WallpaperDialog::exec()
FileLister fl;
fl.setFilter(".png,.jpg,.jpeg,.bmp");
string filepath = GMENU2X_SYSTEM_DIR "/skins/"
string filepath = GMenu2X::getHome() + "/skins/"
+ gmenu2x->confStr["skin"] + "/wallpapers";
if (fileExists(filepath))
fl.setPath(filepath, true);
filepath = GMenu2X::getHome() + "/skins/"
filepath = GMENU2X_SYSTEM_DIR "/skins/"
+ gmenu2x->confStr["skin"] + "/wallpapers";
if (fileExists(filepath)) {
fl.setPath(filepath, false);
@ -51,13 +51,13 @@ bool WallpaperDialog::exec()
}
if (gmenu2x->confStr["skin"] != "Default") {
filepath = GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers";
filepath = GMenu2X::getHome() + "/skins/Default/wallpapers";
if (fileExists(filepath)) {
fl.setPath(filepath, false);
fl.browse(false);
}
filepath = GMenu2X::getHome() + "/skins/Default/wallpapers";
filepath = GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers";
if (fileExists(filepath)) {
fl.setPath(filepath, false);
fl.browse(false);