Skip to content

Commit

Permalink
add small status header
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski committed Jul 6, 2024
1 parent 13e2084 commit d52f986
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ free_space_refresh = 10
# Available fields:
# Id, Name, SizeWhenDone, Progress, DownloadRate, UploadRate, DownloadDir,
# Padding, UploadRatio, UploadedEver, AddedDate, ActivityDate, PeersConnected
# SmallStatus
headers = ["Name", "SizeWhenDone", "Progress", "DownloadRate", "UploadRate"]

```
Expand Down
1 change: 1 addition & 0 deletions rm-config/defaults/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ free_space_refresh = 10
# Available fields:
# Id, Name, SizeWhenDone, Progress, DownloadRate, UploadRate, DownloadDir,
# Padding, UploadRatio, UploadedEver, AddedDate, ActivityDate, PeersConnected
# SmallStatus
headers = ["Name", "SizeWhenDone", "Progress", "DownloadRate", "UploadRate"]
61 changes: 32 additions & 29 deletions rm-config/src/main_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,44 +68,47 @@ pub enum Header {
ActivityDate,
AddedDate,
PeersConnected,
SmallStatus,
}

impl Header {
pub fn default_constraint(&self) -> Constraint {
match self {
Header::Name => Constraint::Max(70),
Header::SizeWhenDone => Constraint::Length(12),
Header::Progress => Constraint::Length(12),
Header::Eta => Constraint::Length(12),
Header::DownloadRate => Constraint::Length(12),
Header::UploadRate => Constraint::Length(12),
Header::DownloadDir => Constraint::Max(70),
Header::Padding => Constraint::Length(2),
Header::UploadRatio => Constraint::Length(6),
Header::UploadedEver => Constraint::Length(12),
Header::Id => Constraint::Length(4),
Header::ActivityDate => Constraint::Length(14),
Header::AddedDate => Constraint::Length(12),
Header::PeersConnected => Constraint::Length(6),
Self::Name => Constraint::Max(70),
Self::SizeWhenDone => Constraint::Length(12),
Self::Progress => Constraint::Length(12),
Self::Eta => Constraint::Length(12),
Self::DownloadRate => Constraint::Length(12),
Self::UploadRate => Constraint::Length(12),
Self::DownloadDir => Constraint::Max(70),
Self::Padding => Constraint::Length(2),
Self::UploadRatio => Constraint::Length(6),
Self::UploadedEver => Constraint::Length(12),
Self::Id => Constraint::Length(4),
Self::ActivityDate => Constraint::Length(14),
Self::AddedDate => Constraint::Length(12),
Self::PeersConnected => Constraint::Length(6),
Self::SmallStatus => Constraint::Length(1),
}
}

pub fn header_name(&self) -> &'static str {
match self {
Header::Name => "Name",
Header::SizeWhenDone => "Size",
Header::Progress => "Progress",
Header::Eta => "ETA",
Header::DownloadRate => "Download",
Header::UploadRate => "Upload",
Header::DownloadDir => "Directory",
Header::Padding => "",
Header::UploadRatio => "Ratio",
Header::UploadedEver => "Up Ever",
Header::Id => "Id",
Header::ActivityDate => "Last active",
Header::AddedDate => "Added",
Header::PeersConnected => "Peers",
match *self {
Self::Name => "Name",
Self::SizeWhenDone => "Size",
Self::Progress => "Progress",
Self::Eta => "ETA",
Self::DownloadRate => "Download",
Self::UploadRate => "Upload",
Self::DownloadDir => "Directory",
Self::Padding => "",
Self::UploadRatio => "Ratio",
Self::UploadedEver => "Up Ever",
Self::Id => "Id",
Self::ActivityDate => "Last active",
Self::AddedDate => "Added",
Self::PeersConnected => "Peers",
Self::SmallStatus => "",
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions rm-main/src/ui/tabs/torrents/rustmission_torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ impl RustmissionTorrent {
Header::ActivityDate => time_to_line(self.activity_date),
Header::AddedDate => time_to_line(self.added_date),
Header::PeersConnected => Line::from(self.peers_connected.to_string()),
Header::SmallStatus => match self.status() {
TorrentStatus::Stopped => Line::from("󰏤"),
TorrentStatus::QueuedToVerify => Line::from("󱥸"),
TorrentStatus::Verifying => Line::from("󰑓"),
TorrentStatus::QueuedToDownload => Line::from("󱥸"),
TorrentStatus::QueuedToSeed => Line::from("󱥸"),
TorrentStatus::Seeding => {
if !self.upload_speed.is_empty() {
Line::from("")
} else {
Line::from("󰄬")
}
}
TorrentStatus::Downloading => Line::from(""),
},
}
}

Expand Down

0 comments on commit d52f986

Please sign in to comment.