diff --git a/CHANGELOG.md b/CHANGELOG.md index be806d75cb28..bcc7ea5fe45a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - JabRef does not show finished background tasks in the status bar popup. [#11574](https://github.com/JabRef/jabref/pull/11574) - We enhanced the indexing speed. [#11502](https://github.com/JabRef/jabref/pull/11502) - ⚠️ Renamed command line parameters `embeddBibfileInPdf` to `embedBibFileInPdf`, `writeMetadatatoPdf` to `writeMetadataToPdf`, and `writeXMPtoPdf` to `writeXmpToPdf`. [#11575](https://github.com/JabRef/jabref/pull/11575) +- The browse button for a Custom theme now opens in the directory of the current used CSS file [#11597](https://github.com/JabRef/jabref/pull/11597) ### Fixed diff --git a/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java b/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java index 4690d33a0490..b622604c925f 100644 --- a/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java @@ -66,7 +66,8 @@ public class GeneralTabViewModel implements PreferenceTabViewModel { private final BooleanProperty themeSyncOsProperty = new SimpleBooleanProperty(); - private final StringProperty customPathToThemeProperty = new SimpleStringProperty(); + // init with empty string to avoid npe in accessing + private final StringProperty customPathToThemeProperty = new SimpleStringProperty(""); private final BooleanProperty fontOverrideProperty = new SimpleBooleanProperty(); private final StringProperty fontSizeProperty = new SimpleStringProperty(); @@ -334,10 +335,14 @@ public StringProperty customPathToThemeProperty() { } public void importCSSFile() { + + String fileDir = customPathToThemeProperty.getValue().isEmpty() ? preferences.getInternalPreferences().getLastPreferencesExportPath().toString() + : customPathToThemeProperty.getValue(); + FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() .addExtensionFilter(StandardFileType.CSS) .withDefaultExtension(StandardFileType.CSS) - .withInitialDirectory(preferences.getInternalPreferences().getLastPreferencesExportPath()).build(); + .withInitialDirectory(fileDir).build(); dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> customPathToThemeProperty.setValue(file.toAbsolutePath().toString()));