7 Commits
2.1.1 ... 2.1.3

Author SHA1 Message Date
7dcaa1436b [2.1.3] Unhardcode window title 2026-01-11 23:44:55 +02:00
c423993a93 myes, forgot to add this 2026-01-11 22:42:02 +02:00
bbffa5dbd3 [2.1.2] Better ui for searching
owo
2026-01-11 22:41:43 +02:00
d6b9d566d2 Save manifest when adding new song 2026-01-11 21:24:29 +02:00
2c2f35ff0a Fix mixed up placeholders for new song window input boxes 2026-01-11 21:18:04 +02:00
2aa0e5a1e8 Change behavour when tool is missing
Dont die when tool is missing
2026-01-11 21:17:36 +02:00
1b0af636df Update readme 2025-12-07 22:17:24 +02:00
11 changed files with 109 additions and 25 deletions

0
CHANGELOG.md Normal file
View File

18
Cargo.lock generated
View File

@@ -5756,7 +5756,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]] [[package]]
name = "xmpd-cache" name = "xmpd-cache"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@@ -5773,7 +5773,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-cliargs" name = "xmpd-cliargs"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"camino", "camino",
"clap", "clap",
@@ -5783,7 +5783,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-core" name = "xmpd-core"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@@ -5800,7 +5800,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-gui" name = "xmpd-gui"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@@ -5823,7 +5823,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-manifest" name = "xmpd-manifest"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"serde", "serde",
@@ -5837,7 +5837,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-player" name = "xmpd-player"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"lazy_static", "lazy_static",
@@ -5847,7 +5847,7 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-settings" name = "xmpd-settings"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@@ -5860,11 +5860,11 @@ dependencies = [
[[package]] [[package]]
name = "xmpd-tooling" name = "xmpd-tooling"
version = "2.1.1" version = "2.1.3"
[[package]] [[package]]
name = "xmpd-update" name = "xmpd-update"
version = "2.1.1" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"log", "log",

View File

@@ -13,7 +13,7 @@ members=[
] ]
[workspace.package] [workspace.package]
version="2.1.1" version="2.1.3"
edition="2024" edition="2024"
repository="https://git.mcorangehq.xyz/XOR64/xmpd/" repository="https://git.mcorangehq.xyz/XOR64/xmpd/"
license="GPL-3.0" license="GPL-3.0"

View File

@@ -1,5 +1,9 @@
# (XMPD) Xor64 Music Player/Downloader # (XMPD) Xor64 Music Player/Downloader
# **NOTE** This readme has outdated info, and needs to be updated
An open source music downloader AND player (soon (TM)) An open source music downloader AND player (soon (TM))
## Design ## Design

View File

