mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
File manager "Clean" button tweaks (#1990)
* File Manager "clean" button tweaks * Add files via upload
This commit is contained in:
parent
14f42d1fe8
commit
f0614c882b
@ -450,7 +450,7 @@ void FileManagerView::on_rename(std::string_view hint) {
|
||||
|
||||
void FileManagerView::on_delete() {
|
||||
if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) {
|
||||
nav_.display_modal("Delete", "Directory not empty;\nUse \"clean\" button\nto clean it first");
|
||||
nav_.display_modal("Delete", " Folder is not empty;\n Use \"Clean\" button to\n empty it first.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -476,48 +476,28 @@ void FileManagerView::on_delete() {
|
||||
}
|
||||
|
||||
void FileManagerView::on_clean() {
|
||||
if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) {
|
||||
////selected a dir, who is not empty, del sub files
|
||||
nav_.push<ModalMessageView>(
|
||||
"Delete", "Will delete all sub files\nexclude sub-folders,\nin this folder\nAre you sure?", YESNO,
|
||||
[this](bool choice) {
|
||||
if (choice) {
|
||||
std::vector<std::filesystem::path> file_list;
|
||||
file_list = scan_root_files(get_selected_full_path(), u"*");
|
||||
|
||||
for (const auto& file_name : file_list) {
|
||||
std::filesystem::path current_full_path = get_selected_full_path() / file_name;
|
||||
delete_file(current_full_path);
|
||||
}
|
||||
reload_current();
|
||||
}
|
||||
});
|
||||
} else if (!is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) {
|
||||
////selected a file, will del it and all others in this dir
|
||||
nav_.push<ModalMessageView>(
|
||||
"Delete", "Will delete all files\nexclude sub-folders\nin this folder,\nAre you sure?", YESNO,
|
||||
[this](bool choice) {
|
||||
if (choice) {
|
||||
std::vector<std::filesystem::path> file_list;
|
||||
file_list = scan_root_files(get_selected_full_path().parent_path(), u"*");
|
||||
|
||||
for (const auto& file_name : file_list) {
|
||||
std::filesystem::path current_full_path = get_selected_full_path().parent_path() / file_name;
|
||||
delete_file(current_full_path);
|
||||
}
|
||||
reload_current();
|
||||
}
|
||||
});
|
||||
|
||||
} else if (is_directory(get_selected_full_path()) && is_empty_directory(get_selected_full_path())) {
|
||||
////sel an empty dir, threw
|
||||
nav_.display_modal("Forbid", "You selected an empty dir;\nUse delete button \ninstead of clean button\nto delete it");
|
||||
return;
|
||||
} else {
|
||||
////edge case e.g. probably . or .. (maybe not needed?)
|
||||
nav_.display_modal("Forbid", "Not able to do that");
|
||||
if (is_empty_directory(get_selected_full_path())) {
|
||||
nav_.display_modal("Clean", "Folder is Empty;\nUse \"Delete\" button instead\nof \"Clean\" button to delete\nit.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto path_name = is_directory(get_selected_full_path()) ? get_selected_full_path() : get_selected_full_path().parent_path();
|
||||
|
||||
// selected either a single file (delete files in this directory) or a directory that is not empty (del sub files)
|
||||
nav_.push<ModalMessageView>(
|
||||
"Clean", " ALL FILES in this folder\n (excluding sub-folders)\n will be DELETED!\n\n Delete all files?", YESNO,
|
||||
[this, path_name](bool choice) {
|
||||
if (choice) {
|
||||
std::vector<std::filesystem::path> file_list;
|
||||
file_list = scan_root_files(path_name, u"*");
|
||||
|
||||
for (const auto& file_name : file_list) {
|
||||
std::filesystem::path current_full_path = path_name / file_name;
|
||||
delete_file(current_full_path);
|
||||
}
|
||||
reload_current();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FileManagerView::on_new_dir() {
|
||||
|
@ -236,7 +236,7 @@ class FileManagerView : public FileManBaseView {
|
||||
NewButton button_clean{
|
||||
{13 * 8, 34 * 8, 4 * 8, 32},
|
||||
{},
|
||||
&bitmap_icon_scanner,
|
||||
&bitmap_icon_clean,
|
||||
Color::red()};
|
||||
|
||||
NewButton button_cut{
|
||||
|
@ -5797,6 +5797,44 @@ static constexpr Bitmap bitmap_icon_brightness{
|
||||
{16, 16},
|
||||
bitmap_icon_brightness_data};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_clean_data[] = {
|
||||
0x00,
|
||||
0x00,
|
||||
0xC0,
|
||||
0x01,
|
||||
0x20,
|
||||
0x02,
|
||||
0xFC,
|
||||
0x1F,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
0x08,
|
||||
0xE8,
|
||||
0x08,
|
||||
0xA8,
|
||||
0x09,
|
||||
0xA8,
|
||||
0x0B,
|
||||
0x28,
|
||||
0x0A,
|
||||
0x28,
|
||||
0x0A,
|
||||
0x28,
|
||||
0x0A,
|
||||
0xE8,
|
||||
0x0B,
|
||||
0x08,
|
||||
0x08,
|
||||
0xF0,
|
||||
0x07,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_clean{
|
||||
{16, 16},
|
||||
bitmap_icon_clean_data};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__BITMAP_HPP__*/
|
||||
|
BIN
firmware/graphics/icon_clean.png
Normal file
BIN
firmware/graphics/icon_clean.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 B |
Loading…
Reference in New Issue
Block a user