Skip to content

Commit

Permalink
Fix #562
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 committed Dec 20, 2023
1 parent d3fb446 commit 989809d
Showing 1 changed file with 101 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,43 @@ public PresentationPanel(final LivePreviewPanel containerPanel) {
this.containerPanel = containerPanel;
BorderPane mainPanel = new BorderPane();
presentationPreview = new PresentationPreview();
presentationPreview.addSlideChangedListener(new org.quelea.windows.presentation.SlideChangedListener() {
@Override
public void slideChanged(PresentationSlide newSlide) {
if (live) {
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
if (!PowerPointHandler.getCurrentSlide().equals(String.valueOf(presentationPreview.getSelectedIndex()))) {
PowerPointHandler.gotoSlide(presentationPreview.getSelectedIndex());
}
}
if (newSlide != null && displayable != null) {
if (displayable.getOOPresentation() == null) {
currentSlide = newSlide;
updateCanvas();
} else {
OOPresentation pres = displayable.getOOPresentation();
pres.setSlideListener((final int newSlideIndex) -> {
presentationPreview.select(newSlideIndex + 1);
});
currentSlide = newSlide;
startOOPres();
QueleaApp.get().getMainWindow().toFront();
pres.gotoSlide(presentationPreview.getSelectedIndex() - 1);
}
presentationPreview.addSlideChangedListener(newSlide -> {
if (live) {
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
if (!PowerPointHandler.getCurrentSlide().equals(String.valueOf(presentationPreview.getSelectedIndex()))) {
PowerPointHandler.gotoSlide(presentationPreview.getSelectedIndex());
}
if (QueleaProperties.get().getUsePP() && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
if (newSlide != null && displayable != null) {
if (displayable.getOOPresentation() == null) {
currentSlide = newSlide;
updateCanvas();
} else {
OOPresentation pres = displayable.getOOPresentation();
pres.setSlideListener((final int newSlideIndex) -> {
presentationPreview.select(newSlideIndex + 1);
});
currentSlide = newSlide;
startOOPres();
QueleaApp.get().getMainWindow().toFront();
pres.gotoSlide(presentationPreview.getSelectedIndex() - 1);
}
}
if (QueleaProperties.get().getUsePP() && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
}
});
presentationPreview.select(0);

presentationPreview.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) {
if (t.getCode().equals(KeyCode.PAGE_DOWN) || t.getCode().equals(KeyCode.DOWN) || t.getCode().equals(KeyCode.RIGHT)) {
t.consume();
QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().advance();
} else if (t.getCode().equals(KeyCode.PAGE_UP) || t.getCode().equals(KeyCode.UP) || t.getCode().equals(KeyCode.LEFT)) {
t.consume();
QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().previous();
}
presentationPreview.addEventHandler(KeyEvent.KEY_PRESSED, t -> {
if (t.getCode().equals(KeyCode.PAGE_DOWN) || t.getCode().equals(KeyCode.DOWN) || t.getCode().equals(KeyCode.RIGHT)) {
t.consume();
QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().advance();
} else if (t.getCode().equals(KeyCode.PAGE_UP) || t.getCode().equals(KeyCode.UP) || t.getCode().equals(KeyCode.LEFT)) {
t.consume();
QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().previous();
}
});
mainPanel.setCenter(presentationPreview);
Expand All @@ -133,42 +127,39 @@ public void requestFocus() {
public void buildLoopTimeline() {
loopTimeline = new Timeline(
new KeyFrame(Duration.seconds(0),
new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if (containerPanel instanceof LivePanel) {
LivePanel livePanel = ((LivePanel) containerPanel);
if (livePanel.isLoopSelected()) {
if (QueleaProperties.get().getUsePP() && livePanel.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.gotoNext();
if (result.contains("not running")) {
Dialog.showInfo(LabelGrabber.INSTANCE.getLabel("set.loop.manually.title"), LabelGrabber.INSTANCE.getLabel("set.loop.manually.message"));
livePanel.stopLoop();
}
} else if (livePanel.getDisplayable() instanceof PresentationDisplayable) {
presentationPreview.advanceSlide(true);
} else {
if (livePanel.getIndex() != livePanel.getLenght()) {
livePanel.advance();
actionEvent -> {
if (containerPanel instanceof LivePanel) {
LivePanel livePanel = ((LivePanel) containerPanel);
if (livePanel.isLoopSelected()) {
if (QueleaProperties.get().getUsePP() && livePanel.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.gotoNext();
if (result.contains("not running")) {
Dialog.showInfo(LabelGrabber.INSTANCE.getLabel("set.loop.manually.title"), LabelGrabber.INSTANCE.getLabel("set.loop.manually.message"));
livePanel.stopLoop();
}
} else if (livePanel.getDisplayable() instanceof PresentationDisplayable) {
presentationPreview.advanceSlide(true);
} else {
livePanel.selectFirstLyric();
if (livePanel.getIndex() != livePanel.getLenght()) {
livePanel.advance();
} else {
livePanel.selectFirstLyric();
}
}
}
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.getCurrentSlide();
if (!result.contains("not running") && !result.isEmpty()) {
int i = Integer.parseInt(result);
presentationPreview.select(i, false);
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.getCurrentSlide();
if (!result.contains("not running") && !result.isEmpty()) {
int i = Integer.parseInt(result);
presentationPreview.select(i, false);
}
}
if (lp.getDisplayable() instanceof PresentationDisplayable && QueleaProperties.get().getUsePP() && !QueleaProperties.get().getPPPath().contains("PPTVIEW") && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
}
if (lp.getDisplayable() instanceof PresentationDisplayable && QueleaProperties.get().getUsePP() && !QueleaProperties.get().getPPPath().contains("PPTVIEW") && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
}
}
}
}
),
new KeyFrame(Duration.seconds(10))
);
Expand All @@ -177,68 +168,59 @@ public void handle(ActionEvent actionEvent) {
loopTimeline.play();

QueleaApp.get()
.doOnLoad(new Runnable() {
.doOnLoad(() -> QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().getLoopDurationTextField().textProperty().addListener(new ChangeListener<String>() {

@Override
public void run() {
QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().getLoopDurationTextField().textProperty().addListener(new ChangeListener<String>() {

@Override
public void changed(ObservableValue<? extends String> ov, String t, String t1) {
int newTime;
try {
newTime = Integer.parseInt(t1);
} catch (NumberFormatException ex) {
return;
}
loopTimeline.stop();
loopTimeline = new Timeline(
new KeyFrame(Duration.seconds(0),
new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if (containerPanel instanceof LivePanel) {
LivePanel livePanel = ((LivePanel) containerPanel);
if (livePanel.isLoopSelected()) {
if (QueleaProperties.get().getUsePP() && livePanel.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.gotoNext();
if (result.contains("not running")) {
Dialog.showInfo(LabelGrabber.INSTANCE.getLabel("set.loop.manually.title"), LabelGrabber.INSTANCE.getLabel("set.loop.manually.message"));
livePanel.stopLoop();
}
} else if (livePanel.getDisplayable() instanceof PresentationDisplayable) {
presentationPreview.advanceSlide(true);
} else {
if (livePanel.getIndex() != livePanel.getLenght()) {
livePanel.advance();
} else {
livePanel.selectFirstLyric();
}
public void changed(ObservableValue<? extends String> ov, String t, String t1) {
int newTime;
try {
newTime = Integer.parseInt(t1);
} catch (NumberFormatException ex) {
return;
}
loopTimeline.stop();
loopTimeline = new Timeline(
new KeyFrame(Duration.seconds(0),
actionEvent -> {
if (containerPanel instanceof LivePanel) {
LivePanel livePanel = ((LivePanel) containerPanel);
if (livePanel.isLoopSelected()) {
if (QueleaProperties.get().getUsePP() && livePanel.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.gotoNext();
if (result.contains("not running")) {
Dialog.showInfo(LabelGrabber.INSTANCE.getLabel("set.loop.manually.title"), LabelGrabber.INSTANCE.getLabel("set.loop.manually.message"));
livePanel.stopLoop();
}
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.getCurrentSlide();
if (!result.contains("not running") && !result.isEmpty()) {
int i = Integer.parseInt(result);
presentationPreview.select(i, false);
}
} else if (livePanel.getDisplayable() instanceof PresentationDisplayable) {
presentationPreview.advanceSlide(true);
} else {
if (livePanel.getIndex() != livePanel.getLenght()) {
livePanel.advance();
} else {
livePanel.selectFirstLyric();
}
if (lp.getDisplayable() instanceof PresentationDisplayable && QueleaProperties.get().getUsePP() && !QueleaProperties.get().getPPPath().contains("PPTVIEW") && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
LivePanel lp = QueleaApp.get().getMainWindow().getMainPanel().getLivePanel();
if (lp.getDisplayable() instanceof PresentationDisplayable) {
String result = PowerPointHandler.getCurrentSlide();
if (!result.contains("not running") && !result.isEmpty()) {
int i = Integer.parseInt(result);
presentationPreview.select(i, false);
}
}
if (lp.getDisplayable() instanceof PresentationDisplayable && QueleaProperties.get().getUsePP() && !QueleaProperties.get().getPPPath().contains("PPTVIEW") && lp.getBlacked() && !PowerPointHandler.screenStatus().equals("3")) {
lp.setBlacked(false);
}
}
}
}
),
new KeyFrame(Duration.seconds(newTime))
);
loopTimeline.setCycleCount(Animation.INDEFINITE);
loopTimeline.play();
}
});
),
new KeyFrame(Duration.seconds(newTime))
);
loopTimeline.setCycleCount(Animation.INDEFINITE);
loopTimeline.play();
}
}
})
);
}

Expand Down Expand Up @@ -292,12 +274,7 @@ public void showDisplayable(final PresentationDisplayable displayable, final int
}
PresentationSlide[] slides = displayable.getPresentation().getSlides();
presentationPreview.setSlides(slides);
Platform.runLater(new Runnable() {
@Override
public void run() {
presentationPreview.select(Math.max(index,1), true);
}
});
Platform.runLater(() -> presentationPreview.select(Math.max(index,1), true));

/*
* TODO
Expand Down

0 comments on commit 989809d

Please sign in to comment.