From 7f00f8f2f5d0fd47a718a61362187adf2e7f0bb0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 30 Jul 2023 22:30:23 +0200 Subject: [PATCH] Fix fullscreen mode saving --- src/main/java/org/jabref/gui/JabRefGUI.java | 5 +++++ .../org/jabref/preferences/GuiPreferences.java | 15 +++++++++++++++ .../org/jabref/preferences/JabRefPreferences.java | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 133df390b3f..4e5796916c0 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -112,6 +112,10 @@ private void openWindow(Stage mainStage) { mainStage.setMinHeight(330); mainStage.setMinWidth(580); + + if (guiPreferences.isWindowFullscreen()) { + mainStage.setFullScreen(true); + } // Restore window location and/or maximised state if (guiPreferences.isWindowMaximised()) { mainStage.setMaximized(true); @@ -271,6 +275,7 @@ private void saveWindowState(Stage mainStage) { preferences.setSizeX(mainStage.getWidth()); preferences.setSizeY(mainStage.getHeight()); preferences.setWindowMaximised(mainStage.isMaximized()); + preferences.setWindowFullScreen(mainStage.isFullScreen()); debugLogWindowState(mainStage); } diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index c868ba3d751..06a948741a1 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -24,6 +24,7 @@ public class GuiPreferences { private final DoubleProperty sizeY; private final BooleanProperty windowMaximised; + private final BooleanProperty windowFullScreen; // the last libraries that were open when jabref closes and should be reopened on startup private final ObservableList lastFilesOpened; @@ -44,6 +45,7 @@ public GuiPreferences(double positionX, double sizeX, double sizeY, boolean windowMaximised, + boolean windowFullScreen, List lastFilesOpened, Path lastFocusedFile, FileHistory fileHistory, @@ -59,6 +61,7 @@ public GuiPreferences(double positionX, this.sizeX = new SimpleDoubleProperty(sizeX); this.sizeY = new SimpleDoubleProperty(sizeY); this.windowMaximised = new SimpleBooleanProperty(windowMaximised); + this.windowFullScreen = new SimpleBooleanProperty(windowFullScreen); this.lastFilesOpened = FXCollections.observableArrayList(lastFilesOpened); this.lastFocusedFile = new SimpleObjectProperty<>(lastFocusedFile); this.lastSelectedIdBasedFetcher = new SimpleStringProperty(lastSelectedIdBasedFetcher); @@ -132,6 +135,18 @@ public void setWindowMaximised(boolean windowMaximised) { this.windowMaximised.set(windowMaximised); } + public BooleanProperty windowFullScreenProperty() { + return windowFullScreen; + } + + public void setWindowFullScreen(boolean windowFullScreen) { + this.windowFullScreen.set(windowFullScreen); + } + + public boolean isWindowFullscreen() { + return windowFullScreen.get(); + } + public ObservableList getLastFilesOpened() { return lastFilesOpened; } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index f34f530032b..cf240bbe896 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -158,6 +158,7 @@ public class JabRefPreferences implements PreferencesService { public static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeightFX"; public static final String AUTO_RESIZE_MODE = "autoResizeMode"; public static final String WINDOW_MAXIMISED = "windowMaximised"; + public static final String WINDOW_FULLSCREEN = "windowFullscreen"; public static final String REFORMAT_FILE_ON_SAVE_AND_EXPORT = "reformatFileOnSaveAndExport"; public static final String EXPORT_IN_ORIGINAL_ORDER = "exportInOriginalOrder"; @@ -555,6 +556,7 @@ private JabRefPreferences() { defaults.put(SIZE_X, 1024); defaults.put(SIZE_Y, 768); defaults.put(WINDOW_MAXIMISED, Boolean.TRUE); + defaults.put(WINDOW_FULLSCREEN, Boolean.FALSE); defaults.put(AUTO_RESIZE_MODE, Boolean.FALSE); // By default disable "Fit table horizontally on the screen" defaults.put(ENTRY_EDITOR_HEIGHT, 0.65); defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" @@ -2516,6 +2518,7 @@ public GuiPreferences getGuiPreferences() { getDouble(SIZE_X), getDouble(SIZE_Y), getBoolean(WINDOW_MAXIMISED), + getBoolean(WINDOW_FULLSCREEN), getStringList(LAST_EDITED), Path.of(get(LAST_FOCUSED)), getFileHistory(), @@ -2532,6 +2535,7 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeXProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_X, newValue.doubleValue())); EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); + EasyBind.listen(guiPreferences.windowFullScreenProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_FULLSCREEN, newValue)); guiPreferences.getLastFilesOpened().addListener((ListChangeListener) change -> { if (change.getList().isEmpty()) { prefs.remove(LAST_EDITED);