diff --git a/client/src/main/java/envoy/client/ui/SceneContext.java b/client/src/main/java/envoy/client/ui/SceneContext.java index 2d693af..083333a 100644 --- a/client/src/main/java/envoy/client/ui/SceneContext.java +++ b/client/src/main/java/envoy/client/ui/SceneContext.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.scene.*; +import javafx.scene.input.*; import javafx.stage.Stage; import envoy.client.data.Settings; @@ -105,6 +106,17 @@ public final class SceneContext implements EventListener { sceneStack.push(scene); stage.setScene(scene); + + // Adding the option to exit Linux-like with "Control" + "Q" + scene.getAccelerators() + .put(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), + () -> { + // Presumably no Settings are loaded in the login scene, hence Envoy is closed + // directly + if (sceneInfo != SceneInfo.LOGIN_SCENE && settings.isHideOnClose()) stage.setIconified(true); + else System.exit(0); + }); + // The LoginScene is the only scene not intended to be resized // As strange as it seems, this is needed as otherwise the LoginScene won't be // displayed on some OS (...Debian...) diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index 90e4499..f53d474 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -67,7 +67,7 @@ public final class Startup extends Application { // Initialize the local database try { - File localDBDir = new File(config.getHomeDirectory(), config.getLocalDB().getPath()); + final var localDBDir = new File(config.getHomeDirectory(), config.getLocalDB().getPath()); logger.info("Initializing LocalDB at " + localDBDir); localDB = new LocalDB(localDBDir); localDB.lock(); @@ -99,11 +99,9 @@ public final class Startup extends Application { if (!performHandshake( LoginCredentials.loginWithToken(localDB.getUser().getName(), localDB.getAuthToken(), VERSION, localDB.getLastSync()))) sceneContext.load(SceneInfo.LOGIN_SCENE); - } else { - + } else // Load login scene sceneContext.load(SceneInfo.LOGIN_SCENE); - } } /** @@ -126,9 +124,7 @@ public final class Startup extends Application { loadChatScene(); client.initReceiver(localDB, cacheMap); return true; - } else { - return false; - } + } else return false; } catch (IOException | InterruptedException | TimeoutException e) { logger.log(Level.INFO, "Could not connect to server. Entering offline mode..."); return attemptOfflineMode(credentials.getIdentifier());