Compare commits

..

No commits in common. "e0201ccb50313ad6dd5b8c52409bdfad84d7a253" and "dfc55837ee627f8130ff6b75b07dcee32a395f78" have entirely different histories.

9 changed files with 38 additions and 32 deletions

View File

@ -19,6 +19,15 @@ 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,6 +168,10 @@ 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};
use egui::{Color32, RichText, TextBuffer};
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,11 +41,7 @@ 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",
&[playlist_name.clone()]
);
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()]);
gui.windows.open(WindowIndex::Confirm, true);
ui.close_menu();
}

View File

@ -28,11 +28,12 @@ impl ComponentUi for SideNav {
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &pname));
ui.horizontal(|ui| {
let text = if gui.current_playlist == *pname {
RichText::new(&pname).color(tint)
let text;
if gui.current_playlist == *pname {
text = RichText::new(&pname).color(tint);
} else {
RichText::new(&pname)
};
text = 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: &str, sname: &str, song: &Song) -> Self {
pub fn new(pname: &String, sname: &String, song: &Song) -> Self {
Self {
pname: pname.to_string(),
sname: sname.to_string(),
pname: pname.clone(),
sname: sname.clone(),
song: song.clone()
}
}
@ -83,11 +83,7 @@ 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",
&[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", &vec![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};
use egui::{Color32, Label, RichText, TextBuffer};
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: &[String]) {
pub fn set_message<S: ToString>(&mut self, new_id: &S, text: &S, data: &Vec<String>) {
self.text = text.to_string();
self.id = new_id.to_string();
self.data = data.to_vec();
self.data = data.clone();
}
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::SongType;
use crate::manifest::song::{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(_) = self.urls_to_add.pop() {
// todo!();
if let Some(url) = 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 {