added keybind to remove highlighted song from queue
This commit is contained in:
parent
255687be7c
commit
ad2e99ce76
24
src/app.rs
24
src/app.rs
|
|
@ -113,6 +113,30 @@ impl App {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_from_current_playlist(&mut self) {
|
||||||
|
let mut file = String::new();
|
||||||
|
match self.selected_tab {
|
||||||
|
SelectedTab::DirectoryBrowser => {
|
||||||
|
let (_, f) = self.browser.filetree.get(self.browser.selected).unwrap();
|
||||||
|
file.push_str(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedTab::Queue => {
|
||||||
|
file = self.queue_list.list.get(self.queue_list.index).unwrap().to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i, song) in self.queue_list.list.clone().iter().enumerate() {
|
||||||
|
if song.contains(&file) {
|
||||||
|
self.conn.conn.delete(i as u32).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.update_queue();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cycle_tabls(&mut self) {
|
pub fn cycle_tabls(&mut self) {
|
||||||
self.selected_tab = match self.selected_tab {
|
self.selected_tab = match self.selected_tab {
|
||||||
SelectedTab::DirectoryBrowser => SelectedTab::Queue,
|
SelectedTab::DirectoryBrowser => SelectedTab::Queue,
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,11 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
||||||
app.inputmode = InputMode::toggle_editing_states(&app.inputmode);
|
app.inputmode = InputMode::toggle_editing_states(&app.inputmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove from Current Playlsit
|
||||||
|
KeyCode::Backspace => {
|
||||||
|
app.remove_from_current_playlist();
|
||||||
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue