Skip to content

Commit

Permalink
After delete focus was lost
Browse files Browse the repository at this point in the history
Thread saftey for deleting
Menu for Taskmanager
Small UI enhancements
  • Loading branch information
lanthale committed Aug 12, 2022
1 parent 5c74e68 commit 2a59bfa
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 31 deletions.
2 changes: 1 addition & 1 deletion PhotoSlide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.photoslide</groupId>
<artifactId>PhotoSlide</artifactId>
<version>1.2.19</version>
<version>1.2.20</version>

<!-- This description text is included in the Windows installer by default, see win-jpackage.txt -->
<description>Photoslide is an app for managing and editing photos like Lightroom/ON1/...</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void initialize(URL url, ResourceBundle rb) {
taskProgressView = new TaskProgressView();
taskPopOver = new PopOver();
taskPopOver.setAnimated(true);
taskPopOver.setArrowLocation(PopOver.ArrowLocation.BOTTOM_CENTER);
taskPopOver.setArrowLocation(PopOver.ArrowLocation.BOTTOM_LEFT);
taskPopOver.setDetachable(false);
taskPopOver.setTitle("Taskmanager");
taskPopOver.setHeaderAlwaysVisible(true);
Expand Down Expand Up @@ -1118,5 +1118,12 @@ private void showProcessListButtonAction(ActionEvent event) {
((Parent) taskPopOver.getSkin().getNode()).getStylesheets()
.add(getClass().getResource("/org/photoslide/css/PopOver.css").toExternalForm());
}

@FXML
private void showBackgroundProcessListMenu(ActionEvent event) {
taskPopOver.show(showProcessButton);
((Parent) taskPopOver.getSkin().getNode()).getStylesheets()
.add(getClass().getResource("/org/photoslide/css/PopOver.css").toExternalForm());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import boofcv.io.MediaManager;
import boofcv.io.wrapper.DefaultMediaManager;
import georegression.struct.shapes.Quadrilateral_F64;
import java.util.Optional;
import java.util.prefs.Preferences;
import javafx.scene.control.CheckMenuItem;

Expand Down Expand Up @@ -359,10 +360,10 @@ public void setSelectedPath(Path sPath) {
}
if (keyCombinationMetaA.match(t)) {
fullMediaList.forEach((mediafile) -> {
factory.getSelectionModel().add(mediafile);
});
factory.getSelectionModel().add(mediafile);
});
}

if (KeyCode.RIGHT == t.getCode()) {
selectNextImageInGrid();
}
Expand Down Expand Up @@ -423,8 +424,19 @@ protected void interpolate(double frac) {
});*/
}

