Merge branch '0.5.1' into 0.6.0

This commit is contained in:
veeso
2021-06-21 18:22:19 +02:00
55 changed files with 2384 additions and 1639 deletions

View File

@@ -28,7 +28,7 @@
// Deps
extern crate bytesize;
extern crate hostname;
#[cfg(any(target_os = "unix", target_os = "macos", target_os = "linux"))]
#[cfg(any(target_family = "unix", target_os = "macos", target_os = "linux"))]
extern crate users;
// locals
use super::{browser::FileExplorerTab, Context, FileTransferActivity};
@@ -49,6 +49,7 @@ use tuirealm::components::{
input::{Input, InputPropsBuilder},
progress_bar::{ProgressBar, ProgressBarPropsBuilder},
radio::{Radio, RadioPropsBuilder},
scrolltable::{ScrollTablePropsBuilder, Scrolltable},
span::{Span, SpanPropsBuilder},
table::{Table, TablePropsBuilder},
};
@@ -58,7 +59,7 @@ use tuirealm::tui::{
style::Color,
widgets::{BorderType, Borders, Clear},
};
#[cfg(any(target_os = "unix", target_os = "macos", target_os = "linux"))]
#[cfg(any(target_family = "unix", target_os = "macos", target_os = "linux"))]
use users::{get_group_by_gid, get_user_by_uid};
impl FileTransferActivity {
@@ -99,13 +100,18 @@ impl FileTransferActivity {
.build(),
)),
);
// Mount status bar
// Mount status bars
self.view.mount(
super::COMPONENT_SPAN_STATUS_BAR,
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
Box::new(Span::new(SpanPropsBuilder::default().build())),
);
self.view.mount(
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
Box::new(Span::new(SpanPropsBuilder::default().build())),
);
// Load process bar
self.refresh_status_bar();
self.refresh_local_status_bar();
self.refresh_remote_status_bar();
// Update components
let _ = self.update_local_filelist();
let _ = self.update_remote_filelist();
@@ -144,6 +150,12 @@ impl FileTransferActivity {
.constraints([Constraint::Length(1), Constraint::Length(10)].as_ref())
.direction(Direction::Vertical)
.split(chunks[1]);
// Create status bar chunks
let status_bar_chunks = Layout::default()
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
.direction(Direction::Horizontal)
.horizontal_margin(1)
.split(bottom_chunks[0]);
// If width is unset in the storage, set width
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
@@ -169,11 +181,20 @@ impl FileTransferActivity {
.view
.render(super::COMPONENT_EXPLORER_REMOTE, f, tabs_chunks[1]),
}
// Draw log box and status bar
// Draw log box
self.view
.render(super::COMPONENT_LOG_BOX, f, bottom_chunks[1]);
self.view
.render(super::COMPONENT_SPAN_STATUS_BAR, f, bottom_chunks[0]);
// Draw status bar
self.view.render(
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
f,
status_bar_chunks[0],
);
self.view.render(
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
f,
status_bar_chunks[1],
);
// @! Draw popups
if let Some(props) = self.view.get_props(super::COMPONENT_INPUT_COPY) {
if props.visible {
@@ -817,7 +838,7 @@ impl FileTransferActivity {
.build(),
);
// User
#[cfg(any(target_os = "unix", target_os = "macos", target_os = "linux"))]
#[cfg(any(target_family = "unix", target_os = "macos", target_os = "linux"))]
let username: String = match file.get_user() {
Some(uid) => match get_user_by_uid(uid) {
Some(user) => user.name().to_string_lossy().to_string(),
@@ -828,7 +849,7 @@ impl FileTransferActivity {
#[cfg(target_os = "windows")]
let username: String = format!("{}", file.get_user().unwrap_or(0));
// Group
#[cfg(any(target_os = "unix", target_os = "macos", target_os = "linux"))]
#[cfg(any(target_family = "unix", target_os = "macos", target_os = "linux"))]
let group: String = match file.get_group() {
Some(gid) => match get_group_by_gid(gid) {
Some(group) => group.name().to_string_lossy().to_string(),
@@ -864,9 +885,54 @@ impl FileTransferActivity {
self.view.umount(super::COMPONENT_LIST_FILEINFO);
}
pub(super) fn refresh_status_bar(&mut self) {
let bar_spans: Vec<TextSpan> = vec![
TextSpanBuilder::new("Synchronized Browsing: ")
pub(super) fn refresh_local_status_bar(&mut self) {
let local_bar_spans: Vec<TextSpan> = vec![
TextSpanBuilder::new("File sorting: ")
.with_foreground(Color::LightYellow)
.build(),
TextSpanBuilder::new(Self::get_file_sorting_str(self.local().get_file_sorting()))
.with_foreground(Color::LightYellow)
.reversed()
.build(),
TextSpanBuilder::new(" Hidden files: ")
.with_foreground(Color::LightBlue)
.build(),
TextSpanBuilder::new(Self::get_hidden_files_str(
self.local().hidden_files_visible(),
))
.with_foreground(Color::LightBlue)
.reversed()
.build(),
];
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR_LOCAL) {
self.view.update(
super::COMPONENT_SPAN_STATUS_BAR_LOCAL,
SpanPropsBuilder::from(props)
.with_spans(local_bar_spans)
.build(),
);
}
}
pub(super) fn refresh_remote_status_bar(&mut self) {
let remote_bar_spans: Vec<TextSpan> = vec![
TextSpanBuilder::new("File sorting: ")
.with_foreground(Color::LightYellow)
.build(),
TextSpanBuilder::new(Self::get_file_sorting_str(self.remote().get_file_sorting()))
.with_foreground(Color::LightYellow)
.reversed()
.build(),
TextSpanBuilder::new(" Hidden files: ")
.with_foreground(Color::LightBlue)
.build(),
TextSpanBuilder::new(Self::get_hidden_files_str(
self.remote().hidden_files_visible(),
))
.with_foreground(Color::LightBlue)
.reversed()
.build(),
TextSpanBuilder::new(" Sync Browsing: ")
.with_foreground(Color::LightGreen)
.build(),
TextSpanBuilder::new(match self.browser.sync_browsing {
@@ -876,25 +942,13 @@ impl FileTransferActivity {
.with_foreground(Color::LightGreen)
.reversed()
.build(),
TextSpanBuilder::new(" Localhost file sorting: ")
.with_foreground(Color::LightYellow)
.build(),
TextSpanBuilder::new(Self::get_file_sorting_str(self.local().get_file_sorting()))
.with_foreground(Color::LightYellow)
.reversed()
.build(),
TextSpanBuilder::new(" Remote host file sorting: ")
.with_foreground(Color::LightBlue)
.build(),
TextSpanBuilder::new(Self::get_file_sorting_str(self.remote().get_file_sorting()))
.with_foreground(Color::LightBlue)
.reversed()
.build(),
];
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR) {
if let Some(props) = self.view.get_props(super::COMPONENT_SPAN_STATUS_BAR_REMOTE) {
self.view.update(
super::COMPONENT_SPAN_STATUS_BAR,
SpanPropsBuilder::from(props).with_spans(bar_spans).build(),
super::COMPONENT_SPAN_STATUS_BAR_REMOTE,
SpanPropsBuilder::from(props)
.with_spans(remote_bar_spans)
.build(),
);
}
}
@@ -905,9 +959,12 @@ impl FileTransferActivity {
pub(super) fn mount_help(&mut self) {
self.view.mount(
super::COMPONENT_TEXT_HELP,
Box::new(Table::new(
TablePropsBuilder::default()
Box::new(Scrolltable::new(
ScrollTablePropsBuilder::default()
.with_borders(Borders::ALL, BorderType::Rounded, Color::White)
.with_highlighted_str(Some("?"))
.with_max_scroll_step(8)
.bold()
.with_table(
Some(String::from("Help")),
TableBuilder::default()
@@ -1171,4 +1228,11 @@ impl FileTransferActivity {
FileSorting::BySize => "By size",
}
}
fn get_hidden_files_str(show: bool) -> &'static str {
match show {
true => "Show",
false => "Hide",
}
}
}