mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 18:21:26 +00:00
introduced functionality to center the unlock screen within the main application window
This commit is contained in:
@@ -11,6 +11,7 @@ import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.common.VaultService;
|
||||
import org.cryptomator.ui.fxapp.FxApplicationWindows;
|
||||
import org.cryptomator.ui.fxapp.PrimaryStage;
|
||||
import org.cryptomator.ui.keyloading.KeyLoadingStrategy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -21,6 +22,7 @@ import javafx.beans.property.ObjectProperty;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -33,6 +35,7 @@ public class UnlockWorkflow extends Task<Void> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UnlockWorkflow.class);
|
||||
|
||||
private final Stage mainWindow;
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final VaultService vaultService;
|
||||
@@ -44,7 +47,8 @@ public class UnlockWorkflow extends Task<Void> {
|
||||
private final ObjectProperty<IllegalMountPointException> illegalMountPointException;
|
||||
|
||||
@Inject
|
||||
UnlockWorkflow(@UnlockWindow Stage window, //
|
||||
UnlockWorkflow(@PrimaryStage Stage mainWindow, //
|
||||
@UnlockWindow Stage window, //
|
||||
@UnlockWindow Vault vault, //
|
||||
VaultService vaultService, //
|
||||
@FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy<Scene> successScene, //
|
||||
@@ -53,6 +57,7 @@ public class UnlockWorkflow extends Task<Void> {
|
||||
FxApplicationWindows appWindows, //
|
||||
@UnlockWindow KeyLoadingStrategy keyLoadingStrategy, //
|
||||
@UnlockWindow ObjectProperty<IllegalMountPointException> illegalMountPointException) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
this.vaultService = vaultService;
|
||||
@@ -99,6 +104,13 @@ public class UnlockWorkflow extends Task<Void> {
|
||||
appWindows.showErrorWindow(e, window, null);
|
||||
}
|
||||
|
||||
private void centerOnPrimaryStage(Window window){
|
||||
double centerXPosition = mainWindow.getX() + (mainWindow.getWidth() - window.getWidth()) / 2;
|
||||
double centerYPosition = mainWindow.getY() + (mainWindow.getHeight() - window.getHeight()) / 2;
|
||||
window.setX(centerXPosition);
|
||||
window.setY(centerYPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void succeeded() {
|
||||
LOG.info("Unlock of '{}' succeeded.", vault.getDisplayName());
|
||||
@@ -107,6 +119,7 @@ public class UnlockWorkflow extends Task<Void> {
|
||||
case ASK -> Platform.runLater(() -> {
|
||||
window.setScene(successScene.get());
|
||||
window.show();
|
||||
centerOnPrimaryStage(window);
|
||||
});
|
||||
case REVEAL -> {
|
||||
Platform.runLater(window::close);
|
||||
|
||||
Reference in New Issue
Block a user