aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-02 16:44:19 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-02 16:44:19 +0200
commite9627c23c07d9060f2a6bdccfcd81a0e28adfe9f (patch)
tree55f6bafa8b6e5982932714a86ed33d7ea17e5ac4 /src/plugins
parentd9cb6885ab741ba69a966109cb05e26692143ce0 (diff)
Fix file manager crash on filter selection, reset search on selection
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/FileManager.cpp24
1 files changed, 19 insertions, 5 deletions
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 {