Skip to content

Commit

Permalink
Fix font size preference not updating in preference dialog 8386 (#9287)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Nouri-Azari <u7285974@anu.edu.au>
  • Loading branch information
tomazari and u7285974 authored Nov 1, 2022
1 parent 4c4a6ac commit 0d7f855
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where hitting enter on the search field within the preferences dialog closed the dialog. [koppor#630](https://github.com/koppor/jabref/issues/630)
- We fixed a typo within a connection error message. [koppor#625](https://github.com/koppor/jabref/issues/625)
- We fixed an issue where the 'close dialog' key binding was not closing the Preferences dialog. [#8888](https://github.com/jabref/jabref/issues/8888)
- We fixed an issue where font size preferences did not apply correctly to preference dialog window and the menu bar. [#8386](https://github.com/JabRef/jabref/issues/8386) and [#9279](https://github.com/JabRef/jabref/issues/9279)
- We fixed an issue when using an unsafe character in the citation key, the auto-linking feature fails to link files. [#9267](https://github.com/JabRef/jabref/issues/9267)

### Removed
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/theme/ThemeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void updateFontStyle(Scene scene) {
if (appearancePreferences.shouldOverrideDefaultFontSize()) {
scene.getRoot().setStyle("-fx-font-size: " + appearancePreferences.getMainFontSize() + "pt;");
} else {
scene.getRoot().setStyle("");
scene.getRoot().setStyle("-fx-font-size: " + appearancePreferences.getDefaultFontSize() + "pt;");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
public class AppearancePreferences {
private final BooleanProperty shouldOverrideDefaultFontSize;
private final IntegerProperty mainFontSize;
private final IntegerProperty defaultFontSize;
private final ObjectProperty<Theme> theme;

public AppearancePreferences(boolean shouldOverrideDefaultFontSize, int mainFontSize, Theme theme) {
public AppearancePreferences(boolean shouldOverrideDefaultFontSize, int mainFontSize, int defaultFontSize, Theme theme) {
this.shouldOverrideDefaultFontSize = new SimpleBooleanProperty(shouldOverrideDefaultFontSize);
this.mainFontSize = new SimpleIntegerProperty(mainFontSize);
this.defaultFontSize = new SimpleIntegerProperty(defaultFontSize);
this.theme = new SimpleObjectProperty<>(theme);
}

Expand All @@ -36,6 +38,10 @@ public int getMainFontSize() {
return mainFontSize.get();
}

public int getDefaultFontSize() {
return defaultFontSize.get();
}

public void setMainFontSize(int mainFontSize) {
this.mainFontSize.set(mainFontSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,7 @@ public AppearancePreferences getAppearancePreferences() {
appearancePreferences = new AppearancePreferences(
getBoolean(OVERRIDE_DEFAULT_FONT_SIZE),
getInt(MAIN_FONT_SIZE),
(Integer) defaults.get(MAIN_FONT_SIZE),
new Theme(get(FX_THEME))
);

Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/jabref/gui/theme/ThemeManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void themeManagerUsesProvidedTheme() throws IOException {
Path testCss = tempFolder.resolve("test.css");
Files.writeString(testCss, TEST_CSS_CONTENT, StandardOpenOption.CREATE);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

ThemeManager themeManager = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);

Expand All @@ -73,7 +73,7 @@ public void customThemeAvailableEvenWhenDeleted() throws IOException {
Path testCss = tempFolder.resolve("test.css");
Files.writeString(testCss, TEST_CSS_CONTENT, StandardOpenOption.CREATE);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

// ActiveTheme should provide the additionalStylesheet that was created before
ThemeManager themeManagerCreatedBeforeFileDeleted = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);
Expand Down Expand Up @@ -101,7 +101,7 @@ public void customThemeAvailableEvenWhenDeleted() throws IOException {
public void customThemeBecomesAvailableAfterFileIsCreated() throws IOException {
Path testCss = tempFolder.resolve("test.css");
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

// ActiveTheme should provide no additionalStylesheet when no file exists
ThemeManager themeManagerCreatedBeforeFileExists = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);
Expand Down Expand Up @@ -132,7 +132,7 @@ public void largeCustomThemeNotHeldInMemory() throws IOException {
}
Files.writeString(largeCssTestFile, " */", StandardOpenOption.APPEND);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(largeCssTestFile.toString()));
new AppearancePreferences(false, 0, 0, new Theme(largeCssTestFile.toString()));

// ActiveTheme should provide the large additionalStylesheet that was created before
ThemeManager themeManager = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);
Expand Down Expand Up @@ -165,7 +165,7 @@ public void installThemeOnScene() throws IOException {
Path testCss = tempFolder.resolve("reload.css");
Files.writeString(testCss, TEST_CSS_CONTENT, StandardOpenOption.CREATE);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

ThemeManager themeManager = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);

Expand All @@ -180,7 +180,7 @@ public void installThemeOnWebEngine() throws IOException {
Path testCss = tempFolder.resolve("reload.css");
Files.writeString(testCss, TEST_CSS_CONTENT, StandardOpenOption.CREATE);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

ThemeManager themeManager = new ThemeManager(appearancePreferences, new DummyFileUpdateMonitor(), Runnable::run);

Expand Down Expand Up @@ -209,7 +209,7 @@ public void liveReloadCssDataUrl() throws IOException, InterruptedException {
Path testCss = tempFolder.resolve("reload.css");
Files.writeString(testCss, TEST_CSS_CONTENT, StandardOpenOption.CREATE);
AppearancePreferences appearancePreferences =
new AppearancePreferences(false, 0, new Theme(testCss.toString()));
new AppearancePreferences(false, 0, 0, new Theme(testCss.toString()));

final ThemeManager themeManager;

Expand Down

0 comments on commit 0d7f855

Please sign in to comment.