From e9627c23c07d9060f2a6bdccfcd81a0e28adfe9f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Oct 2020 16:44:19 +0200 Subject: Fix file manager crash on filter selection, reset search on selection --- src/plugins/FileManager.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp index d8a0612..ccaf2c1 100644 --- a/src/plugins/FileManager.cpp +++ b/src/plugins/FileManager.cpp @@ -41,6 +41,11 @@ namespace QuickMedia { return file_get_filetime_or(path1, std::filesystem::file_time_type::min()) > file_get_filetime_or(path2, std::filesystem::file_time_type::min()); }); + if(current_dir != "/") { + auto parent_item = BodyItem::create(".."); + result_items.push_back(std::move(parent_item)); + } + for(auto &p : paths) { auto body_item = BodyItem::create(p.path().filename().string()); // TODO: Check file magic number instead of extension? @@ -62,12 +67,21 @@ namespace QuickMedia { } bool FileManager::set_child_directory(const std::string &filename) { - std::filesystem::path new_path = current_dir / filename; - if(std::filesystem::is_directory(new_path)) { - current_dir = std::move(new_path); - return true; + if(filename == "..") { + std::filesystem::path new_path = current_dir.parent_path(); + if(std::filesystem::is_directory(new_path)) { + current_dir = std::move(new_path); + return true; + } + return false; + } else { + std::filesystem::path new_path = current_dir / filename; + if(std::filesystem::is_directory(new_path)) { + current_dir = std::move(new_path); + return true; + } + return false; } - return false; } const std::filesystem::path& FileManager::get_current_dir() const { -- cgit v1.2.3