From b1c8417b0fec1d13dc9eda97e2074b7d1ec2a082 Mon Sep 17 00:00:00 2001 From: MCorange Date: Wed, 20 Nov 2024 20:00:24 +0200 Subject: [PATCH] Things idk --- DEV.md | 6 ++- assets/burger_menu.svg | 1 + assets/plus.svg | 39 +++++++++++++++++++ xmpd-cache/src/downloader/song.rs | 11 +++++- .../src/components/song_list/song_list_nav.rs | 14 ++++++- xmpd-gui/src/data.rs | 2 + xmpd-manifest/src/song.rs | 29 ++++++++------ 7 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 assets/burger_menu.svg create mode 100644 assets/plus.svg diff --git a/DEV.md b/DEV.md index 0476442..00ca25f 100644 --- a/DEV.md +++ b/DEV.md @@ -1 +1,5 @@ -listen along feature using ws and or p2p, downloading music when connectedd if you dont have it, matched by either the url, or a global id set by server +[ ] listen along feature using ws and or p2p, downloading music when connectedd if you dont have it, matched by either the url, or a global id set by server +[ ] Internationalisation +[ ] Music Player +[ ] Playlist exporting to folder, zip, tar balls, etc + diff --git a/assets/burger_menu.svg b/assets/burger_menu.svg new file mode 100644 index 0000000..4dce6a1 --- /dev/null +++ b/assets/burger_menu.svg @@ -0,0 +1 @@ + diff --git a/assets/plus.svg b/assets/plus.svg new file mode 100644 index 0000000..84453ce --- /dev/null +++ b/assets/plus.svg @@ -0,0 +1,39 @@ + + + + + + diff --git a/xmpd-cache/src/downloader/song.rs b/xmpd-cache/src/downloader/song.rs index dba01d0..d2b5627 100644 --- a/xmpd-cache/src/downloader/song.rs +++ b/xmpd-cache/src/downloader/song.rs @@ -120,7 +120,16 @@ impl SongCacheDl { cache.jobs.insert(sid, SongStatus::Done); cache.current_jobs -= 1; }); - } + } + SourceType::HttpBare => { + todo!() + } + SourceType::Http7z => { + todo!() + } + SourceType::HttpZip => { + todo!() + } } Ok(()) } diff --git a/xmpd-gui/src/components/song_list/song_list_nav.rs b/xmpd-gui/src/components/song_list/song_list_nav.rs index 362436d..0224ed7 100644 --- a/xmpd-gui/src/components/song_list/song_list_nav.rs +++ b/xmpd-gui/src/components/song_list/song_list_nav.rs @@ -32,13 +32,19 @@ impl CompUi for SongListNav { } ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| { - let img = ui.add( + let download_all = ui.add( egui::Image::new(crate::data::DL_ICON) .tint(theme.accent_color) .sense(egui::Sense::click()) .fit_to_exact_size(egui::Vec2::new(16.0, 16.0)) ); - if img.clicked() { + let add_song = ui.add( + egui::Image::new(crate::data::PLUS_ICON) + .tint(theme.accent_color) + .sense(egui::Sense::click()) + .fit_to_exact_size(egui::Vec2::new(16.0, 16.0)) + ); + if download_all.clicked() { let songs: Vec<_>; match pid { Some(pid) => { @@ -60,6 +66,10 @@ impl CompUi for SongListNav { ToastType::Info ); } + + if add_song.clicked() { + todo!() + } }); }); Ok(()) diff --git a/xmpd-gui/src/data.rs b/xmpd-gui/src/data.rs index 491d85b..92917ac 100644 --- a/xmpd-gui/src/data.rs +++ b/xmpd-gui/src/data.rs @@ -11,6 +11,8 @@ pub const DL_ICON: egui::ImageSource = egui::include_image!("../../assets/downl pub const INFO_ICON: egui::ImageSource = egui::include_image!("../../assets/info.svg"); pub const WARN_ICON: egui::ImageSource = egui::include_image!("../../assets/warning.svg"); pub const ERROR_ICON: egui::ImageSource = egui::include_image!("../../assets/error.svg"); +pub const PLUS_ICON: egui::ImageSource = egui::include_image!("../../assets/plus.svg"); +pub const BURGER_ICON: egui::ImageSource = egui::include_image!("../../assets/burger_menu.svg"); pub const C_WARN: egui::Color32 = egui::Color32::from_rgb(255, 183, 0); // #ffb700 diff --git a/xmpd-manifest/src/song.rs b/xmpd-manifest/src/song.rs index 2564bfc..b5986cc 100644 --- a/xmpd-manifest/src/song.rs +++ b/xmpd-manifest/src/song.rs @@ -1,4 +1,4 @@ -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; @@ -11,16 +11,16 @@ pub struct Song { } impl Song { - pub fn new(url: &url::Url) -> crate::Result { + pub fn new(url: &url::Url, source_type: SourceType) -> crate::Result { Ok(Self { name: String::default(), author: String::default(), - source_type: SourceType::from_url(url)?, + source_type, url: url.clone() }) } - pub fn new_from_str(url: &str) -> crate::Result { - Self::new(&url::Url::from_str(url)?) + pub fn new_from_str(url: &str, source_type: SourceType) -> crate::Result { + Self::new(&url::Url::from_str(url)?, source_type) } pub fn name(&self) -> &str { &self.name @@ -48,21 +48,26 @@ impl Song { } } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd)] +#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd)] pub enum SourceType { Youtube, Spotify, Soundcloud, + HttpBare, + HttpZip, + Http7z } impl SourceType { - fn from_url(url: &url::Url) -> crate::Result { + fn from_url(url: &url::Url) -> Option { match url.host_str() { - Some("youtube.com") | Some("youtu.be") => Ok(Self::Youtube), - Some("open.spotify.com") => Ok(Self::Spotify), - Some("soundcloud.com") |Some("on.soundcloud.com") => Ok(Self::Soundcloud), - Some(host) => anyhow::bail!("Unknown host {host:?}"), - None => anyhow::bail!("Unknown host: (none)"), + Some("youtube.com") | Some("youtu.be") => + Some(Self::Youtube), + Some("open.spotify.com") => + Some(Self::Spotify), + Some("soundcloud.com") | Some("on.soundcloud.com") => + Some(Self::Soundcloud), + _ => None } } }