diff --git a/CHANGELOG.md b/CHANGELOG.md index dc1d06c..6f7c5b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ Released on FIXME: - Find feature: - A "wait popup" will now be displayed while searching files - If find command doesn't return any result show an info dialog and not an empty explorer + - It is now possible to keep navigating on the other explorer while "found tab" is open + - ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files) ## 0.7.0 diff --git a/src/ui/activities/filetransfer/lib/browser.rs b/src/ui/activities/filetransfer/lib/browser.rs index 501ab92..92413ad 100644 --- a/src/ui/activities/filetransfer/lib/browser.rs +++ b/src/ui/activities/filetransfer/lib/browser.rs @@ -40,14 +40,23 @@ pub enum FileExplorerTab { FindRemote, // Find result tab } +/// ## FoundExplorerTab +/// +/// Describes the explorer tab type +#[derive(Copy, Clone, Debug)] +pub enum FoundExplorerTab { + Local, + Remote, +} + /// ## Browser /// /// Browser contains the browser options pub struct Browser { - local: FileExplorer, // Local File explorer state - remote: FileExplorer, // Remote File explorer state - found: Option, // File explorer for find result - tab: FileExplorerTab, // Current selected tab + local: FileExplorer, // Local File explorer state + remote: FileExplorer, // Remote File explorer state + found: Option<(FoundExplorerTab, FileExplorer)>, // File explorer for find result + tab: FileExplorerTab, // Current selected tab pub sync_browsing: bool, } @@ -82,23 +91,30 @@ impl Browser { } pub fn found(&self) -> Option<&FileExplorer> { - self.found.as_ref() + self.found.as_ref().map(|x| &x.1) } pub fn found_mut(&mut self) -> Option<&mut FileExplorer> { - self.found.as_mut() + self.found.as_mut().map(|x| &mut x.1) } - pub fn set_found(&mut self, files: Vec) { + pub fn set_found(&mut self, tab: FoundExplorerTab, files: Vec) { let mut explorer = Self::build_found_explorer(); explorer.set_files(files); - self.found = Some(explorer); + self.found = Some((tab, explorer)); } pub fn del_found(&mut self) { self.found = None; } + /// ### found_tab + /// + /// Returns found tab if any + pub fn found_tab(&self) -> Option { + self.found.as_ref().map(|x| x.0) + } + pub fn tab(&self) -> FileExplorerTab { self.tab } diff --git a/src/ui/activities/filetransfer/update.rs b/src/ui/activities/filetransfer/update.rs index c34e274..2a035b5 100644 --- a/src/ui/activities/filetransfer/update.rs +++ b/src/ui/activities/filetransfer/update.rs @@ -27,15 +27,17 @@ */ // locals use super::{ - actions::SelectedEntry, browser::FileExplorerTab, FileTransferActivity, LogLevel, TransferOpts, - COMPONENT_EXPLORER_FIND, COMPONENT_EXPLORER_LOCAL, COMPONENT_EXPLORER_REMOTE, - COMPONENT_INPUT_COPY, COMPONENT_INPUT_EXEC, COMPONENT_INPUT_FIND, COMPONENT_INPUT_GOTO, - COMPONENT_INPUT_MKDIR, COMPONENT_INPUT_NEWFILE, COMPONENT_INPUT_OPEN_WITH, - COMPONENT_INPUT_RENAME, COMPONENT_INPUT_SAVEAS, COMPONENT_LIST_FILEINFO, - COMPONENT_LIST_REPLACING_FILES, COMPONENT_LOG_BOX, COMPONENT_PROGRESS_BAR_FULL, - COMPONENT_PROGRESS_BAR_PARTIAL, COMPONENT_RADIO_DELETE, COMPONENT_RADIO_DISCONNECT, - COMPONENT_RADIO_QUIT, COMPONENT_RADIO_REPLACE, COMPONENT_RADIO_SORTING, COMPONENT_TEXT_ERROR, - COMPONENT_TEXT_FATAL, COMPONENT_TEXT_HELP, + actions::SelectedEntry, + browser::{FileExplorerTab, FoundExplorerTab}, + FileTransferActivity, LogLevel, TransferOpts, COMPONENT_EXPLORER_FIND, + COMPONENT_EXPLORER_LOCAL, COMPONENT_EXPLORER_REMOTE, COMPONENT_INPUT_COPY, + COMPONENT_INPUT_EXEC, COMPONENT_INPUT_FIND, COMPONENT_INPUT_GOTO, COMPONENT_INPUT_MKDIR, + COMPONENT_INPUT_NEWFILE, COMPONENT_INPUT_OPEN_WITH, COMPONENT_INPUT_RENAME, + COMPONENT_INPUT_SAVEAS, COMPONENT_LIST_FILEINFO, COMPONENT_LIST_REPLACING_FILES, + COMPONENT_LOG_BOX, COMPONENT_PROGRESS_BAR_FULL, COMPONENT_PROGRESS_BAR_PARTIAL, + COMPONENT_RADIO_DELETE, COMPONENT_RADIO_DISCONNECT, COMPONENT_RADIO_QUIT, + COMPONENT_RADIO_REPLACE, COMPONENT_RADIO_SORTING, COMPONENT_TEXT_ERROR, COMPONENT_TEXT_FATAL, + COMPONENT_TEXT_HELP, }; use crate::fs::explorer::FileSorting; use crate::fs::FsEntry; @@ -64,6 +66,15 @@ impl Update for FileTransferActivity { None => None, // Exit after None Some(msg) => match msg { // -- local tab + (COMPONENT_EXPLORER_LOCAL, key) + if key == &MSG_KEY_RIGHT + && matches!(self.browser.found_tab(), Some(FoundExplorerTab::Remote)) => + { + // Go to find explorer + self.view.active(COMPONENT_EXPLORER_FIND); + self.browser.change_tab(FileExplorerTab::FindRemote); + None + } (COMPONENT_EXPLORER_LOCAL, key) if key == &MSG_KEY_RIGHT => { // Change tab self.view.active(COMPONENT_EXPLORER_REMOTE); @@ -137,6 +148,15 @@ impl Update for FileTransferActivity { self.update_local_filelist() } // -- remote tab + (COMPONENT_EXPLORER_REMOTE, key) + if key == &MSG_KEY_LEFT + && matches!(self.browser.found_tab(), Some(FoundExplorerTab::Local)) => + { + // Go to find explorer + self.view.active(COMPONENT_EXPLORER_FIND); + self.browser.change_tab(FileExplorerTab::FindLocal); + None + } (COMPONENT_EXPLORER_REMOTE, key) if key == &MSG_KEY_LEFT => { // Change tab self.view.active(COMPONENT_EXPLORER_LOCAL); @@ -336,6 +356,24 @@ impl Update for FileTransferActivity { None } // -- find result explorer + (COMPONENT_EXPLORER_FIND, key) + if key == &MSG_KEY_RIGHT + && matches!(self.browser.tab(), FileExplorerTab::FindLocal) => + { + // Active remote explorer + self.view.active(COMPONENT_EXPLORER_REMOTE); + self.browser.change_tab(FileExplorerTab::Remote); + None + } + (COMPONENT_EXPLORER_FIND, key) + if key == &MSG_KEY_LEFT + && matches!(self.browser.tab(), FileExplorerTab::FindRemote) => + { + // Active local explorer + self.view.active(COMPONENT_EXPLORER_LOCAL); + self.browser.change_tab(FileExplorerTab::Local); + None + } (COMPONENT_EXPLORER_FIND, key) if key == &MSG_KEY_ESC => { // Umount find self.umount_find(); @@ -457,7 +495,13 @@ impl Update for FileTransferActivity { } Ok(files) => { // Create explorer and load files - self.browser.set_found(files); + self.browser.set_found( + match self.browser.tab() { + FileExplorerTab::Local => FoundExplorerTab::Local, + _ => FoundExplorerTab::Remote, + }, + files, + ); // Mount result widget self.mount_find(input); self.update_find_list(); diff --git a/src/ui/activities/filetransfer/view.rs b/src/ui/activities/filetransfer/view.rs index f6ab723..5cf74ad 100644 --- a/src/ui/activities/filetransfer/view.rs +++ b/src/ui/activities/filetransfer/view.rs @@ -26,7 +26,10 @@ * SOFTWARE. */ // locals -use super::{browser::FileExplorerTab, Context, FileTransferActivity}; +use super::{ + browser::{FileExplorerTab, FoundExplorerTab}, + Context, FileTransferActivity, +}; use crate::fs::explorer::FileSorting; use crate::fs::FsEntry; use crate::ui::components::{ @@ -165,24 +168,20 @@ impl FileTransferActivity { } // Draw explorers // @! Local explorer (Find or default) - match self.browser.tab() { - FileExplorerTab::FindLocal => { - self.view - .render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[0]) - } - _ => self - .view - .render(super::COMPONENT_EXPLORER_LOCAL, f, tabs_chunks[0]), + if matches!(self.browser.found_tab(), Some(FoundExplorerTab::Local)) { + self.view + .render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[0]); + } else { + self.view + .render(super::COMPONENT_EXPLORER_LOCAL, f, tabs_chunks[0]); } // @! Remote explorer (Find or default) - match self.browser.tab() { - FileExplorerTab::FindRemote => { - self.view - .render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[1]) - } - _ => self - .view - .render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]), + if matches!(self.browser.found_tab(), Some(FoundExplorerTab::Remote)) { + self.view + .render(super::COMPONENT_EXPLORER_FIND, f, tabs_chunks[1]); + } else { + self.view + .render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]); } // Draw log box self.view