Added option to close Envoy Linux-like with "Control"+"Q"
This commit is contained in:
		@@ -7,6 +7,7 @@ import java.util.logging.Level;
 | 
				
			|||||||
import javafx.application.Platform;
 | 
					import javafx.application.Platform;
 | 
				
			||||||
import javafx.fxml.FXMLLoader;
 | 
					import javafx.fxml.FXMLLoader;
 | 
				
			||||||
import javafx.scene.*;
 | 
					import javafx.scene.*;
 | 
				
			||||||
 | 
					import javafx.scene.input.*;
 | 
				
			||||||
import javafx.stage.Stage;
 | 
					import javafx.stage.Stage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import envoy.client.data.Settings;
 | 
					import envoy.client.data.Settings;
 | 
				
			||||||
@@ -105,6 +106,17 @@ public final class SceneContext implements EventListener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			sceneStack.push(scene);
 | 
								sceneStack.push(scene);
 | 
				
			||||||
			stage.setScene(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
 | 
								// 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
 | 
								// As strange as it seems, this is needed as otherwise the LoginScene won't be
 | 
				
			||||||
			// displayed on some OS (...Debian...)
 | 
								// displayed on some OS (...Debian...)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,7 @@ public final class Startup extends Application {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// Initialize the local database
 | 
							// Initialize the local database
 | 
				
			||||||
		try {
 | 
							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);
 | 
								logger.info("Initializing LocalDB at " + localDBDir);
 | 
				
			||||||
			localDB = new LocalDB(localDBDir);
 | 
								localDB = new LocalDB(localDBDir);
 | 
				
			||||||
			localDB.lock();
 | 
								localDB.lock();
 | 
				
			||||||
@@ -99,12 +99,10 @@ public final class Startup extends Application {
 | 
				
			|||||||
			if (!performHandshake(
 | 
								if (!performHandshake(
 | 
				
			||||||
					LoginCredentials.loginWithToken(localDB.getUser().getName(), localDB.getAuthToken(), VERSION, localDB.getLastSync())))
 | 
										LoginCredentials.loginWithToken(localDB.getUser().getName(), localDB.getAuthToken(), VERSION, localDB.getLastSync())))
 | 
				
			||||||
				sceneContext.load(SceneInfo.LOGIN_SCENE);
 | 
									sceneContext.load(SceneInfo.LOGIN_SCENE);
 | 
				
			||||||
		} else {
 | 
							} else 
 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Load login scene
 | 
								// Load login scene
 | 
				
			||||||
			sceneContext.load(SceneInfo.LOGIN_SCENE);
 | 
								sceneContext.load(SceneInfo.LOGIN_SCENE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Tries to perform a Handshake with the server.
 | 
						 * Tries to perform a Handshake with the server.
 | 
				
			||||||
@@ -126,9 +124,7 @@ public final class Startup extends Application {
 | 
				
			|||||||
				loadChatScene();
 | 
									loadChatScene();
 | 
				
			||||||
				client.initReceiver(localDB, cacheMap);
 | 
									client.initReceiver(localDB, cacheMap);
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			} else {
 | 
								} else return false;
 | 
				
			||||||
				return false;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} catch (IOException | InterruptedException | TimeoutException e) {
 | 
							} catch (IOException | InterruptedException | TimeoutException e) {
 | 
				
			||||||
			logger.log(Level.INFO, "Could not connect to server. Entering offline mode...");
 | 
								logger.log(Level.INFO, "Could not connect to server. Entering offline mode...");
 | 
				
			||||||
			return attemptOfflineMode(credentials.getIdentifier());
 | 
								return attemptOfflineMode(credentials.getIdentifier());
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user