48 lines
1.5 KiB
Java
48 lines
1.5 KiB
Java
package envoy.client.data.shortcuts;
|
|
|
|
import javafx.scene.input.*;
|
|
|
|
import envoy.client.data.Context;
|
|
import envoy.client.helper.ShutdownHelper;
|
|
import envoy.client.ui.SceneContext.SceneInfo;
|
|
import envoy.client.util.UserUtil;
|
|
|
|
/**
|
|
* Envoy-specific implementation of the keyboard-shortcut interaction offered by
|
|
* {@link GlobalKeyShortcuts}.
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @since Envoy Client v0.3-beta
|
|
*/
|
|
public class EnvoyShortcutConfig {
|
|
|
|
private EnvoyShortcutConfig() {}
|
|
|
|
/**
|
|
* Supplies the default shortcuts for {@link GlobalKeyShortcuts}.
|
|
*
|
|
* @since Envoy Client v0.3-beta
|
|
*/
|
|
public static void initializeEnvoyShortcuts() {
|
|
final var instance = GlobalKeyShortcuts.getInstance();
|
|
|
|
// Add the option to exit with "Control" + "Q" or "Alt" + "F4" as offered by
|
|
// some desktop environments
|
|
instance.add(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN),
|
|
ShutdownHelper::exit);
|
|
|
|
// Add the option to logout using "Control"+"Shift"+"L" if not in login scene
|
|
instance.addForNotExcluded(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN,
|
|
KeyCombination.SHIFT_DOWN),
|
|
UserUtil::logout,
|
|
SceneInfo.LOGIN_SCENE);
|
|
|
|
// Add option to open settings scene with "Control"+"S", if not in login scene
|
|
instance.addForNotExcluded(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN),
|
|
() -> Context.getInstance().getSceneContext()
|
|
.load(SceneInfo.SETTINGS_SCENE),
|
|
SceneInfo.SETTINGS_SCENE,
|
|
SceneInfo.LOGIN_SCENE);
|
|
}
|
|
}
|