This commit is contained in:
parent
004eb60470
commit
f3d0cd5459
2 changed files with 71 additions and 4 deletions
51
src/main.rs
51
src/main.rs
|
@ -597,6 +597,8 @@ impl cosmic::Application for App {
|
||||||
slide,
|
slide,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
self.current_item =
|
||||||
|
(item_index, slide_index + 1);
|
||||||
Task::none()
|
Task::none()
|
||||||
} else {
|
} else {
|
||||||
debug!("Slides are not longer");
|
debug!("Slides are not longer");
|
||||||
|
@ -613,7 +615,54 @@ impl cosmic::Application for App {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
presenter::Action::PrevSlide => todo!(),
|
presenter::Action::PrevSlide => {
|
||||||
|
let slide_index = self.current_item.1;
|
||||||
|
let item_index = self.current_item.0;
|
||||||
|
if let Some(item) =
|
||||||
|
self.service.get(item_index)
|
||||||
|
{
|
||||||
|
if slide_index != 0 {
|
||||||
|
let slide = item.slides
|
||||||
|
[slide_index - 1]
|
||||||
|
.clone();
|
||||||
|
self.presenter.update(
|
||||||
|
presenter::Message::SlideChange(
|
||||||
|
slide,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self.current_item =
|
||||||
|
(item_index, slide_index - 1);
|
||||||
|
Task::none()
|
||||||
|
} else if slide_index == 0
|
||||||
|
&& item_index == 0
|
||||||
|
{
|
||||||
|
Task::none()
|
||||||
|
} else {
|
||||||
|
debug!("Change slide to previous items slides");
|
||||||
|
let previous_item_slides_length =
|
||||||
|
if let Some(item) = self
|
||||||
|
.service
|
||||||
|
.get(item_index - 1)
|
||||||
|
{
|
||||||
|
item.slides.len()
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
self.current_item = (
|
||||||
|
item_index - 1,
|
||||||
|
previous_item_slides_length - 1,
|
||||||
|
);
|
||||||
|
if let Some(item) =
|
||||||
|
self.service.get(item_index - 1)
|
||||||
|
{
|
||||||
|
self.presenter.update(presenter::Message::SlideChange(item.slides[previous_item_slides_length - 1].clone()));
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Library(message) => {
|
Message::Library(message) => {
|
||||||
|
|
|
@ -244,13 +244,31 @@ impl Presenter {
|
||||||
let audio = PathBuf::from(audio);
|
let audio = PathBuf::from(audio);
|
||||||
debug!("{:?}", audio);
|
debug!("{:?}", audio);
|
||||||
if audio.exists() {
|
if audio.exists() {
|
||||||
match &self.audio {
|
let old_audio = self.audio.clone();
|
||||||
Some(aud) if aud != &audio => {
|
match old_audio {
|
||||||
|
Some(current_audio)
|
||||||
|
if current_audio != audio =>
|
||||||
|
{
|
||||||
self.audio = Some(audio.clone());
|
self.audio = Some(audio.clone());
|
||||||
|
debug!(
|
||||||
|
?audio,
|
||||||
|
?current_audio,
|
||||||
|
"starting audio"
|
||||||
|
);
|
||||||
tasks.push(self.start_audio());
|
tasks.push(self.start_audio());
|
||||||
}
|
}
|
||||||
Some(_) => (),
|
Some(current_audio) => {
|
||||||
|
debug!(
|
||||||
|
?audio,
|
||||||
|
?current_audio,
|
||||||
|
"could not find audio"
|
||||||
|
);
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
|
debug!(
|
||||||
|
?audio,
|
||||||
|
"could not find audio"
|
||||||
|
);
|
||||||
self.audio = Some(audio.clone());
|
self.audio = Some(audio.clone());
|
||||||
tasks.push(self.start_audio());
|
tasks.push(self.start_audio());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue