Skip to content

Commit

Permalink
FileMan support for folder Cut & Paste and Timestamp Rename (#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotherNgineer authored Mar 29, 2024
1 parent 90ff1e6 commit ba36680
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions firmware/application/apps/ui_fileman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,10 @@ void FileManagerView::on_paste() {
fs::filesystem_error result;

if (clipboard_mode == ClipboardMode::Cut)
result = rename_file(clipboard_path, current_path / new_name);
if ((current_path / clipboard_path.filename()) == clipboard_path)
result = FR_OK; // Skip paste to avoid renaming if path is unchanged
else
result = rename_file(clipboard_path, current_path / new_name);

else if (clipboard_mode == ClipboardMode::Copy)
result = copy_file(clipboard_path, current_path / new_name);
Expand Down Expand Up @@ -639,7 +642,7 @@ FileManagerView::FileManagerView(
};

button_cut.on_select = [this]() {
if (selected_is_valid() && !get_selected_entry().is_directory) {
if (selected_is_valid()) {
clipboard_path = get_selected_full_path();
clipboard_mode = ClipboardMode::Cut;
} else
Expand All @@ -658,7 +661,7 @@ FileManagerView::FileManagerView(
if (clipboard_mode != ClipboardMode::None)
on_paste();
else
nav_.display_modal("Paste", "Cut or copy a file first.");
nav_.display_modal("Paste", " Cut or copy a file,\n or cut a folder, first.");
};

button_new_dir.on_select = [this]() {
Expand All @@ -678,7 +681,7 @@ FileManagerView::FileManagerView(
};

button_rename_timestamp.on_select = [this]() {
if (selected_is_valid() && !get_selected_entry().is_directory) {
if (selected_is_valid()) {
on_rename(::truncate(to_string_timestamp(rtc_time::now()), 8));
} else
nav_.display_modal("Timestamp Rename", "Can't rename that.");
Expand Down

0 comments on commit ba36680

Please sign in to comment.