Fixed clippy errors

This commit is contained in:
Gvidas Juknevičius 2024-10-11 02:33:05 +03:00
parent dfc55837ee
commit 7edb257e2f
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
6 changed files with 30 additions and 27 deletions

View File

@ -168,10 +168,6 @@ impl Downloader {
]);
cmd
}
url => {
log::error!("Unknown or unsupported hostname '{:?}'", url);
return Ok(());
}
};
if log::max_level() < Level::Debug {

View File

@ -1,4 +1,4 @@
use egui::{Color32, RichText, TextBuffer};
use egui::{Color32, RichText};
use crate::ui::gui::{components::ComponentContextMenu, windows::{self, WindowIndex}};
@ -15,14 +15,14 @@ impl ComponentContextMenu for ContextMenu {
if ui.button("Download all").clicked() {
let Some(playlist) = gui.manifest.get_playlist(playlist_name) else {
gui.throw_error(&format!("Playlist not found: {}", playlist_name));
gui.throw_error(format!("Playlist not found: {}", playlist_name));
ui.close_menu();
return;
};
for (song_name, song) in playlist.get_songs() {
if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, &playlist_name, song_name, song, gui.manifest.get_format()) {
gui.throw_error(&format!("Could not download song: {e}"));
if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, playlist_name, song_name, song, gui.manifest.get_format()) {
gui.throw_error(format!("Could not download song: {e}"));
ui.close_menu();
return;
}
@ -41,7 +41,11 @@ impl ComponentContextMenu for ContextMenu {
}
if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() {
let w = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm);
w.set_message(&"side_nav_playlist_manifest_delete", &"This will delete the playlist from the manifest file. This is NOT reversible", &vec![playlist_name.clone()]);
w.set_message(
&"side_nav_playlist_manifest_delete",
&"This will delete the playlist from the manifest file. This is NOT reversible",
&[playlist_name.clone()]
);
gui.windows.open(WindowIndex::Confirm, true);
ui.close_menu();
}

View File

@ -28,12 +28,11 @@ impl ComponentUi for SideNav {
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &pname));
ui.horizontal(|ui| {
let text;
if gui.current_playlist == *pname {
text = RichText::new(&pname).color(tint);
let text = if gui.current_playlist == *pname {
RichText::new(&pname).color(tint)
} else {
text = RichText::new(&pname);
}
RichText::new(&pname)
};
let button = Label::new(text).sense(Sense::click()).selectable(false);
let button = ui.add(button);

View File

@ -12,10 +12,10 @@ pub struct SongInfo {
}
impl SongInfo {
pub fn new(pname: &String, sname: &String, song: &Song) -> Self {
pub fn new(pname: &str, sname: &str, song: &Song) -> Self {
Self {
pname: pname.clone(),
sname: sname.clone(),
pname: pname.to_string(),
sname: sname.to_string(),
song: song.clone()
}
}
@ -83,7 +83,11 @@ impl ComponentContextMenu for ContextMenu {
}
if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() {
let w = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm);
w.set_message(&"song_list_song_manifest_delete", &"This will delete the song from the manifest file. This is NOT reversible", &vec![data.playlist_name().clone(), data.song_name().clone()]);
w.set_message(
&"song_list_song_manifest_delete",
&"This will delete the song from the manifest file. This is NOT reversible",
&[data.playlist_name().clone(), data.song_name().clone()]
);
gui.windows.open(WindowIndex::Confirm, true);
ui.close_menu();
ui.close_menu();

View File

@ -1,4 +1,4 @@
use egui::{Color32, Label, RichText, TextBuffer};
use egui::{Color32, Label, RichText};
use super::{State, Window};
@ -41,10 +41,10 @@ impl Window for ConfirmW {
}
impl ConfirmW {
pub fn set_message<S: ToString>(&mut self, new_id: &S, text: &S, data: &Vec<String>) {
pub fn set_message<S: ToString>(&mut self, new_id: &S, text: &S, data: &[String]) {
self.text = text.to_string();
self.id = new_id.to_string();
self.data = data.clone();
self.data = data.to_vec();
}
pub fn get_response(&self) -> (&String, &Option<bool>, &Vec<String>) {
(&self.id, &self.response, &self.data)

View File

@ -1,4 +1,4 @@
use crate::manifest::song::{Song, SongType};
use crate::manifest::song::SongType;
use super::{State, Window};
@ -9,8 +9,8 @@ pub struct GuiImportPlaylist {
ed_type: SongType,
ed_name: String,
ed_url: String,
urls_to_add: Vec<String>,
playlist_name: String,
//urls_to_add: Vec<String>,
// playlist_name: String,
}
@ -46,8 +46,8 @@ impl Window for GuiImportPlaylist {
}
});
if let Some(url) = self.urls_to_add.pop() {
todo!();
//if let Some(_) = self.urls_to_add.pop() {
// todo!();
//let client = reqwest::blocking::Client::new();
// let song_name = crate::crawler::spotify::get_song_name(&client, url.clone())?;
@ -57,7 +57,7 @@ impl Window for GuiImportPlaylist {
// playlist.add_song(song_name, song);
//}
//let _ = state.manifest.save(None);
}
//}
if save {