switch to libcosmics builtin rfd instead of our own

This commit is contained in:
Chris Cochrun 2025-03-15 23:16:47 -05:00
parent 66e33be26c
commit 54ef90442e
6 changed files with 22 additions and 109 deletions

View file

@ -1,5 +1,6 @@
use cosmic::dialog::ashpd::url::Url;
// use cosmic::dialog::ashpd::url::Url;
use crisp::types::{Keyword, Symbol, Value};
use gstreamer::query::Uri;
use iced_video_player::Video;
use miette::{miette, Result};
use serde::{Deserialize, Serialize};
@ -58,7 +59,7 @@ impl TryFrom<Background> for Video {
value: Background,
) -> std::result::Result<Self, Self::Error> {
Video::new(
&Url::from_file_path(value.path)
&url::Url::from_file_path(value.path)
.map_err(|_| ParseError::BackgroundNotVideo)?,
)
.map_err(|_| ParseError::BackgroundNotVideo)

View file

@ -455,29 +455,7 @@ impl cosmic::Application for App {
})
}
Message::Library(message) => {
<<<<<<< HEAD
// debug!(?message);
let (mut kind, mut index): (LibraryKind, i32) =
(LibraryKind::Song, 0);
let mut opened_item = false;
match message {
library::Message::OpenItem(item) => {
let Some(item) = item else {
return ().into();
};
debug!("opening: {:?}", item);
kind = item.0;
index = item.1;
opened_item = true;
}
_ => {
// debug!("none");
()
}
};
=======
let mut song = Song::default();
>>>>>>> 93b021e (fixed lots of bugs by return Action enums in song_editor and library)
if let Some(library) = &mut self.library {
match library.update(message) {
library::Action::OpenItem(None) => {

View file

@ -2,7 +2,6 @@ use miette::{miette, IntoDiagnostic, Result};
use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc};
use cosmic::{
dialog::ashpd::url::Url,
iced::{
alignment::Horizontal,
font::{Family, Stretch, Style, Weight},
@ -26,6 +25,7 @@ use cosmic::{
use iced_video_player::{gst_pbutils, Position, Video, VideoPlayer};
use rodio::{Decoder, OutputStream, Sink};
use tracing::{debug, error, info, warn};
use url::Url;
use crate::{
core::{service_items::ServiceItemModel, slide::Slide},

View file

@ -1,6 +1,7 @@
use std::{io, path::PathBuf};
use cosmic::{
dialog::file_chooser::open::Dialog,
iced::{
font::{Family, Stretch, Style, Weight},
Font, Length,
@ -432,12 +433,18 @@ impl Default for SongEditor {
}
async fn pick_background() -> Result<PathBuf, SongError> {
rfd::AsyncFileDialog::new()
.set_title("Choose a background...")
.pick_file()
let dialog = Dialog::new().title("Choose a background...");
dialog
.open_file()
.await
.ok_or(SongError::DialogClosed)
.map(|file| file.path().to_owned())
.map_err(|_| SongError::DialogClosed)
.map(|file| file.url().to_file_path().unwrap())
// rfd::AsyncFileDialog::new()
// .set_title("Choose a background...")
// .pick_file()
// .await
// .ok_or(SongError::DialogClosed)
// .map(|file| file.path().to_owned())
}
#[derive(Debug, Clone)]