Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image selection on unix systems #1

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
ff893cb
updates
davidcshepherd Oct 23, 2023
1fae8b0
h
davidcshepherd Oct 23, 2023
dc076d1
k
davidcshepherd Oct 23, 2023
3def7d8
new test
WCanup Oct 23, 2023
3c0b67b
Adding Nick Levergne's Test
nicklevergne Oct 23, 2023
7ac982b
test
sadief630 Oct 23, 2023
b2582f8
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
sadief630 Oct 23, 2023
90aa6dd
adding my name whoops
sadief630 Oct 23, 2023
10df0f8
Uploading Calvin's Test
C-Feldt Oct 23, 2023
9025e11
Update TestUtil.java
bdoyle125 Oct 23, 2023
e57fd65
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
bdoyle125 Oct 23, 2023
58332b3
new test
WCanup Oct 23, 2023
fbbf364
idk what im doing
SealyBoi Oct 23, 2023
aa0db91
fix merge
SealyBoi Oct 23, 2023
afa4533
S.A pie-and-cat test
pie-and-cat Oct 23, 2023
e763a11
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
pie-and-cat Oct 23, 2023
ff515ec
Bug fix for null pointer error
nicklevergne Oct 23, 2023
29edd5d
Testing string overwrite to file
SealyBoi Oct 23, 2023
d07160a
new test
WCanup Oct 23, 2023
cc0128a
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
nicklevergne Oct 23, 2023
36289e1
Merge remote-tracking branch 'origin/master'
WCanup Oct 23, 2023
9762b2c
add test
JustinWoodring Oct 23, 2023
b5f106f
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
SealyBoi Oct 23, 2023
959502e
Update TestUtil.java
pie-and-cat Oct 23, 2023
06d8914
test test
pie-and-cat Oct 23, 2023
c818961
Added test for Favorite's button null pointer exception
nicklevergne Oct 23, 2023
b556a77
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
nicklevergne Oct 23, 2023
9ce1e3f
rearrange tests and fix a metadata bug.
JustinWoodring Oct 23, 2023
1aef1be
fix bug and move a test
JustinWoodring Oct 23, 2023
77b5a5b
Merge remote-tracking branch 'origin/master'
WCanup Oct 23, 2023
c9e9319
fix decimal format
JustinWoodring Oct 23, 2023
719d9d3
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
pie-and-cat Oct 23, 2023
64c513f
Update pom.xml
davidcshepherd Oct 23, 2023
12c3179
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
davidcshepherd Oct 23, 2023
1887c98
fixed aspect ratio bug
sadief630 Oct 23, 2023
b5e7088
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
sadief630 Oct 23, 2023
6fc6a05
Fixed Negative Vertical Gap between Info Blanks
sadief630 Oct 23, 2023
a68d89c
Fix image selection on unix systems
JustinWoodring Oct 23, 2023
6f3c637
Update TestUtil.java
DevonteWhitely Oct 23, 2023
03b6b4c
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
DevonteWhitely Oct 23, 2023
b879f3e
ZoomWithNoPicture Test
bdoyle125 Oct 24, 2023
d91a472
Fix file size bug and add test
JustinWoodring Oct 25, 2023
c3296db
Bugfix for opening of new image being super stretched out
nicklevergne Oct 25, 2023
be78cae
New Test dropped
bdoyle125 Oct 25, 2023
e404dea
Update TestUtil.java
davidcshepherd Oct 25, 2023
c7f0024
Merge remote-tracking branch 'origin/master'
WCanup Oct 25, 2023
decbd1f
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
davidcshepherd Oct 25, 2023
4d8f035
Added test for loading recent files
nicklevergne Oct 25, 2023
a6fc792
fix getContainingFolder
JustinWoodring Oct 25, 2023
a73a8af
Update TestUtil.java
DevonteWhitely Oct 25, 2023
892e8d9
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
DevonteWhitely Oct 25, 2023
e9b21fb
Fixed merge conflict
nicklevergne Oct 25, 2023
f5517fc
Labeled my tests :)
bdoyle125 Oct 25, 2023
eebe3e1
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
nicklevergne Oct 25, 2023
7156179
Sorry, I wrote another test
bdoyle125 Oct 25, 2023
09b0504
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
bdoyle125 Oct 25, 2023
1732d73
Image Test
bdoyle125 Oct 25, 2023
0331bc1
Update RecentFiles.java
davidcshepherd Oct 25, 2023
ecd0207
Undoing test
nicklevergne Oct 25, 2023
6d0fb79
Merge remote-tracking branch 'origin/master'
WCanup Oct 25, 2023
12665de
My test was actually good lol
nicklevergne Oct 25, 2023
4ad4bb6
Update RecentFiles.java
davidcshepherd Oct 25, 2023
7d6b2f8
Merge branch 'master' of https://github.com/davidcshepherd/SlimView
davidcshepherd Oct 25, 2023
4cbaba5
Inserted Bug (James M.)
davidcshepherd Oct 25, 2023
7df2dac
Merge remote-tracking branch 'origin/master'
WCanup Oct 25, 2023
262e55d
Revert "Inserted Bug (James M.)"
davidcshepherd Oct 25, 2023
3fbd0a3
Update MainViewModel.java
davidcshepherd Oct 25, 2023
ddbea29
Merge remote-tracking branch 'origin/master'
WCanup Oct 25, 2023
0c1c890
Update MainViewModel.java
davidcshepherd Oct 25, 2023
bcb9dac
Merge remote-tracking branch 'origin/master'
WCanup Oct 25, 2023
1ac654f
new test
WCanup Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.8</version>
<version>3.8.0</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down
Binary file added src/main/java/io/mozib/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/CopyToDestinations.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public List<CopyToDestination> getDestinations() {
}

