Fix path separator, revert UI

This commit is contained in:
Kyle Reed 2023-05-02 20:49:41 -07:00
parent 11f4edc892
commit 3fc23354ce
3 changed files with 16 additions and 18 deletions

View File

@ -20,9 +20,10 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
/* BUGS: /* TODO:
* - OOM/paging menu items * - Paging menu items
* - Using UI with empty SD card * - UI with empty SD card
* - Copy/Move
*/ */
#include <algorithm> #include <algorithm>
@ -328,7 +329,7 @@ FileLoadView::FileLoadView(
on_select_entry = [this](KeyEvent) { on_select_entry = [this](KeyEvent) {
if (get_selected_entry().is_directory) { if (get_selected_entry().is_directory) {
current_path /= get_selected_entry().path; current_path = get_selected_full_path();
reload_current(); reload_current();
} else { } else {
nav_.pop(); nav_.pop();
@ -354,20 +355,17 @@ void FileManagerView::on_rename() {
text_prompt(nav_, name_buffer, cursor_pos, max_filename_length, text_prompt(nav_, name_buffer, cursor_pos, max_filename_length,
[this, &entry](std::string& renamed) { [this, &entry](std::string& renamed) {
auto renamed_path = fs::path{ renamed }; auto renamed_path = fs::path{ renamed };
bool has_partner = false;
rename_file(get_selected_full_path(), current_path / renamed_path); rename_file(get_selected_full_path(), current_path / renamed_path);
if (iequal(renamed_path.extension(), entry.path.extension())) { auto has_partner = partner_file_prompt(nav_, entry.path, "Rename",
has_partner = partner_file_prompt(nav_, entry.path, "Rename", [this, renamed_path](const fs::path& partner, bool should_rename) mutable {
[this, renamed_path](const fs::path& partner, bool should_rename) mutable { if (should_rename) {
if (should_rename) { auto new_name = renamed_path.replace_extension(partner.extension());
auto new_name = renamed_path.replace_extension(partner.extension()); rename_file(current_path / partner, current_path / new_name);
rename_file(current_path / partner, current_path / new_name);
}
reload_current();
} }
); reload_current();
} }
);
if (!has_partner) if (!has_partner)
reload_current(); reload_current();

View File

@ -163,12 +163,12 @@ private:
}; };
Button button_rename { Button button_rename {
{ 0 * 8, 29 * 8, 9 * 8, 32 }, { 0 * 8, 29 * 8, 14 * 8, 32 },
"Rename" "Rename"
}; };
Button button_delete { Button button_delete {
{ 21 * 8, 29 * 8, 9 * 8, 32 }, { 16 * 8, 29 * 8, 14 * 8, 32 },
"Delete" "Delete"
}; };

View File

@ -154,7 +154,7 @@ struct path {
path& operator/=(const path& p) { path& operator/=(const path& p) {
if (_s.back() != preferred_separator) if (_s.back() != preferred_separator)
_s + preferred_separator; _s += preferred_separator;
_s += p._s; _s += p._s;
return *this; return *this;
} }