diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-10 18:49:44 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-10 22:41:04 +0200 |
commit | cdf8d103f1ed6a932eb30b589b578d23ca66a514 (patch) | |
tree | 0782751764748be50c4203b8e1af14907046e3d2 /plugins | |
parent | 2eac1e3d3ece90d1c522e15cb57ee41baa3dd822 (diff) |
Add downloader, fix room navigation lag
Fix bug where getting next page fails if there is no search bar
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/FileManager.hpp | 19 | ||||
-rw-r--r-- | plugins/Page.hpp | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/plugins/FileManager.hpp b/plugins/FileManager.hpp index 72ac75d..20ed49c 100644 --- a/plugins/FileManager.hpp +++ b/plugins/FileManager.hpp @@ -4,6 +4,8 @@ #include <filesystem> namespace QuickMedia { + class FileManagerPage; + enum FileManagerMimeType { FILE_MANAGER_MIME_TYPE_IMAGE = (1 << 0), FILE_MANAGER_MIME_TYPE_VIDEO = (1 << 1), @@ -12,20 +14,31 @@ namespace QuickMedia { static const FileManagerMimeType FILE_MANAGER_MIME_TYPE_ALL = (FileManagerMimeType)(FILE_MANAGER_MIME_TYPE_IMAGE|FILE_MANAGER_MIME_TYPE_VIDEO|FILE_MANAGER_MIME_TYPE_OTHER); // Return the tags to go to after selecting a file, or return an empty array to exit the program - using FileSelectionHandler = std::function<std::vector<Tab>()>; + using FileSelectionHandler = std::function<std::vector<Tab>(FileManagerPage*, const std::filesystem::path&)>; class FileManagerPage : public Page { public: - FileManagerPage(Program *program, FileManagerMimeType mime_type = FILE_MANAGER_MIME_TYPE_ALL, FileSelectionHandler selection_handler = nullptr) : Page(program), current_dir("/"), mime_type(mime_type), selection_handler(selection_handler) {} - const char* get_title() const override { return current_dir.c_str(); } + FileManagerPage(Program *program, FileManagerMimeType mime_type = FILE_MANAGER_MIME_TYPE_ALL, FileSelectionHandler selection_handler = nullptr, bool allow_empty_match_submit = false, const std::string &title_prefix = "") : + Page(program), current_dir("/"), mime_type(mime_type), selection_handler(selection_handler), allow_empty_match_submit(allow_empty_match_submit), title_prefix(title_prefix) + { + title = title_prefix + current_dir.string(); + } + const char* get_title() const override { return title.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; bool is_single_page() const override { return true; } + bool allow_submit_no_selection() const override { return allow_empty_match_submit; } + void on_navigate_to_page(Body*) override; bool set_current_directory(const std::string &path); PluginResult get_files_in_directory(BodyItems &result_items); + + bool close = false; private: std::filesystem::path current_dir; FileManagerMimeType mime_type; FileSelectionHandler selection_handler; + bool allow_empty_match_submit; + std::string title; + std::string title_prefix; }; }
\ No newline at end of file diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 426469a..78eb3c4 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -47,7 +47,7 @@ namespace QuickMedia { virtual bool is_single_page() const { return false; } virtual bool is_trackable() const { return false; } virtual bool is_lazy_fetch_page() const { return false; } - // Note: If submit is done without any selection, then the search term is sent as the |title|, not |url| + // Note: If submit is done without any selection, then the search term is sent as the |title|, not |url|. Submit will only be sent if the input text is not empty or if an item is selected virtual bool allow_submit_no_selection() const { return false; } // This is called both when first navigating to page and when going back to page |