Add Ability to Delete Messages Locally #70
@ -8,6 +8,7 @@ import javafx.scene.control.Alert.AlertType;
|
|||||||
import envoy.client.data.*;
|
import envoy.client.data.*;
|
||||||
import envoy.client.event.*;
|
import envoy.client.event.*;
|
||||||
import envoy.client.ui.SceneContext.SceneInfo;
|
import envoy.client.ui.SceneContext.SceneInfo;
|
||||||
|
import envoy.client.ui.StatusTrayIcon;
|
||||||
import envoy.util.EnvoyLog;
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
import dev.kske.eventbus.EventBus;
|
import dev.kske.eventbus.EventBus;
|
||||||
@ -24,12 +25,12 @@ public final class ShutdownHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Exits Envoy or minimizes it, depending on the current state of
|
* Exits Envoy or minimizes it, depending on the current state of
|
||||||
* {@link Settings#isHideOnClose()}.
|
* {@link Settings#isHideOnClose()} and {@link StatusTrayIcon#isSupported()}.
|
||||||
*
|
*
|
||||||
* @since Envoy Client v0.2-beta
|
* @since Envoy Client v0.2-beta
|
||||||
*/
|
*/
|
||||||
public static void exit() {
|
public static void exit() {
|
||||||
if (Settings.getInstance().isHideOnClose()) Context.getInstance().getStage().setIconified(true);
|
if (Settings.getInstance().isHideOnClose() && StatusTrayIcon.isSupported()) Context.getInstance().getStage().setIconified(true);
|
||||||
else {
|
else {
|
||||||
EventBus.getInstance().dispatch(new EnvoyCloseEvent());
|
EventBus.getInstance().dispatch(new EnvoyCloseEvent());
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
@ -105,17 +105,7 @@ public final class SceneContext implements EventListener {
|
|||||||
sceneStack.push(scene);
|
sceneStack.push(scene);
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
|
||||||
// Add the option to exit Linux-like with "Control" + "Q"
|
supplyKeyboardShortcuts(sceneInfo, scene);
|
||||||
scene.getAccelerators().put(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit);
|
|
||||||
|
|
||||||
// Add the option to logout using "Control"+"Shift"+"L" if not in login scene
|
|
||||||
if (sceneInfo != SceneInfo.LOGIN_SCENE) scene.getAccelerators()
|
|
||||||
.put(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), ShutdownHelper::logout);
|
|
||||||
|
|
||||||
// Add the option to open the settings scene with "Control"+"S", if being in
|
|
||||||
// chat scene
|
|
||||||
if (sceneInfo.equals(SceneInfo.CHAT_SCENE))
|
|
||||||
scene.getAccelerators().put(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN), () -> load(SceneInfo.SETTINGS_SCENE));
|
|
||||||
|
|
||||||
// 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
|
||||||
@ -130,6 +120,22 @@ public final class SceneContext implements EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void supplyKeyboardShortcuts(SceneInfo sceneInfo, final Scene scene) {
|
||||||
|
final var accelerators = scene.getAccelerators();
|
||||||
|
|
||||||
|
// Add the option to exit Linux-like with "Control" + "Q" or "Alt" + "F4"
|
||||||
|
accelerators.put(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit);
|
||||||
|
|
||||||
|
// Add the option to logout using "Control"+"Shift"+"L" if not in login scene
|
||||||
|
if (sceneInfo != SceneInfo.LOGIN_SCENE)
|
||||||
|
accelerators.put(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), ShutdownHelper::logout);
|
||||||
|
|
||||||
|
// Add the option to open the settings scene with "Control"+"S", if being in
|
||||||
|
// chat scene
|
||||||
|
if (sceneInfo == SceneInfo.CHAT_SCENE)
|
||||||
|
accelerators.put(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN), () -> load(SceneInfo.SETTINGS_SCENE));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the current scene and displays the previous one.
|
* Removes the current scene and displays the previous one.
|
||||||
*
|
*
|
||||||
|
@ -205,10 +205,11 @@ public final class Startup extends Application {
|
|||||||
context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE);
|
context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE);
|
||||||
stage.centerOnScreen();
|
stage.centerOnScreen();
|
||||||
|
|
||||||
if (StatusTrayIcon.isSupported()) {
|
// Exit or minimize the stage when a close request occurs
|
||||||
|
stage.setOnCloseRequest(
|
||||||
|
e -> { ShutdownHelper.exit(); if (Settings.getInstance().isHideOnClose() && StatusTrayIcon.isSupported()) e.consume(); });
|
||||||
|
|
||||||
// Exit or minimize the stage when a close request occurs
|
if (StatusTrayIcon.isSupported()) {
|
||||||
stage.setOnCloseRequest(e -> { ShutdownHelper.exit(); if (Settings.getInstance().isHideOnClose()) e.consume(); });
|
|
||||||
|
|
||||||
// Initialize status tray icon
|
// Initialize status tray icon
|
||||||
final var trayIcon = new StatusTrayIcon(stage);
|
final var trayIcon = new StatusTrayIcon(stage);
|
||||||
|
@ -5,6 +5,7 @@ import javafx.scene.control.*;
|
|||||||
import envoy.client.data.SettingsItem;
|
import envoy.client.data.SettingsItem;
|
||||||
import envoy.client.event.ThemeChangeEvent;
|
import envoy.client.event.ThemeChangeEvent;
|
||||||
import envoy.client.helper.ShutdownHelper;
|
import envoy.client.helper.ShutdownHelper;
|
||||||
|
import envoy.client.ui.StatusTrayIcon;
|
||||||
import envoy.data.User.UserStatus;
|
import envoy.data.User.UserStatus;
|
||||||
|
|
||||||
import dev.kske.eventbus.EventBus;
|
import dev.kske.eventbus.EventBus;
|
||||||
@ -22,13 +23,16 @@ public final class GeneralSettingsPane extends SettingsPane {
|
|||||||
super("General");
|
super("General");
|
||||||
setSpacing(10);
|
setSpacing(10);
|
||||||
|
|
||||||
// TODO: Support other value types
|
final var settingsItems = settings.getItems();
|
||||||
final var settingsItems = settings.getItems();
|
|
||||||
final var hideOnCloseCheckbox = new SettingsCheckbox((SettingsItem<Boolean>) settingsItems.get("hideOnClose"));
|
// Add hide on close if supported
|
||||||
final var hideOnCloseTooltip = new Tooltip("If selected, Envoy will still be present in the task bar when closed.");
|
if (StatusTrayIcon.isSupported()) {
|
||||||
hideOnCloseTooltip.setWrapText(true);
|
final var hideOnCloseCheckbox = new SettingsCheckbox((SettingsItem<Boolean>) settingsItems.get("hideOnClose"));
|
||||||
hideOnCloseCheckbox.setTooltip(hideOnCloseTooltip);
|
final var hideOnCloseTooltip = new Tooltip("If selected, Envoy will still be present in the task bar when closed.");
|
||||||
getChildren().add(hideOnCloseCheckbox);
|
hideOnCloseTooltip.setWrapText(true);
|
||||||
|
hideOnCloseCheckbox.setTooltip(hideOnCloseTooltip);
|
||||||
|
getChildren().add(hideOnCloseCheckbox);
|
||||||
|
}
|
||||||
|
|
||||||
final var enterToSendCheckbox = new SettingsCheckbox((SettingsItem<Boolean>) settingsItems.get("enterToSend"));
|
final var enterToSendCheckbox = new SettingsCheckbox((SettingsItem<Boolean>) settingsItems.get("enterToSend"));
|
||||||
final var enterToSendTooltip = new Tooltip(
|
final var enterToSendTooltip = new Tooltip(
|
||||||
|
Reference in New Issue
Block a user