mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-09-20 14:13:32 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd13eee0df | ||
|
|
3d1bc24c21 |
+30
-17
@@ -5,7 +5,6 @@ mod views;
|
||||
use anyhow::{Result, anyhow};
|
||||
use eframe::{NativeOptions, icon_data::from_png_bytes, run_native};
|
||||
use egui::{Context, FontData, FontDefinitions, FontFamily, FontTweak, Vec2, ViewportBuilder};
|
||||
use itertools::Itertools;
|
||||
use pwsp_lib::{
|
||||
types::{
|
||||
audio_player::PlayerState,
|
||||
@@ -110,12 +109,17 @@ impl SoundpadGui {
|
||||
pub fn add_dirs(&mut self) {
|
||||
let file_dialog = FileDialog::new();
|
||||
if let Some(paths) = file_dialog.pick_folders() {
|
||||
let mut changed = false;
|
||||
for path in paths {
|
||||
self.app_state.dirs.push(path);
|
||||
if !self.app_state.dirs.contains(&path) {
|
||||
self.app_state.dirs.push(path);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
self.config.dirs = self.app_state.dirs.clone();
|
||||
self.config.save_to_file().ok();
|
||||
}
|
||||
self.app_state.dirs = self.app_state.dirs.iter().unique().cloned().collect();
|
||||
self.config.dirs = self.app_state.dirs.clone();
|
||||
self.config.save_to_file().ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,18 +200,27 @@ impl SoundpadGui {
|
||||
if let Ok(entries) = fs::read_dir(&dir) {
|
||||
let mut children = Vec::new();
|
||||
for entry in entries.filter_map(|e| e.ok()) {
|
||||
let p = entry.path();
|
||||
if p.is_dir() {
|
||||
dirs_to_visit.push(p.clone());
|
||||
children.push(p);
|
||||
} else if crate::gui::SUPPORTED_EXTENSIONS.contains(
|
||||
&p.extension()
|
||||
.unwrap_or_default()
|
||||
.to_str()
|
||||
.unwrap_or_default(),
|
||||
) {
|
||||
all_files.push(p.clone());
|
||||
children.push(p);
|
||||
if let Ok(file_type) = entry.file_type() {
|
||||
if file_type.is_dir() {
|
||||
let p = entry.path();
|
||||
dirs_to_visit.push(p.clone());
|
||||
children.push(p);
|
||||
} else {
|
||||
let file_name = entry.file_name();
|
||||
let is_supported = Path::new(&file_name)
|
||||
.extension()
|
||||
.map(|e| {
|
||||
crate::gui::SUPPORTED_EXTENSIONS
|
||||
.contains(&e.to_str().unwrap_or_default())
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
if is_supported {
|
||||
let p = entry.path();
|
||||
all_files.push(p.clone());
|
||||
children.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dir_updates.insert(dir, children);
|
||||
|
||||
Reference in New Issue
Block a user