From f85ef14b3e9f63f8a139a14d574830d2aa6501f8 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 13 Aug 2014 07:27:55 +0000 Subject: [PATCH] Remove unnecessary file existence check in WallpaperDialog::exec() Browsing the user's wallpaper directory will simply add no new files to the list of wallpapers available if the directory doesn't exist. WallpaperDialog::exec doesn't need to care about that. Because wallpapers are files, not directories, also don't return directories in the result. The code that makes the wallpapers list calls FileLister::getFiles and ignores directories anyway. --- src/wallpaperdialog.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/wallpaperdialog.cpp b/src/wallpaperdialog.cpp index 67c7159..6ffa4b9 100644 --- a/src/wallpaperdialog.cpp +++ b/src/wallpaperdialog.cpp @@ -43,30 +43,17 @@ bool WallpaperDialog::exec() bool close = false, result = true; FileLister fl; + fl.setShowDirectories(false); fl.setFilter("png"); - string filepath = GMenu2X::getHome() + "/skins/" - + gmenu2x->confStr["skin"] + "/wallpapers"; - if (fileExists(filepath)) { - fl.browse(filepath, true); - } - - filepath = GMENU2X_SYSTEM_DIR "/skins/" - + gmenu2x->confStr["skin"] + "/wallpapers"; - if (fileExists(filepath)) { - fl.browse(filepath, false); - } + fl.browse(GMenu2X::getHome() + "/skins/" + + gmenu2x->confStr["skin"] + "/wallpapers", true); + fl.browse(GMENU2X_SYSTEM_DIR "/skins/" + + gmenu2x->confStr["skin"] + "/wallpapers", false); if (gmenu2x->confStr["skin"] != "Default") { - filepath = GMenu2X::getHome() + "/skins/Default/wallpapers"; - if (fileExists(filepath)) { - fl.browse(filepath, false); - } - - filepath = GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers"; - if (fileExists(filepath)) { - fl.browse(filepath, false); - } + fl.browse(GMenu2X::getHome() + "/skins/Default/wallpapers", false); + fl.browse(GMENU2X_SYSTEM_DIR "/skins/Default/wallpapers", false); } vector wallpapers = fl.getFiles();