Compare commits

..

2 Commits

Author SHA1 Message Date
e0201ccb50
Some other formatting changes
Some checks failed
Continuous integration / Clippy (push) Failing after 42s
Continuous integration / build (push) Successful in 54s
2024-10-11 02:43:36 +03:00
7edb257e2f
Fixed clippy errors 2024-10-11 02:33:05 +03:00
9 changed files with 32 additions and 38 deletions

View File

@ -19,15 +19,6 @@ jobs:
# - uses: actions-rust-lang/setup-rust-toolchain@v1
# - run: cargo test
#fmt:
# name: Rustfmt
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions-rust-lang/setup-rust-toolchain@v1
# - run: rustup component add rustfmt
# - run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest

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

@ -53,7 +53,7 @@ impl Gui {
pub fn throw_error<S: ToString>(&mut self, text: S) {
let w = self.windows.get_window::<windows::error::GuiError>(WindowIndex::Error);
w.set_error_message(&text);
w.set_error_message(text);
self.windows.open(WindowIndex::Error, true);
}
}

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

@ -27,7 +27,7 @@ impl Window for GuiError {
}
impl GuiError {
pub fn set_error_message<S: ToString>(&mut self, text: &S) {
pub fn set_error_message<S: ToString>(&mut self, text: S) {
self.text = text.to_string();
}
}

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 {