From 769ce2c13f5ca88a98aa5f8e6fddb9af0a4f1faf Mon Sep 17 00:00:00 2001 From: berry120 Date: Sat, 6 Jan 2024 01:22:26 +0000 Subject: [PATCH] Address #636 --- .../windows/library/VideoListPanel.java | 16 ++++----- .../windows/main/schedule/ScheduleList.java | 36 +++++++++++++------ 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Quelea/src/main/java/org/quelea/windows/library/VideoListPanel.java b/Quelea/src/main/java/org/quelea/windows/library/VideoListPanel.java index 0fcca6887..d09046f9a 100644 --- a/Quelea/src/main/java/org/quelea/windows/library/VideoListPanel.java +++ b/Quelea/src/main/java/org/quelea/windows/library/VideoListPanel.java @@ -184,13 +184,13 @@ public void addVideoFile(File file) { removeMenu.show(view, t.getScreenX(), t.getScreenY()); } }); -// view.setOnDragDetected((MouseEvent t) -> { -// Dragboard db = startDragAndDrop(TransferMode.ANY); -// ClipboardContent content = new ClipboardContent(); -// content.putString(file.getAbsolutePath()); -// db.setContent(content); -// t.consume(); -// }); + view.setOnDragDetected((MouseEvent t) -> { + Dragboard db = startDragAndDrop(TransferMode.ANY); + ClipboardContent content = new ClipboardContent(); + content.putString(file.getAbsolutePath()); + db.setContent(content); + t.consume(); + }); viewBox.getChildren().add(view); viewBox.getChildren().add(fileLabel); setupHover(viewBox, file.getName()); @@ -220,7 +220,7 @@ private static String trim17(String toTrim) { } private Image resize(Image image) { - var sImg = SwingFXUtils.fromFXImage(image, null).getScaledInstance(160,90,0); + var sImg = SwingFXUtils.fromFXImage(image, null).getScaledInstance(160, 90, 0); BufferedImage bimage = new BufferedImage(sImg.getWidth(null), sImg.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D bGr = bimage.createGraphics(); bGr.drawImage(sImg, 0, 0, null); diff --git a/Quelea/src/main/java/org/quelea/windows/main/schedule/ScheduleList.java b/Quelea/src/main/java/org/quelea/windows/main/schedule/ScheduleList.java index 6e5391367..c634f177b 100644 --- a/Quelea/src/main/java/org/quelea/windows/main/schedule/ScheduleList.java +++ b/Quelea/src/main/java/org/quelea/windows/main/schedule/ScheduleList.java @@ -34,9 +34,11 @@ import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.util.Callback; +import org.quelea.data.Background; import org.quelea.data.ImageBackground; import org.quelea.data.Schedule; import org.quelea.data.ThemeDTO; +import org.quelea.data.VideoBackground; import org.quelea.data.displayable.BiblePassage; import org.quelea.data.displayable.Displayable; import org.quelea.data.displayable.ImageDisplayable; @@ -251,28 +253,34 @@ private void dragDropped(DragEvent event, ListCell listCell) { } }); } else { - String imageLocation = db.getString(); + String dbLocation = db.getString(); boolean useTempDisp = false; - if (imageLocation != null) { - useTempDisp = imageLocation.equals("tempdisp"); - if (!Utils.isInDir(QueleaProperties.get().getImageDir(), new File(imageLocation)) && !useTempDisp) { + if (dbLocation != null) { + boolean isVideo = Utils.fileIsVideo(new File(dbLocation)); + useTempDisp = dbLocation.equals("tempdisp"); + if (!Utils.isInDir(QueleaProperties.get().getImageDir(), new File(dbLocation)) && !useTempDisp) { try { - Utils.copyFile(new File(imageLocation), new File(QueleaProperties.get().getImageDir(), new File(imageLocation).getName())); + Utils.copyFile(new File(dbLocation), new File(QueleaProperties.get().getImageDir(), new File(dbLocation).getName())); } catch (IOException ex) { LOGGER.log(Level.WARNING, "Couldn't copy image file", ex); } } - boolean isSong = true; - isSong = !(listCell == null || listCell.isEmpty()); + boolean isSong = !(listCell == null || listCell.isEmpty()); if (isSong) { if (!(listCell.getItem() instanceof TextDisplayable)) { isSong = false; } } if (!isSong && !useTempDisp) { - ImageDisplayable img = new ImageDisplayable(new File(imageLocation)); + Displayable visualDisplayable; + if(isVideo) { + visualDisplayable = new VideoDisplayable(dbLocation); + } + else { + visualDisplayable = new ImageDisplayable(new File(dbLocation)); + } useTempDisp = true; - tempDisp = img; + tempDisp = visualDisplayable; } else { if (useTempDisp) { @@ -288,7 +296,15 @@ private void dragDropped(DragEvent event, ListCell listCell) { if (dropShadow == null || (dropShadow.getColor().equals(Color.WHITE) && dropShadow.getOffsetX() == 0 && dropShadow.getOffsetY() == 0)) { dropShadow = new SerializableDropShadow(Color.BLACK, 3, 3, 2, 0, true); } - ThemeDTO newTheme = new ThemeDTO(theme.getSerializableFont(), theme.getFontPaint(), theme.getTranslateSerializableFont(), theme.getTranslateFontPaint(), new ImageBackground(new File(imageLocation).getName()), dropShadow, theme.getSerializableFont().isBold(), theme.getSerializableFont().isItalic(), theme.getTranslateSerializableFont().isBold(), theme.getTranslateSerializableFont().isItalic(), theme.getTextPosition(), theme.getTextAlignment()); + Background background; + if(isVideo) { + background = new VideoBackground(new File(dbLocation).getName(), 0, true); + } + else { + background = new ImageBackground(new File(dbLocation).getName()); + } + + ThemeDTO newTheme = new ThemeDTO(theme.getSerializableFont(), theme.getFontPaint(), theme.getTranslateSerializableFont(), theme.getTranslateFontPaint(), background, dropShadow, theme.getSerializableFont().isBold(), theme.getSerializableFont().isItalic(), theme.getTranslateSerializableFont().isBold(), theme.getTranslateSerializableFont().isItalic(), theme.getTextPosition(), theme.getTextAlignment()); for (TextSection section : textDisplayable.getSections()) { section.setTheme(newTheme); }