@@ -55,7 +55,9 @@ impl Cache {
} }
} }
} }
anyhow::bail!("Tool {} was not found", tool_path) // anyhow::bail!("Tool {} was not found", tool_path)
log::error!("Tool {tool_path:?} doesnt exist!");
Ok(())
} }
pub fn init(&mut self) -> Result<Receiver<Message>> { pub fn init(&mut self) -> Result<Receiver<Message>> {
// Check for missing tooling // Check for missing tooling

View File

@@ -1,8 +1,10 @@
use eframe::Frame;
use egui::{Align, Align2, Area, Key, Layout, Order, Style};
use uuid::Uuid; use uuid::Uuid;
use xmpd_cache::DlStatus; use xmpd_cache::DlStatus;
use xmpd_manifest::{song::Song, store::BaseStore}; use xmpd_manifest::{song::Song, store::BaseStore};
use crate::{components::{left_nav::LeftNav, toast::ToastType, CompGetter, CompUi}, windows::WindowId}; use crate::{components::{CompGetter, CompUi, left_nav::LeftNav, toast::ToastType}, utils::SearchType, windows::WindowId};
use super::SongList; use super::SongList;
@@ -15,6 +17,8 @@ pub struct Header {
component_register!(Header); component_register!(Header);
impl CompUi for Header { impl CompUi for Header {
fn draw(ui: &mut egui::Ui, state: &mut crate::GuiState) -> crate::Result<()> { fn draw(ui: &mut egui::Ui, state: &mut crate::GuiState) -> crate::Result<()> {
let theme = xmpd_settings::Settings::get()?.theme.clone(); let theme = xmpd_settings::Settings::get()?.theme.clone();
@@ -26,7 +30,53 @@ impl CompUi for Header {
.tint(theme.accent_color); .tint(theme.accent_color);
ui.add(search_icon); ui.add(search_icon);
{ {
ui.text_edit_singleline(&mut handle_error_ui!(Header::get()).search_text); let resp = ui.text_edit_singleline(&mut handle_error_ui!(Header::get()).search_text);
let popup_id = resp.id.with("mode_popup");
if resp.clicked() {
ui.memory_mut(|m| m.open_popup(popup_id));
}
// NOTE: Genuinely cancerous code incoming
let search_text = handle_error_ui!(Header::get()).search_text.clone();
if !search_text.is_empty() {
if ui.memory(|mem: &egui::Memory| mem.is_popup_open(popup_id)) {
Area::new(popup_id)
.order(Order::Foreground)
.constrain(true)
.fixed_pos(resp.rect.left_bottom())
.pivot(Align2::LEFT_TOP)
.show(ui.ctx(), |ui| {
let tf = crate::main_window::get_themed_frame(&theme)
.stroke(egui::Stroke::new(
1.5,
theme.secondary_bg_color,
));
let frame_margin = tf.total_margin();
tf.show(ui, |ui| {
ui.with_layout(Layout::top_down_justified(Align::LEFT), |ui| {
ui.set_width(resp.rect.width() - frame_margin.sum().x);
let st = SearchType::from_str(&search_text);
let style = ui.style_mut();
style.visuals.selection.bg_fill = theme.secondary_bg_color;
style.visuals.selection.stroke.color = theme.accent_color;
for item in &[SearchType::Author, SearchType::Source, SearchType::Genre] {
if ui.selectable_label(st.0 == *item, item.new_query(&st.1)).clicked() {
{
handle_error_ui!(Header::get()).search_text = item.new_query(&st.1);
}
ui.memory_mut(|m| m.close_popup());
}
}
})
})
});
if ui.input(|i| i.key_pressed(Key::Escape)) || resp.clicked_elsewhere() {
ui.memory_mut(|mem| mem.close_popup());
}
}
}
} }
ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| { ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| {

View File

@@ -25,7 +25,7 @@ impl CompUi for SongList {
let mut sl = SongList::get()?; let mut sl = SongList::get()?;
sl.playable_songs = Self::get_playable_songs(&songs)?; sl.playable_songs = Self::get_playable_songs(&songs)?;
if let Some((sid, _)) = songs.first() { if let Some((sid, _)) = songs.first() {
if sl.selected_sid == Default::default() { if sl.selected_sid.eq(&uuid::Uuid::default()) {
sl.selected_sid = (*sid).clone(); sl.selected_sid = (*sid).clone();
} }
} }
@@ -66,6 +66,7 @@ impl SongList {
let should_display = match &query_type { let should_display = match &query_type {
SearchType::Normal | SearchType::Normal |
SearchType::Author | SearchType::Author |
SearchType::Genre |
SearchType::Source if query_text.is_empty() => true, SearchType::Source if query_text.is_empty() => true,
SearchType::Source => { SearchType::Source => {
@@ -83,6 +84,13 @@ impl SongList {
.to_lowercase() .to_lowercase()
.contains(&query_text) .contains(&query_text)
}, },
SearchType::Genre => {
song.genres()
.iter()
.map(|v| v.to_lowercase().contains(&query_text))
.collect::<Vec<bool>>()
.contains(&true)
},
}; };
if should_display { if should_display {

View File

@@ -11,7 +11,6 @@ mod components;
mod data; mod data;
mod utils; mod utils;
const W_NAME: &str = "xmpd v2.0.0a";
type Result<T> = anyhow::Result<T>; type Result<T> = anyhow::Result<T>;
@@ -24,7 +23,7 @@ pub fn start() -> Result<()> {
let options = eframe::NativeOptions::default(); let options = eframe::NativeOptions::default();
let mut state = GuiState::new(&manifest_p)?; let mut state = GuiState::new(&manifest_p)?;
let res = eframe::run_simple_native(W_NAME, options, move |ctx, _frame| { let res = eframe::run_simple_native(&format!("xmpd v{}", env!("CARGO_PKG_VERSION")), options, move |ctx, _frame| {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
let f_start = Instant::now(); let f_start = Instant::now();

View File

@@ -94,7 +94,7 @@ pub fn draw(ctx: &egui::Context, state: &mut GuiState, cache_rx: &Receiver<Messa
Ok(()) Ok(())
} }
fn get_themed_frame(theme: &Theme) -> egui::Frame { pub fn get_themed_frame(theme: &Theme) -> egui::Frame {
egui::Frame::none() egui::Frame::none()
.fill(theme.primary_bg_color) .fill(theme.primary_bg_color)
.stroke(egui::Stroke::new( .stroke(egui::Stroke::new(

View File

@@ -1,9 +1,12 @@
use std::fmt::Display;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum SearchType { pub enum SearchType {
Normal, Normal,
Author, Author,
Source, Source,
Genre
} }
impl SearchType { impl SearchType {
@@ -13,9 +16,27 @@ impl SearchType {
(Self::Source, i.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()), (Self::Source, i.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()),
i @ _ if i.starts_with("author:") => i @ _ if i.starts_with("author:") =>
(Self::Author, i.strip_prefix("author:").unwrap_or("").to_string().to_lowercase()), (Self::Author, i.strip_prefix("author:").unwrap_or("").to_string().to_lowercase()),
i @ _ if i.starts_with("genre:") =>
(Self::Author, i.strip_prefix("genre:").unwrap_or("").to_string().to_lowercase()),
i @ _ => (Self::Normal, i.to_string().to_lowercase()) i @ _ => (Self::Normal, i.to_string().to_lowercase())
} }
} }
pub fn new_query(&self, s: &str) -> String {
format!("{self}:{s}")
}
}
impl Display for SearchType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
Self::Normal => "",
Self::Genre => "genre",
Self::Source => "source",
Self::Author => "author"
};
f.write_str(s)?;
Ok(())
}
} }
pub fn super_separator(ui: &mut egui::Ui, color: egui::Color32, width: f32, height: f32) { pub fn super_separator(ui: &mut egui::Ui, color: egui::Color32, width: f32, height: f32) {

View File

@@ -99,8 +99,8 @@ impl Window for NewSongW {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add_space(3.0); ui.add_space(3.0);
if ui.button("Close").clicked() { if ui.button("Close").clicked() {
self.author = String::from("New Song"); self.author = String::from("Unknown");
self.name = String::from("Unknown"); self.name = String::from("New Song");
self.source_t = SourceType::Youtube; self.source_t = SourceType::Youtube;
self.source_url = String::default(); self.source_url = String::default();
state.windows.toggle(&WindowId::NewSong, false); state.windows.toggle(&WindowId::NewSong, false);
@@ -111,16 +111,16 @@ impl Window for NewSongW {
s.set_name(&self.name); s.set_name(&self.name);
s.set_author(&self.author); s.set_author(&self.author);
state.manifest.store_mut().get_songs_mut().insert(uuid::Uuid::new_v4(), s); state.manifest.store_mut().get_songs_mut().insert(uuid::Uuid::new_v4(), s);
let _ = state.manifest.save();
self.author = String::from("New Song"); self.author = String::from("Unknown");
self.name = String::from("Unknown"); self.name = String::from("New Song");
self.source_t = SourceType::Youtube; self.source_t = SourceType::Youtube;
self.source_url = String::default(); self.source_url = String::default();
} }
if ui.button("Cancel").clicked() { if ui.button("Cancel").clicked() {
self.author = String::from("New Song"); self.author = String::from("Unknown");
self.name = String::from("Unknown"); self.name = String::from("New Song");
self.source_t = SourceType::Youtube; self.source_t = SourceType::Youtube;
self.source_url = String::default(); self.source_url = String::default();
state.windows.toggle(&WindowId::NewSong, false); state.windows.toggle(&WindowId::NewSong, false);