Things idk

This commit is contained in:
Gvidas Juknevičius 2024-11-20 20:00:24 +02:00
parent 3d9c12959d
commit b1c8417b0f
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
7 changed files with 86 additions and 16 deletions

6
DEV.md
View File

@ -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

1
assets/burger_menu.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#FFFFFF"><path shape-rendering="crispEdges" d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>

After

Width:  |  Height:  |  Size: 223 B

39
assets/plus.svg Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="#FFFFFF"
version="1.1"
id="svg1"
sodipodi:docname="plus.svg"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#000000"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="45.254834"
inkscape:cx="7.4025241"
inkscape:cy="12.396466"
inkscape:window-width="1898"
inkscape:window-height="1037"
inkscape:window-x="10"
inkscape:window-y="10"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<path
shape-rendering="crispEdges"
d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -120,7 +120,16 @@ impl SongCacheDl {
cache.jobs.insert(sid, SongStatus::Done); cache.jobs.insert(sid, SongStatus::Done);
cache.current_jobs -= 1; cache.current_jobs -= 1;
}); });
} }
SourceType::HttpBare => {
todo!()
}
SourceType::Http7z => {
todo!()
}
SourceType::HttpZip => {
todo!()
}
} }
Ok(()) Ok(())
} }

View File

@ -32,13 +32,19 @@ impl CompUi for SongListNav {
} }
ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| { 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) egui::Image::new(crate::data::DL_ICON)
.tint(theme.accent_color) .tint(theme.accent_color)
.sense(egui::Sense::click()) .sense(egui::Sense::click())
.fit_to_exact_size(egui::Vec2::new(16.0, 16.0)) .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<_>; let songs: Vec<_>;
match pid { match pid {
Some(pid) => { Some(pid) => {
@ -60,6 +66,10 @@ impl CompUi for SongListNav {
ToastType::Info ToastType::Info
); );
} }
if add_song.clicked() {
todo!()
}
}); });
}); });
Ok(()) Ok(())

View File

@ -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 INFO_ICON: egui::ImageSource = egui::include_image!("../../assets/info.svg");
pub const WARN_ICON: egui::ImageSource = egui::include_image!("../../assets/warning.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 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 pub const C_WARN: egui::Color32 = egui::Color32::from_rgb(255, 183, 0); // #ffb700

View File

@ -1,4 +1,4 @@
use std::str::FromStr; use std::{path::PathBuf, str::FromStr};
@ -11,16 +11,16 @@ pub struct Song {
} }
impl Song { impl Song {
pub fn new(url: &url::Url) -> crate::Result<Self> { pub fn new(url: &url::Url, source_type: SourceType) -> crate::Result<Self> {
Ok(Self { Ok(Self {
name: String::default(), name: String::default(),
author: String::default(), author: String::default(),
source_type: SourceType::from_url(url)?, source_type,
url: url.clone() url: url.clone()
}) })
} }
pub fn new_from_str(url: &str) -> crate::Result<Self> { pub fn new_from_str(url: &str, source_type: SourceType) -> crate::Result<Self> {
Self::new(&url::Url::from_str(url)?) Self::new(&url::Url::from_str(url)?, source_type)
} }
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
&self.name &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 { pub enum SourceType {
Youtube, Youtube,
Spotify, Spotify,
Soundcloud, Soundcloud,
HttpBare,
HttpZip,
Http7z
} }
impl SourceType { impl SourceType {
fn from_url(url: &url::Url) -> crate::Result<Self> { fn from_url(url: &url::Url) -> Option<Self> {
match url.host_str() { match url.host_str() {
Some("youtube.com") | Some("youtu.be") => Ok(Self::Youtube), Some("youtube.com") | Some("youtu.be") =>
Some("open.spotify.com") => Ok(Self::Spotify), Some(Self::Youtube),
Some("soundcloud.com") |Some("on.soundcloud.com") => Ok(Self::Soundcloud), Some("open.spotify.com") =>
Some(host) => anyhow::bail!("Unknown host {host:?}"), Some(Self::Spotify),
None => anyhow::bail!("Unknown host: (none)"), Some("soundcloud.com") | Some("on.soundcloud.com") =>
Some(Self::Soundcloud),
_ => None
} }
} }
} }