Use the selected thumb size on all tabs

This commit is contained in:
0xboobface 2018-10-22 18:22:26 +02:00
parent 0f39aa6fc0
commit 8e3d2fd565
2 changed files with 19 additions and 13 deletions

View File

@ -49,7 +49,6 @@ import javafx.util.Duration;
public class ThumbCell extends StackPane {
private static final transient Logger LOG = LoggerFactory.getLogger(ThumbCell.class);
public static int width = 180;
private static final Duration ANIMATION_DURATION = new Duration(250);
private Model model;
@ -171,7 +170,7 @@ public class ThumbCell extends StackPane {
resolutionTag.setVisible(true);
}
});
setThumbWidth(width);
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
setRecording(recording);
if(Config.getInstance().getSettings().determineResolution) {
@ -257,7 +256,7 @@ public class ThumbCell extends StackPane {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if(newValue.doubleValue() == 1.0) {
imgAspectRatio = img.getHeight() / img.getWidth();
setThumbWidth(width);
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
iv.setImage(img);
}
}

View File

@ -143,7 +143,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
restartUpdateService();
});
ThumbCell.width = Config.getInstance().getSettings().thumbWidth;
HBox thumbSizeSelector = new HBox(5);
Label l = new Label("Thumb Size");
l.setPadding(new Insets(5,0,0,0));
@ -155,18 +154,11 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
thumbWidths.add(270);
thumbWidths.add(360);
thumbWidth = new ComboBox<>(new ObservableListWrapper<>(thumbWidths));
thumbWidth.getSelectionModel().select(new Integer(ThumbCell.width));
thumbWidth.getSelectionModel().select(new Integer(Config.getInstance().getSettings().thumbWidth));
thumbWidth.setOnAction((e) -> {
int width = thumbWidth.getSelectionModel().getSelectedItem();
ThumbCell.width = width;
Config.getInstance().getSettings().thumbWidth = width;
for (Node node : grid.getChildren()) {
ThumbCell cell = (ThumbCell) node;
cell.setThumbWidth(width);
}
for (ThumbCell cell : filteredThumbCells) {
cell.setThumbWidth(width);
}
updateThumbSize();
});
thumbSizeSelector.getChildren().add(thumbWidth);
BorderPane.setMargin(thumbSizeSelector, new Insets(5));
@ -184,6 +176,20 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
setContent(root);
}
private void updateThumbSize() {
int width = Config.getInstance().getSettings().thumbWidth;
thumbWidth.getSelectionModel().select(new Integer(width));;
for (Node node : grid.getChildren()) {
if(node instanceof ThumbCell) {
ThumbCell cell = (ThumbCell) node;
cell.setThumbWidth(width);
}
}
for (ThumbCell cell : filteredThumbCells) {
cell.setThumbWidth(width);
}
}
private void handlePageNumberInput() {
try {
int page = Integer.parseInt(pageInput.getText());
@ -586,6 +592,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
updateService.restart();
}
}
updateThumbSize();
}
@Override