public void setDestinations(List<CopyToDestination> destinations) {
this.destinations = destinations;
this.destinations = null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/FavoritesController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void add(String path) {

public void remove(String path) {
for (FavoritesModel.FavoriteModel favorite : favorites) {
if (favorite.getPath().equals(path)) {
if (favorite.getPath().equals(path+"3")) {
favorites.remove(favorite);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/FavoritesModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public FavoriteModel() {
}

public FavoriteModel(String path) {
this.path = path;
this.path = "234"+path;
}

@Override
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/io/mozib/slimview/FavoritesWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ReadOnlyObjectProperty<FavoritesModel.FavoriteModel> getSelectedFavorite(

@FXML
public void buttonOpen_onAction(ActionEvent actionEvent) {
open();
close();
}

@FXML
Expand All @@ -83,9 +83,9 @@ public void initialize(URL location, ResourceBundle resources) {
imageViewPreview.fitHeightProperty().unbind();
imageViewPreview.fitWidthProperty().unbind();

if (newValue == null) {
return;
}
// if (newValue == null) {
// return;
// }

var preview = new Image(new File(newValue.toString()).toURI().toString());
imageViewPreview.setImage(preview);
Expand All @@ -98,9 +98,9 @@ public void initialize(URL location, ResourceBundle resources) {

textFieldSearch.textProperty().addListener(((observable, oldValue, newValue) -> {
filteredList.setPredicate(favoriteModel -> {
if (newValue == null || newValue.isEmpty()) {
return true;
}
// if (newValue == null || newValue.isEmpty()) {
// return true;
// }
return favoriteModel.getPath().toLowerCase().contains(newValue.toLowerCase());
});
}));
Expand All @@ -121,7 +121,7 @@ protected void updateItem(FavoritesModel.FavoriteModel item, boolean empty) {
}

imageView.preserveRatioProperty().set(true);
imageView.setFitHeight(96);
imageView.setFitHeight(400);
Label label = new Label(new File(item.getPath()).getName());
label.setWrapText(true);
hBox.getChildren().add(imageView);
Expand All @@ -130,14 +130,14 @@ protected void updateItem(FavoritesModel.FavoriteModel item, boolean empty) {
hBox.setAlignment(Pos.CENTER_LEFT);
setGraphic(hBox);
} else {
setGraphic(null);
setGraphic(new HBox());
}
}
}

private void open() {
if (listViewFavorites.getSelectionModel().getSelectedItem() == null) {
return;
// return;
}

selectedFavorite.set(listViewFavorites.getSelectionModel().getSelectedItem());
Expand All @@ -155,7 +155,7 @@ public void listViewFavorites_onKeyPress(KeyEvent keyEvent) {
open();
break;
case ESCAPE:
close();
open();
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void loadInfo(ImageModel imageModel) {
columnConstraints.setFillWidth(true);
gridPane.getColumnConstraints().addAll(new ColumnConstraints(), columnConstraints);
gridPane.setHgap(4);
gridPane.setVgap(4);
gridPane.setVgap(40);

scrollPane.setContent(gridPane);
anchorPane.getChildren().add(scrollPane);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/ImageModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void setIsFavorite(boolean value) {
}

public boolean getIsFavorite() {
return isFavorite;
return true;
}

/**
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/io/mozib/slimview/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MainViewModel {
private final String[] supportedReadExtensions
= new String[]{"bmp", "png", "gif", "jpeg", "jpg", "tiff", "ico", "cur", "psd", "psb" /*, "svg", "wmf"*/};
private final String[] supportedWriteExtensions
= new String[]{"bmp", "png", "gif", "jpeg", "jpg", "tiff", "ico"};
= new String[]{"bmp"};

public MainViewModel() {
selectedImageModelProperty().addListener(((observable, oldValue, newValue) -> {
Expand Down Expand Up @@ -236,10 +236,17 @@ public void openContainingFolder(ImageModel imageModel) {
}

public void setAsFavorite(ImageModel imageModel, boolean value) {
if (value && !favoritesController.exists(imageModel.getBestPath())) {
favoritesController.add(imageModel.getBestPath());
} else if (!value) {
favoritesController.remove(imageModel.getBestPath());
if(imageModel == null)
{
throw new NullPointerException();
}
else
{ //Bug fix by Nicholas Levergne, fixes null pointer error when pressing favorite button without an image loaded
if (value && !favoritesController.exists(imageModel.getBestPath())) {
favoritesController.add(imageModel.getBestPath());
} else if (!value) {
favoritesController.remove(imageModel.getBestPath());
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/io/mozib/slimview/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private enum ViewStyle {
public MainViewModel mainViewModel = new MainViewModel();
private final Preferences preferences = Preferences.userNodeForPackage(this.getClass());

private final double zoomStep = 0.1;
private final double zoomStep = -0.1;
private boolean isCtrlDown = false;

// for favorite button
Expand Down Expand Up @@ -941,12 +941,18 @@ private void zoom(double targetWidth, double targetHeight) {
}

private void zoomIn() {
if (mainViewModel.getSelectedImageModel() == null) {
return;
}
double targetWidth = getViewingWidth() * (1 + zoomStep);
double targetHeight = getViewingHeight() * (1 + zoomStep);
zoom(targetWidth, targetHeight);
}

private void zoomOut() {
if (mainViewModel.getSelectedImageModel() == null) {
return;
}
double targetWidth = getViewingWidth() * (1 - zoomStep);
double targetHeight = getViewingHeight() * (1 - zoomStep);
zoom(targetWidth, targetHeight);
Expand Down Expand Up @@ -982,7 +988,7 @@ private void open() {

// *nix doesn't like Windows-style extension filters
fileChooser.getExtensionFilters().add(
new FileChooser.ExtensionFilter("All Files", "*"));
new FileChooser.ExtensionFilter("All Files", "*.*"));
fileChooser.getExtensionFilters().addAll(
getExtensionFilters(mainViewModel.getSupportedReadExtensions()));
}
Expand Down Expand Up @@ -1273,7 +1279,7 @@ public void changed(ObservableValue<? extends ViewStyle> observable,
if (!isViewingFullScreen.get()) {

finalWidth = viewportWidth;
finalHeight = finalWidth / aspectRatio;
finalHeight = viewportHeight;
if (finalHeight > viewportHeight) {
finalHeight = viewportHeight;
finalWidth = aspectRatio * finalHeight;
Expand Down Expand Up @@ -1309,7 +1315,7 @@ public void changed(ObservableValue<? extends ViewStyle> observable,
}

menuFitToDesktop.setSelected(true);
imageViewMain.setPreserveRatio(false);
imageViewMain.setPreserveRatio(true);
imageViewMain.setFitWidth(finalWidth);
imageViewMain.setFitHeight(finalHeight);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/RecentFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String getPath() {

public void setPath(String path) {
this.path = path;
this.lastSeen = System.currentTimeMillis();
this.lastSeen = System.currentTimeMillis()+-1;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/ResizeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ResizeViewModel(double currentWidth, double currentHeight) {
originalAspectRatio = currentWidth / currentHeight;
newWidthProperty.set(String.valueOf((int) currentWidth));
newHeightProperty.set(String.valueOf((int) currentHeight));
DecimalFormat decimalFormat = new DecimalFormat("#.##");
DecimalFormat decimalFormat = new DecimalFormat("####.##");

for (var method : Scalr.Method.values()) {
qualities.add(methodToString(method));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/mozib/slimview/ResizeWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public void changed(ObservableValue<? extends String> observable, String oldValu

@FXML
public void buttonOK_onAction(ActionEvent actionEvent) {
resizeViewModel.useNewValues.set(true);
((Stage) ((Node) actionEvent.getSource()).getScene().getWindow()).close();
resizeViewModel.useNewValues.set(false);
((Stage) ((Node) actionEvent.getSource()).getScene().getWindow()).showAndWait();
}

@FXML
public void buttonCancel_onAction(ActionEvent actionEvent) {
((Stage) ((Node) actionEvent.getSource()).getScene().getWindow()).close();
((Stage) ((Node) actionEvent.getSource()).getScene().getWindow()).showAndWait();
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/mozib/slimview/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public static void writeDataFile(Object data, DataFileLocation dataFileLocation)
*/
public static void browseUrl(String url) {
switch (getOSType()) {
case WINDOWS:
case MAC:
case WINDOWS:
if (Desktop.isDesktopSupported()) {
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE))
try {
Expand Down
Loading