Skip to content

Commit

Permalink
Fix fullscreen mode saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Jul 30, 2023
1 parent 3f4c35b commit 7f00f8f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/preferences/GuiPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> lastFilesOpened;
Expand All @@ -44,6 +45,7 @@ public GuiPreferences(double positionX,
double sizeX,
double sizeY,
boolean windowMaximised,
boolean windowFullScreen,
List<String> lastFilesOpened,
Path lastFocusedFile,
FileHistory fileHistory,
Expand All @@ -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);
Expand Down Expand Up @@ -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<String> getLastFilesOpened() {
return lastFilesOpened;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand All @@ -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<String>) change -> {
if (change.getList().isEmpty()) {
prefs.remove(LAST_EDITED);
Expand Down

0 comments on commit 7f00f8f

Please sign in to comment.