Compare commits

..

5 Commits
2.1.2 ... main

9 changed files with 96 additions and 17 deletions

0
CHANGELOG.md Normal file
View File

18
Cargo.lock generated
View File

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

View File

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

View File

@ -1,8 +1,10 @@
use eframe::Frame;
use egui::{Align, Align2, Area, Key, Layout, Order, Style};
use uuid::Uuid;
use xmpd_cache::DlStatus;
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;
@ -15,6 +17,8 @@ pub struct Header {
component_register!(Header);
impl CompUi for Header {
fn draw(ui: &mut egui::Ui, state: &mut crate::GuiState) -> crate::Result<()> {
let theme = xmpd_settings::Settings::get()?.theme.clone();
@ -26,7 +30,54 @@ impl CompUi for Header {
.tint(theme.accent_color);
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.style_mut().visuals.override_text_color = Some(theme.text_color);
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| {

View File

@ -66,6 +66,7 @@ impl SongList {
let should_display = match &query_type {
SearchType::Normal |
SearchType::Author |
SearchType::Genre |
SearchType::Source if query_text.is_empty() => true,
SearchType::Source => {
@ -83,6 +84,13 @@ impl SongList {
.to_lowercase()
.contains(&query_text)
},
SearchType::Genre => {
song.genres()
.iter()
.map(|v| v.to_lowercase().contains(&query_text))
.collect::<Vec<bool>>()
.contains(&true)
},
};
if should_display {

View File

@ -11,7 +11,6 @@ mod components;
mod data;
mod utils;
const W_NAME: &str = "xmpd v2.0.0a";
type Result<T> = anyhow::Result<T>;
@ -24,7 +23,7 @@ pub fn start() -> Result<()> {
let options = eframe::NativeOptions::default();
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)]
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(())
}
fn get_themed_frame(theme: &Theme) -> egui::Frame {
pub fn get_themed_frame(theme: &Theme) -> egui::Frame {
egui::Frame::none()
.fill(theme.primary_bg_color)
.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 {
Normal,
Author,
Source,
Genre
}
impl SearchType {
@ -13,9 +16,27 @@ impl SearchType {
(Self::Source, i.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()),
i @ _ if i.starts_with("author:") =>
(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())
}
}
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) {

View File

@ -111,7 +111,7 @@ impl Window for NewSongW {
s.set_name(&self.name);
s.set_author(&self.author);
state.manifest.store_mut().get_songs_mut().insert(uuid::Uuid::new_v4(), s);
let _ = state.manifest.save();
self.author = String::from("Unknown");
self.name = String::from("New Song");
self.source_t = SourceType::Youtube;