Selaa lähdekoodia

Remove displayConfiguration from settings

Rexbas 1 vuosi sitten
vanhempi
commit
745d435a57

+ 0 - 4
src/main/java/org/cryptomator/common/settings/Settings.java

@@ -65,7 +65,6 @@ public class Settings {
 	public final IntegerProperty windowYPosition;
 	public final IntegerProperty windowWidth;
 	public final IntegerProperty windowHeight;
-	public final StringProperty displayConfiguration;
 	public final StringProperty language;
 	public final StringProperty mountService;
 	public final StringProperty lastUpdateCheck;
@@ -103,7 +102,6 @@ public class Settings {
 		this.windowYPosition = new SimpleIntegerProperty(this, "windowYPosition", json.windowYPosition);
 		this.windowWidth = new SimpleIntegerProperty(this, "windowWidth", json.windowWidth);
 		this.windowHeight = new SimpleIntegerProperty(this, "windowHeight", json.windowHeight);
-		this.displayConfiguration = new SimpleStringProperty(this, "displayConfiguration", json.displayConfiguration);
 		this.language = new SimpleStringProperty(this, "language", json.language);
 		this.mountService = new SimpleStringProperty(this, "mountService", json.mountService);
 		this.lastUpdateCheck = new SimpleStringProperty(this, "lastUpdateCheck", json.lastUpdateCheck);
@@ -131,7 +129,6 @@ public class Settings {
 		windowYPosition.addListener(this::somethingChanged);
 		windowWidth.addListener(this::somethingChanged);
 		windowHeight.addListener(this::somethingChanged);
-		displayConfiguration.addListener(this::somethingChanged);
 		language.addListener(this::somethingChanged);
 		mountService.addListener(this::somethingChanged);
 		lastUpdateCheck.addListener(this::somethingChanged);
@@ -186,7 +183,6 @@ public class Settings {
 		json.windowYPosition = windowYPosition.get();
 		json.windowWidth = windowWidth.get();
 		json.windowHeight = windowHeight.get();
-		json.displayConfiguration = displayConfiguration.get();
 		json.language = language.get();
 		json.mountService = mountService.get();
 		json.lastUpdateCheck = lastUpdateCheck.get();

+ 0 - 3
src/main/java/org/cryptomator/common/settings/SettingsJson.java

@@ -31,9 +31,6 @@ class SettingsJson {
 	@JsonProperty("theme")
 	UiTheme theme = Settings.DEFAULT_THEME;
 
-	@JsonProperty("displayConfiguration")
-	String displayConfiguration;
-
 	@JsonProperty("keychainProvider")
 	String keychainProvider = Settings.DEFAULT_KEYCHAIN_PROVIDER;
 

+ 5 - 39
src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java

@@ -6,7 +6,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanBinding;
 import javafx.collections.ObservableList;
 import javafx.fxml.FXML;
@@ -54,42 +53,20 @@ public class ResizeController implements FxController {
 	public void initialize() {
 		LOG.trace("init ResizeController");
 
-		if (neverTouched()) {
-			settings.displayConfiguration.set(getMonitorSizes());
-			return;
-		} else {
-			if (didDisplayConfigurationChange() || !isWithinDisplayBounds()) {
-				// If the position is illegal, then the window appears on the main screen in the middle of the window.
-				Rectangle2D primaryScreenBounds = Screen.getPrimary().getBounds();
-				window.setX((primaryScreenBounds.getWidth() - window.getMinWidth()) / 2);
-				window.setY((primaryScreenBounds.getHeight() - window.getMinHeight()) / 2);
-				window.setWidth(window.getMinWidth());
-				window.setHeight(window.getMinHeight());
-			} else {
-				window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight());
-				window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth());
-				window.setX(settings.windowXPosition.get());
-				window.setY(settings.windowYPosition.get());
-			}
+		if (!neverTouched()) {
+			window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight());
+			window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth());
+			window.setX(settings.windowXPosition.get());
+			window.setY(settings.windowYPosition.get());
 		}
 
 		window.setOnShowing(this::checkDisplayBounds);
-
-		savePositionalSettings();
 	}
 
 	private boolean neverTouched() {
 		return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0);
 	}
 
-	private boolean didDisplayConfigurationChange() {
-		String currentDisplayConfiguration = getMonitorSizes();
-		String settingsDisplayConfiguration = settings.displayConfiguration.get();
-		boolean configurationHasChanged = !settingsDisplayConfiguration.equals(currentDisplayConfiguration);
-		if (configurationHasChanged) settings.displayConfiguration.set(currentDisplayConfiguration);
-		return configurationHasChanged;
-	}
-
 	private boolean isWithinDisplayBounds() {
 		// (x1, y1) is the top left corner of the window, (x2, y2) is the bottom right corner
 		final double slack = 10;
@@ -131,17 +108,6 @@ public class ResizeController implements FxController {
 		}
 	}
 
-	private String getMonitorSizes() {
-		ObservableList<Screen> screens = Screen.getScreens();
-		StringBuilder sb = new StringBuilder();
-		for (int i = 0; i < screens.size(); i++) {
-			Rectangle2D screenBounds = screens.get(i).getBounds();
-			if (!sb.isEmpty()) sb.append(" ");
-			sb.append("displayId: " + i + ", " + screenBounds.getWidth() + "x" + screenBounds.getHeight() + ";");
-		}
-		return sb.toString();
-	}
-
 	private void startResize(MouseEvent evt) {
 		origX = window.getX();
 		origY = window.getY();