diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-12 23:02:10 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-12 23:02:10 +0200 |
commit | 6f1a252490e7c74f577470616fc5fcaf79716c60 (patch) | |
tree | 255df3d300e3998b57a218c0a2ccdacbc4d904c9 | |
parent | 34329ff4ca3b8805ef893b3da67735bcaa460edf (diff) |
Add file and folder icons to file manager
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | images/file.png | bin | 0 -> 1074 bytes | |||
-rw-r--r-- | images/folder.png | bin | 0 -> 826 bytes | |||
-rw-r--r-- | include/ResourceLoader.hpp | 1 | ||||
-rw-r--r-- | src/ResourceLoader.cpp | 4 | ||||
-rw-r--r-- | src/plugins/FileManager.cpp | 12 |
6 files changed, 17 insertions, 1 deletions
@@ -125,7 +125,6 @@ Update room name and topic text in ui when they change. Support webp directly without using ffmpeg to convert it to a png. Add client side 4chan file size limit (note, webm has different limit than images). Add client side 4chan max comment chars limit. -Use a directory icon and a file icon for non-media files in the file manager. Dynamically fetch 4chan api key, if it ever changes in the future. Same for youtube. Set curl download limits everywhere (when saving to file, downloading to json, etc...). In the downloader if we already have the url in thumbnail/video cache, then copy it to the destination instead of redownloading it. This would also fix downloading images when viewing a manga page.
\ No newline at end of file diff --git a/images/file.png b/images/file.png Binary files differnew file mode 100644 index 0000000..22806e9 --- /dev/null +++ b/images/file.png diff --git a/images/folder.png b/images/folder.png Binary files differnew file mode 100644 index 0000000..06f2b63 --- /dev/null +++ b/images/folder.png diff --git a/include/ResourceLoader.hpp b/include/ResourceLoader.hpp index a332ba4..440eb7f 100644 --- a/include/ResourceLoader.hpp +++ b/include/ResourceLoader.hpp @@ -7,6 +7,7 @@ namespace sf { namespace QuickMedia { void set_resource_loader_root_path(const char *resource_root); + const char* get_resource_loader_root_path(); } namespace QuickMedia::FontLoader { diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index f6c8354..85b3619 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -14,6 +14,10 @@ namespace QuickMedia { void set_resource_loader_root_path(const char *new_resource_root) { resource_root = new_resource_root; } + + const char* get_resource_loader_root_path() { + return resource_root.c_str(); + } } namespace QuickMedia::FontLoader { diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp index 6ee7e71..5ca7dc7 100644 --- a/src/plugins/FileManager.cpp +++ b/src/plugins/FileManager.cpp @@ -1,5 +1,6 @@ #include "../../plugins/FileManager.hpp" #include "../../include/FileAnalyzer.hpp" +#include "../../include/ResourceLoader.hpp" #include "../../include/QuickMedia.hpp" namespace QuickMedia { @@ -106,6 +107,15 @@ namespace QuickMedia { if(file_mime_type == FILE_MANAGER_MIME_TYPE_IMAGE || file_mime_type == FILE_MANAGER_MIME_TYPE_VIDEO) { body_item->thumbnail_is_local = true; body_item->thumbnail_url = p.path().string(); + } else { + body_item->thumbnail_is_local = true; + if(is_regular_file) { + body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/file.png"); + body_item->thumbnail_size = sf::Vector2i(18, 24); + } else { + body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/folder.png"); + body_item->thumbnail_size = sf::Vector2i(24, 22); + } } time_t last_modified_time = std::chrono::duration_cast<std::chrono::seconds>(file_get_last_modified_time(p, std::filesystem::file_time_type::min()).time_since_epoch()).count(); @@ -123,6 +133,8 @@ namespace QuickMedia { if(is_regular_file) { description += "\n"; description += "Size: " + file_size_to_human_readable_string(file_size); + } else { + description += "\nDirectory"; } body_item->set_description(std::move(description)); body_item->set_description_color(sf::Color(179, 179, 179)); |