public void selectPreviousImageInGrid() {
int actIndex = sortedMediaList.indexOf(factory.getSelectedMediaItem());
/**
* selects the next image
*
* @param idx option parameter - if provided it it selects an the next item
* based on the provided index-1
*/
public void selectPreviousImageInGrid(int... idx) {
int actIndex = -1;
if (idx.length == 0) {
actIndex = sortedMediaList.indexOf(factory.getSelectedMediaItem());
} else {
actIndex = idx[0] - 1;
}
actIndex = actIndex - 1;
if (actIndex >= 0) {
MediaGridCell nextCell = factory.getMediaCellForMediaFile(sortedMediaList.get(actIndex));
Expand All @@ -438,8 +450,19 @@ public void selectPreviousImageInGrid() {
}
}

public void selectNextImageInGrid() {
int actIndex = sortedMediaList.indexOf(factory.getSelectedMediaItem());
/**
* selects the next image
*
* @param idx option parameter - if provided it it selects an the next item
* based on the provided index-1
*/
public void selectNextImageInGrid(int... idx) {
int actIndex = -1;
if (idx.length == 0) {
actIndex = sortedMediaList.indexOf(factory.getSelectedMediaItem());
} else {
actIndex = idx[0] - 1;
}
actIndex = actIndex + 1;
if (actIndex < sortedMediaList.size()) {
MediaGridCell nextCell = factory.getMediaCellForMediaFile(sortedMediaList.get(actIndex));
Expand Down Expand Up @@ -629,29 +652,27 @@ private void deleteButtonAction(ActionEvent event) {
deleteAction();
}

public void deleteAction() {
/*Alert alert = new Alert(AlertType.CONFIRMATION, "Mark MediaFile " + factory.getSelectedCell().getItem().getName() + " \n as deleted ?", ButtonType.CANCEL, ButtonType.YES, ButtonType.NO);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
getClass().getResource("/org/photoslide/css/Dialogs.css").toExternalForm());
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {*/
//new File(factory.getSelectedCell().getItem().getName()).delete();
MediaFile item = fullMediaList.get(fullMediaList.indexOf(factory.getSelectedCell().getItem()));
public void deleteAction() {
final int sIdx = sortedMediaList.indexOf(factory.getSelectedCell().getItem());
final int idx = fullMediaList.indexOf(factory.getSelectedCell().getItem());
final MediaFile item = fullMediaList.get(idx);
item.setDeleted(true);
imageView.setImage(null);
getTitleLabel().setVisible(false);
getCameraLabel().setVisible(false);
getFilenameLabel().setVisible(false);
getRatingControl().setVisible(false);
/*} else {
alert.hide();
}
factory.getSelectedCell().requestLayout();*/
executorParallel.submit(() -> {
factory.getSelectedCell().getItem().saveEdits();
getRatingControl().setVisible(false);
Task<Boolean> task = new Task<>() {
@Override
protected Boolean call() throws Exception {
item.saveEdits();
return true;
}
};
task.setOnSucceeded((t) -> {
selectNextImageInGrid(sIdx);
});
executorParallel.submit(task);
}

@FXML
Expand Down
15 changes: 10 additions & 5 deletions PhotoSlide/src/main/resources/org/photoslide/fxml/MainView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<MenuItem mnemonicParsing="false" onAction="#wipeAllMediaFileEdits" text="Wipe all edits" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Window">
<items>
<MenuItem mnemonicParsing="false" onAction="#showBackgroundProcessListMenu" text="Show background process list" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem fx:id="aboutMenu" mnemonicParsing="false" onAction="#aboutMenuAction" text="About PhotoSlide" />
Expand Down Expand Up @@ -305,6 +310,11 @@

<HBox id="HBox" alignment="CENTER_LEFT" maxHeight="26.0" minHeight="26.0" prefHeight="26.0" prefWidth="1280.0" spacing="5.0" style="-fx-background-color: rgb(80, 80, 80)rgb(80, 80, 80);" VBox.vgrow="NEVER">
<children>
<Button id="toolbutton" fx:id="showProcessButton" mnemonicParsing="false" onAction="#showProcessListButtonAction" HBox.hgrow="NEVER">
<graphic>
<FontIcon fx:id="processListIcon" iconLiteral="ti-pulse" />
</graphic>
</Button>
<Label fx:id="statusLabelLeft" maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Left status" textFill="#9f9f9f" HBox.hgrow="ALWAYS">
<font>
<Font size="11.0" fx:id="x3" />
Expand All @@ -320,11 +330,6 @@
</Label>
</children>
</StackPane>
<Button id="toolbutton" fx:id="showProcessButton" mnemonicParsing="false" onAction="#showProcessListButtonAction" HBox.hgrow="NEVER">
<graphic>
<FontIcon fx:id="processListIcon" iconLiteral="ti-pulse" />
</graphic>
</Button>
<Pane minHeight="20.0" prefHeight="20.0" prefWidth="-1.0" HBox.hgrow="ALWAYS" />
<Label fx:id="statusLabelRight" font="$x3" maxWidth="-1.0" text="Right status" textFill="#9f9f9f" HBox.hgrow="NEVER" />
</children>
Expand Down

0 comments on commit 2a59bfa

Please sign in to comment.