Add setting to diable thumbnail updates

This is a feature for people who have bandwidth / contingent restrictions.
It can also help keeping the CPU usage down.
This commit is contained in:
0xboobface 2018-11-20 14:35:06 +01:00
parent 2e9aa56985
commit 97d3be0b98
3 changed files with 25 additions and 12 deletions

View File

@ -67,6 +67,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private CheckBox secureCommunication = new CheckBox();
private CheckBox chooseStreamQuality = new CheckBox();
private CheckBox multiplePlayers = new CheckBox();
private CheckBox updateThumbnails = new CheckBox();
private RadioButton recordLocal;
private RadioButton recordRemote;
private ToggleGroup recordLocation;
@ -334,6 +335,14 @@ public class SettingsTab extends Tab implements TabSelectionListener {
GridPane.setMargin(chooseStreamQuality, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
layout.add(chooseStreamQuality, 1, row++);
l = new Label("Update thumbnails");
layout.add(l, 0, row);
updateThumbnails.setSelected(Config.getInstance().getSettings().updateThumbnails);
updateThumbnails.setOnAction((e) -> Config.getInstance().getSettings().updateThumbnails = updateThumbnails.isSelected());
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
GridPane.setMargin(updateThumbnails, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
layout.add(updateThumbnails, 1, row++);
l = new Label("Maximum resolution (0 = unlimited)");
layout.add(l, 0, row);
List<Integer> resolutionOptions = new ArrayList<>();

View File

@ -262,20 +262,23 @@ public class ThumbCell extends StackPane {
private void setImage(String url) {
if(!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
Image img = new Image(url, true);
boolean updateThumbs = Config.getInstance().getSettings().updateThumbnails;
if(updateThumbs || iv.getImage() == null) {
Image img = new Image(url, true);
// wait for the image to load, otherwise the ImageView replaces the current image with an "empty" image,
// which causes to show the grey background until the image is loaded
img.progressProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if(newValue.doubleValue() == 1.0) {
//imgAspectRatio = img.getHeight() / img.getWidth();
iv.setImage(img);
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
// wait for the image to load, otherwise the ImageView replaces the current image with an "empty" image,
// which causes to show the grey background until the image is loaded
img.progressProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if(newValue.doubleValue() == 1.0) {
//imgAspectRatio = img.getHeight() / img.getWidth();
iv.setImage(img);
setThumbWidth(Config.getInstance().getSettings().thumbWidth);
}
}
}
});
});
}
}
}

View File

@ -63,6 +63,7 @@ public class Settings {
public String proxyUser;
public String proxyPassword;
public int thumbWidth = 180;
public boolean updateThumbnails = true;
public int windowWidth = 1340;
public int windowHeight = 800;
public boolean windowMaximized = false;