set title for "similar tracks" view

This commit is contained in:
Henrik Friedrichsen
2021-01-02 21:46:09 +01:00
parent 3874dc42f8
commit 919a245649
2 changed files with 16 additions and 0 deletions

View File

@@ -263,6 +263,11 @@ impl ListItem for Track {
queue.clone(),
library.clone(),
)
.set_title(format!(
"Similar to \"{} - {}\"",
self.artists.join(", "),
self.title
))
.as_boxed_view_ext()
})
}

View File

@@ -106,6 +106,7 @@ pub struct ListView<I: ListItem> {
queue: Arc<Queue>,
library: Arc<Library>,
pagination: Pagination<I>,
title: String,
}
impl<I: ListItem> ListView<I> {
@@ -122,9 +123,15 @@ impl<I: ListItem> ListView<I> {
queue,
library,
pagination: Pagination::default(),
title: "".to_string(),
}
}
pub fn set_title(mut self, title: String) -> Self {
self.title = title;
self
}
pub fn get_pagination(&self) -> &Pagination<I> {
&self.pagination
}
@@ -433,6 +440,10 @@ impl<I: ListItem> View for ListView<I> {
}
impl<I: ListItem + Clone> ViewExt for ListView<I> {
fn title(&self) -> String {
self.title.clone()
}
fn on_command(&mut self, _s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
match cmd {
Command::Play => {