Skip to content

Commit

Permalink
Address #636
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 committed Jan 6, 2024
1 parent 9db222b commit 769ce2c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -251,28 +253,34 @@ private void dragDropped(DragEvent event, ListCell<Displayable> 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) {

Expand All @@ -288,7 +296,15 @@ private void dragDropped(DragEvent event, ListCell<Displayable> 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);
}
Expand Down

0 comments on commit 769ce2c

Please sign in to comment.