bugs: loading is nearly working...
There is a bug with the slides not containing the text portions of the songs. There is also perhaps a bug in the logic to move to the next and previous slides
This commit is contained in:
parent
3685670ff7
commit
985710b7c5
2 changed files with 62 additions and 22 deletions
|
|
@ -42,7 +42,7 @@ pub fn save(
|
|||
temp_dir.push(s);
|
||||
fs::create_dir_all(&temp_dir).into_diagnostic()?;
|
||||
let service_file = temp_dir.join("serviceitems.ron");
|
||||
dbg!(&service_file);
|
||||
debug!(?service_file);
|
||||
fs::File::create(&service_file).into_diagnostic()?;
|
||||
match fs::File::options()
|
||||
.read(true)
|
||||
|
|
@ -52,23 +52,21 @@ pub fn save(
|
|||
Ok(mut f) => {
|
||||
match f.write(ron.as_bytes()) {
|
||||
Ok(size) => {
|
||||
dbg!(size);
|
||||
debug!(size);
|
||||
}
|
||||
Err(e) => {
|
||||
error!(?e);
|
||||
dbg!(&e);
|
||||
return Err(miette!("PROBS: {e}"));
|
||||
}
|
||||
}
|
||||
match tar.append_file("serviceitems.ron", &mut f) {
|
||||
Ok(()) => {
|
||||
dbg!(
|
||||
debug!(
|
||||
"should have added serviceitems.ron to the file"
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
error!(?e);
|
||||
dbg!(&e);
|
||||
return Err(miette!("PROBS: {e}"));
|
||||
}
|
||||
}
|
||||
|
|
@ -113,19 +111,25 @@ pub fn save(
|
|||
}
|
||||
}
|
||||
if let Some(path) = audio {
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
dbg!(&path);
|
||||
let mut file = fs::File::open(&path).into_diagnostic()?;
|
||||
tar.append_file(file_name, &mut file)
|
||||
.into_diagnostic()?;
|
||||
if path.exists() {
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
debug!(?path);
|
||||
let mut file =
|
||||
fs::File::open(&path).into_diagnostic()?;
|
||||
tar.append_file(file_name, &mut file)
|
||||
.into_diagnostic()?;
|
||||
}
|
||||
}
|
||||
if let Some(background) = background {
|
||||
let path = background.path;
|
||||
dbg!(&path);
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
let mut file = fs::File::open(&path).into_diagnostic()?;
|
||||
tar.append_file(file_name, &mut file)
|
||||
.into_diagnostic()?;
|
||||
if path.exists() {
|
||||
debug!(?path);
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
let mut file =
|
||||
fs::File::open(&path).into_diagnostic()?;
|
||||
tar.append_file(file_name, &mut file)
|
||||
.into_diagnostic()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +137,6 @@ pub fn save(
|
|||
Ok(()) => (),
|
||||
Err(e) => {
|
||||
error!(?e);
|
||||
dbg!(&e);
|
||||
return Err(miette!("tar error: {e}"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
49
src/main.rs
49
src/main.rs
|
|
@ -7,7 +7,7 @@ use core::slide::{
|
|||
};
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::cosmic_config::{Config, CosmicConfigEntry};
|
||||
use cosmic::dialog::file_chooser::save;
|
||||
use cosmic::dialog::file_chooser::{open, save};
|
||||
use cosmic::iced::alignment::Vertical;
|
||||
use cosmic::iced::keyboard::{Key, Modifiers};
|
||||
use cosmic::iced::window::{Mode, Position};
|
||||
|
|
@ -221,6 +221,7 @@ enum Message {
|
|||
New,
|
||||
Open,
|
||||
OpenFile(PathBuf),
|
||||
OpenLoadItems(Vec<ServiceItem>),
|
||||
Save,
|
||||
SaveAsDialog,
|
||||
SaveAs(PathBuf),
|
||||
|
|
@ -1498,23 +1499,50 @@ impl cosmic::Application for App {
|
|||
}
|
||||
Message::Open => {
|
||||
debug!("Open file");
|
||||
Task::none()
|
||||
Task::perform(open_dialog(), |res| match res {
|
||||
Ok(file) => {
|
||||
cosmic::Action::App(Message::OpenFile(file))
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
?e,
|
||||
"There was an error during opening"
|
||||
);
|
||||
cosmic::Action::None
|
||||
}
|
||||
})
|
||||
}
|
||||
Message::OpenFile(file) => {
|
||||
debug!(?file, "opening file");
|
||||
Task::perform(
|
||||
async move { file::load(file) },
|
||||
|res| match res {
|
||||
Ok(items) => cosmic::Action::App(
|
||||
Message::OpenLoadItems(items),
|
||||
),
|
||||
Err(e) => {
|
||||
error!(?e);
|
||||
cosmic::Action::None
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
Message::OpenLoadItems(items) => {
|
||||
self.service = items.clone();
|
||||
self.presenter.service = items;
|
||||
Task::none()
|
||||
}
|
||||
Message::Save => {
|
||||
let service = self.service.clone();
|
||||
let file1 = self.file.clone();
|
||||
let file2 = self.file.clone();
|
||||
let file = self.file.clone();
|
||||
let file_name = self.file.file_name().expect("Since we are saving we should have given a name by now").to_owned();
|
||||
Task::perform(
|
||||
async move { file::save(service, file1, true) },
|
||||
async move { file::save(service, file, true) },
|
||||
move |res| match res {
|
||||
Ok(()) => {
|
||||
tracing::info!(
|
||||
"saving file to: {:?}",
|
||||
file2
|
||||
file_name
|
||||
);
|
||||
cosmic::Action::None
|
||||
}
|
||||
|
|
@ -2196,3 +2224,12 @@ async fn save_as_dialog() -> Result<PathBuf> {
|
|||
)
|
||||
})?
|
||||
}
|
||||
|
||||
async fn open_dialog() -> Result<PathBuf> {
|
||||
let dialog = open::Dialog::new();
|
||||
open::file(dialog).await.into_diagnostic().map(|response| {
|
||||
response.url().to_file_path().map_err(|e| {
|
||||
miette!("Can't convert to file path: {:?}", e)
|
||||
})
|
||||
})?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue