mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 23:09:26 -05:00
support "clean" files (#1983)
* init for clean files * textual * icons position
This commit is contained in:
parent
999f9e2ded
commit
14f42d1fe8
@ -402,6 +402,7 @@ void FileSaveView::refresh_widgets() {
|
|||||||
void FileManagerView::refresh_widgets(const bool v) {
|
void FileManagerView::refresh_widgets(const bool v) {
|
||||||
button_rename.hidden(v);
|
button_rename.hidden(v);
|
||||||
button_delete.hidden(v);
|
button_delete.hidden(v);
|
||||||
|
button_clean.hidden(v);
|
||||||
button_cut.hidden(v);
|
button_cut.hidden(v);
|
||||||
button_copy.hidden(v);
|
button_copy.hidden(v);
|
||||||
button_paste.hidden(v);
|
button_paste.hidden(v);
|
||||||
@ -449,7 +450,7 @@ void FileManagerView::on_rename(std::string_view hint) {
|
|||||||
|
|
||||||
void FileManagerView::on_delete() {
|
void FileManagerView::on_delete() {
|
||||||
if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) {
|
if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) {
|
||||||
nav_.display_modal("Delete", "Directory not empty!");
|
nav_.display_modal("Delete", "Directory not empty;\nUse \"clean\" button\nto clean it first");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,6 +475,51 @@ 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");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FileManagerView::on_new_dir() {
|
void FileManagerView::on_new_dir() {
|
||||||
name_buffer = "";
|
name_buffer = "";
|
||||||
text_prompt(nav_, name_buffer, max_filename_length, [this](std::string& dir_name) {
|
text_prompt(nav_, name_buffer, max_filename_length, [this](std::string& dir_name) {
|
||||||
@ -560,6 +606,7 @@ FileManagerView::FileManagerView(
|
|||||||
&text_date,
|
&text_date,
|
||||||
&button_rename,
|
&button_rename,
|
||||||
&button_delete,
|
&button_delete,
|
||||||
|
&button_clean,
|
||||||
&button_cut,
|
&button_cut,
|
||||||
&button_copy,
|
&button_copy,
|
||||||
&button_paste,
|
&button_paste,
|
||||||
@ -606,6 +653,11 @@ FileManagerView::FileManagerView(
|
|||||||
on_delete();
|
on_delete();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
button_clean.on_select = [this]() {
|
||||||
|
if (selected_is_valid())
|
||||||
|
on_clean();
|
||||||
|
};
|
||||||
|
|
||||||
button_cut.on_select = [this]() {
|
button_cut.on_select = [this]() {
|
||||||
if (selected_is_valid() && !get_selected_entry().is_directory) {
|
if (selected_is_valid() && !get_selected_entry().is_directory) {
|
||||||
clipboard_path = get_selected_full_path();
|
clipboard_path = get_selected_full_path();
|
||||||
|
@ -207,6 +207,7 @@ class FileManagerView : public FileManBaseView {
|
|||||||
void refresh_widgets(const bool v);
|
void refresh_widgets(const bool v);
|
||||||
void on_rename(std::string_view hint);
|
void on_rename(std::string_view hint);
|
||||||
void on_delete();
|
void on_delete();
|
||||||
|
void on_clean();
|
||||||
void on_paste();
|
void on_paste();
|
||||||
void on_new_dir();
|
void on_new_dir();
|
||||||
void on_new_file();
|
void on_new_file();
|
||||||
@ -227,11 +228,17 @@ class FileManagerView : public FileManBaseView {
|
|||||||
Color::dark_blue()};
|
Color::dark_blue()};
|
||||||
|
|
||||||
NewButton button_delete{
|
NewButton button_delete{
|
||||||
{4 * 8, 29 * 8, 4 * 8, 32},
|
{9 * 8, 34 * 8, 4 * 8, 32},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_trash,
|
&bitmap_icon_trash,
|
||||||
Color::red()};
|
Color::red()};
|
||||||
|
|
||||||
|
NewButton button_clean{
|
||||||
|
{13 * 8, 34 * 8, 4 * 8, 32},
|
||||||
|
{},
|
||||||
|
&bitmap_icon_scanner,
|
||||||
|
Color::red()};
|
||||||
|
|
||||||
NewButton button_cut{
|
NewButton button_cut{
|
||||||
{9 * 8, 29 * 8, 4 * 8, 32},
|
{9 * 8, 29 * 8, 4 * 8, 32},
|
||||||
{},
|
{},
|
||||||
@ -269,20 +276,22 @@ class FileManagerView : public FileManBaseView {
|
|||||||
Color::orange()};
|
Color::orange()};
|
||||||
|
|
||||||
NewButton button_rename_timestamp{
|
NewButton button_rename_timestamp{
|
||||||
{4 * 8, 34 * 8, 4 * 8, 32},
|
|
||||||
|
{4 * 8, 29 * 8, 4 * 8, 32},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_options_datetime,
|
&bitmap_icon_options_datetime,
|
||||||
Color::orange(),
|
Color::orange(),
|
||||||
/*vcenter*/ true};
|
/*vcenter*/ true};
|
||||||
|
|
||||||
NewButton button_open_iq_trim{
|
NewButton button_open_iq_trim{
|
||||||
{9 * 8, 34 * 8, 4 * 8, 32},
|
|
||||||
|
{4 * 8, 34 * 8, 4 * 8, 32},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_trim,
|
&bitmap_icon_trim,
|
||||||
Color::orange()};
|
Color::orange()};
|
||||||
|
|
||||||
NewButton button_show_hidden_files{
|
NewButton button_show_hidden_files{
|
||||||
{13 * 8, 34 * 8, 4 * 8, 32},
|
{17 * 8, 34 * 8, 4 * 8, 32},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_hide,
|
&bitmap_icon_hide,
|
||||||
Color::dark_grey()};
|
Color::dark_grey()};
|
||||||
|
Loading…
Reference in New Issue
Block a user