Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferences ui cleanup B #9866

Merged
merged 37 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cf5f82b
Introduced library preferences tab
calixtus May 8, 2023
d555ffa
Moved language setting to AppearanceTab
calixtus May 9, 2023
75e551a
Changed theme radio buttons to combobox
calixtus May 9, 2023
0d5f846
Moved four settings to AppearanceTab
calixtus May 9, 2023
c1bf900
Removed GeneralTab, moved memory stick button to prefs toolbar
calixtus May 9, 2023
949bff2
Moved default library to EntryTab
calixtus May 9, 2023
ea38b9b
Moved telemetry prefs to AppearanceTab
calixtus May 9, 2023
6cf3d9d
Moved default library to LibraryTab
calixtus May 9, 2023
6dd2c76
Fixed AppearancePreferences
calixtus May 9, 2023
7ea1fdc
Moved memory stick mode to InternalPreferences
calixtus May 9, 2023
70571ba
Moved language to AppearancePreferences
calixtus May 9, 2023
c889560
Renamed GeneralPreferences to LibraryPreferences, moved reformatting …
calixtus May 9, 2023
adf7cdb
Fixed ui
calixtus May 9, 2023
4ce19e4
CHANGELOG.md
calixtus May 9, 2023
137710a
Fixed backup branch merge conflicts
calixtus May 9, 2023
455edf5
Fixed backup branch merge conflicts
calixtus May 9, 2023
5cd19df
Fixed checkstyle
calixtus May 9, 2023
8cf533a
Reworded getGeneralPreferences
calixtus May 9, 2023
0b69aa4
Fixed ThemeManagerTest
calixtus May 9, 2023
8332684
Polished KeyBindingsTab
calixtus May 10, 2023
8106f87
Added missing symbols in CustomImporter/ExporterTab
calixtus May 10, 2023
cbc76f0
Added small border to combobox popups
calixtus May 10, 2023
f857059
Merge remote-tracking branch 'upstream/main' into library_prefs
calixtus May 10, 2023
47e4ef1
CHANGELOG.md
calixtus May 10, 2023
e178ef4
l10n
calixtus May 10, 2023
cb02a2e
Merge remote-tracking branch 'upstream/main' into library_prefs
calixtus May 10, 2023
4a54aa0
Reworded AppearanceTab to WorkspaceTab
calixtus May 10, 2023
aabf62d
Reworded AppearanceTab to WorkspaceTab
calixtus May 10, 2023
c0e52fe
Merged WorkspaceTab and LibraryTab
calixtus May 10, 2023
bc5c4fc
Moved Autocompletion to new tab and moved Custom tab editor to EntryE…
calixtus May 10, 2023
cb5ce9f
CHANGELOG.md
calixtus May 10, 2023
d81d37f
Merge branch 'main' into library_prefs
koppor May 12, 2023
beb59e2
Readded Hint on 9839
koppor May 12, 2023
e488e3b
Merge branch 'main' into library_prefs
calixtus May 15, 2023
57b0649
Renamed workspace tab back to general tab
calixtus May 15, 2023
df6e42f
Update Javadoc
calixtus May 15, 2023
baf2947
Merge branch 'main' into library_prefs
calixtus May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reworded AppearanceTab to WorkspaceTab
  • Loading branch information
calixtus committed May 10, 2023
commit aabf62de8b0e067a7b14bd3b57b85bb06f96b9b7
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static synchronized ClipBoardManager getClipboardManager() {
public static synchronized ThemeManager getThemeManager() {
if (themeManager == null) {
themeManager = new ThemeManager(
prefs.getAppearancePreferences(),
prefs.getWorkspacePreferences(),
getFileUpdateMonitor(),
Runnable::run);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public void about() {
* set to true
*/
private void tearDownJabRef(List<String> filenames) {
if (prefs.getAppearancePreferences().shouldOpenLastEdited()) {
if (prefs.getWorkspacePreferences().shouldOpenLastEdited()) {
// Here we store the names of all current files. If there is no current file, we remove any
// previously stored filename.
if (filenames.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void openWindow(Stage mainStage) {

private void openDatabases() {
// If the option is enabled, open the last edited libraries, if any.
if (!isBlank && preferencesService.getAppearancePreferences().shouldOpenLastEdited()) {
if (!isBlank && preferencesService.getWorkspacePreferences().shouldOpenLastEdited()) {
openLastEditedDatabases();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ public BibDatabase getDatabase() {
}

private boolean showDeleteConfirmationDialog(int numberOfEntries) {
if (preferencesService.getAppearancePreferences().shouldConfirmDelete()) {
if (preferencesService.getWorkspacePreferences().shouldConfirmDelete()) {
String title = Localization.lang("Delete entry");
String message = Localization.lang("Really delete the selected entry?");
String okButton = Localization.lang("Delete entry");
Expand All @@ -685,7 +685,7 @@ private boolean showDeleteConfirmationDialog(int numberOfEntries) {
okButton,
cancelButton,
Localization.lang("Do not ask again"),
optOut -> preferencesService.getAppearancePreferences().setConfirmDelete(!optOut));
optOut -> preferencesService.getWorkspacePreferences().setConfirmDelete(!optOut));
} else {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext,
this.entryTypesManager = entryTypesManager;

setText(Localization.lang("Deprecated fields"));
EasyBind.subscribe(preferences.getAppearancePreferences().showAdvancedHintsProperty(), advancedHints -> {
EasyBind.subscribe(preferences.getWorkspacePreferences().showAdvancedHintsProperty(), advancedHints -> {
if (advancedHints) {
setTooltip(new Tooltip(Localization.lang("Shows fields having a successor in biblatex.\nFor instance, the publication month should be part of the date field.\nUse the Cleanup Entries functionality to convert the entry to biblatex.")));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private StackPane getRelatedArticlesPane(BibEntry entry) {
ProgressIndicator progress = new ProgressIndicator();
progress.setMaxSize(100, 100);

MrDLibFetcher fetcher = new MrDLibFetcher(preferencesService.getAppearancePreferences().getLanguage().name(),
MrDLibFetcher fetcher = new MrDLibFetcher(preferencesService.getWorkspacePreferences().getLanguage().name(),
Globals.BUILD_INFO.version, preferencesService.getMrDlibPreferences());
BackgroundTask
.wrap(() -> fetcher.performSearch(entry))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private StackPane createNumberCell(GroupNodeViewModel group) {

text.styleProperty().bind(Bindings.createStringBinding(() -> {
double reducedFontSize;
double font_size = preferencesService.getAppearancePreferences().getMainFontSize();
double font_size = preferencesService.getWorkspacePreferences().getMainFontSize();
// For each breaking point, the font size is reduced 0.20 em to fix issue 8797
if (font_size > 26.0) {
reducedFontSize = 0.25;
Expand All @@ -301,7 +301,7 @@ private StackPane createNumberCell(GroupNodeViewModel group) {
reducedFontSize = 0.75;
}
return String.format("-fx-font-size: %fem;", reducedFontSize);
}, preferencesService.getAppearancePreferences().mainFontSizeProperty()));
}, preferencesService.getWorkspacePreferences().mainFontSizeProperty()));

node.getChildren().add(text);
node.setMaxWidth(Control.USE_PREF_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@
<ColumnConstraints hgrow="SOMETIMES" percentWidth="30.0"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>

<Label styleClass="sectionHeader" text="%Appearance"
GridPane.rowIndex="0" GridPane.columnIndex="0" GridPane.columnSpan="2"/>
<Label text="%Language"
GridPane.columnIndex="0" GridPane.columnSpan="2"/>
GridPane.rowIndex="1" GridPane.columnIndex="0"/>
<ComboBox fx:id="language" prefWidth="200.0"
GridPane.rowIndex="0" GridPane.columnIndex="1"/>
GridPane.rowIndex="1" GridPane.columnIndex="1"/>

<Label text="%Visual theme"
GridPane.rowIndex="1" GridPane.columnIndex="0"/>
GridPane.rowIndex="2" GridPane.columnIndex="0"/>
<ComboBox fx:id="theme" prefWidth="200.0"
GridPane.rowIndex="1" GridPane.columnIndex="1"/>
GridPane.rowIndex="2" GridPane.columnIndex="1"/>
<HBox alignment="CENTER_LEFT" spacing="4.0"
GridPane.rowIndex="2" GridPane.columnIndex="0" GridPane.columnSpan="2">
GridPane.rowIndex="3" GridPane.columnIndex="0" GridPane.columnSpan="2">
<TextField fx:id="customThemePath" HBox.hgrow="ALWAYS"/>
<Button fx:id="customThemeBrowse" onAction="#importTheme" styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0">
<graphic>
Expand All @@ -49,14 +50,15 @@
</HBox>

<CheckBox fx:id="fontOverride" text="%Override default font settings"
GridPane.rowIndex="3" GridPane.columnIndex="0"/>
GridPane.rowIndex="4" GridPane.columnIndex="0"/>
<HBox alignment="CENTER_LEFT" spacing="4.0" disable="${!fontOverride.selected}"
GridPane.rowIndex="3" GridPane.columnIndex="1">
GridPane.rowIndex="4" GridPane.columnIndex="1">
<Label text="%Size"/>
<Spinner fx:id="fontSize" styleClass="fontsizeSpinner" editable="true"/>
</HBox>
</GridPane>

<Label styleClass="sectionHeader" text="%User interface"/>
<CheckBox fx:id="openLastStartup" text="%Open last edited libraries on startup"/>
<CheckBox fx:id="showAdvancedHints"
text="%Show advanced hints (i.e. helpful tooltips, suggestions and explanation)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.AppearancePreferences;
import org.jabref.preferences.PreferencesService;
import org.jabref.preferences.TelemetryPreferences;
import org.jabref.preferences.WorkspacePreferences;

import de.saxsys.mvvmfx.utils.validation.CompositeValidator;
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
Expand Down Expand Up @@ -73,7 +73,7 @@ public String getDisplayName() {

private final DialogService dialogService;
private final PreferencesService preferences;
private final AppearancePreferences appearancePreferences;
private final WorkspacePreferences workspacePreferences;
private final TelemetryPreferences telemetryPreferences;

private final Validator fontSizeValidator;
Expand All @@ -84,7 +84,7 @@ public String getDisplayName() {
public WorkspaceTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
this.appearancePreferences = preferences.getAppearancePreferences();
this.workspacePreferences = preferences.getWorkspacePreferences();
this.telemetryPreferences = preferences.getTelemetryPreferences();

fontSizeValidator = new FunctionBasedValidator<>(
Expand Down Expand Up @@ -112,52 +112,52 @@ public WorkspaceTabViewModel(DialogService dialogService, PreferencesService pre

@Override
public void setValues() {
selectedLanguageProperty.setValue(appearancePreferences.getLanguage());
selectedLanguageProperty.setValue(workspacePreferences.getLanguage());

// The light theme is in fact the absence of any theme modifying 'base.css'. Another embedded theme like
// 'dark.css', stored in the classpath, can be introduced in {@link org.jabref.gui.theme.Theme}.
switch (appearancePreferences.getTheme().getType()) {
switch (workspacePreferences.getTheme().getType()) {
case DEFAULT -> selectedThemeProperty.setValue(ThemeTypes.LIGHT);
case EMBEDDED -> selectedThemeProperty.setValue(ThemeTypes.DARK);
case CUSTOM -> {
selectedThemeProperty.setValue(ThemeTypes.CUSTOM);
customPathToThemeProperty.setValue(appearancePreferences.getTheme().getName());
customPathToThemeProperty.setValue(workspacePreferences.getTheme().getName());
}
}

fontOverrideProperty.setValue(appearancePreferences.shouldOverrideDefaultFontSize());
fontSizeProperty.setValue(String.valueOf(appearancePreferences.getMainFontSize()));
fontOverrideProperty.setValue(workspacePreferences.shouldOverrideDefaultFontSize());
fontSizeProperty.setValue(String.valueOf(workspacePreferences.getMainFontSize()));

openLastStartupProperty.setValue(appearancePreferences.shouldOpenLastEdited());
showAdvancedHintsProperty.setValue(appearancePreferences.shouldShowAdvancedHints());
inspectionWarningDuplicateProperty.setValue(appearancePreferences.shouldWarnAboutDuplicatesInInspection());
confirmDeleteProperty.setValue(appearancePreferences.shouldConfirmDelete());
openLastStartupProperty.setValue(workspacePreferences.shouldOpenLastEdited());
showAdvancedHintsProperty.setValue(workspacePreferences.shouldShowAdvancedHints());
inspectionWarningDuplicateProperty.setValue(workspacePreferences.shouldWarnAboutDuplicatesInInspection());
confirmDeleteProperty.setValue(workspacePreferences.shouldConfirmDelete());

collectTelemetryProperty.setValue(telemetryPreferences.shouldCollectTelemetry());
}

@Override
public void storeSettings() {
Language newLanguage = selectedLanguageProperty.getValue();
if (newLanguage != appearancePreferences.getLanguage()) {
appearancePreferences.setLanguage(newLanguage);
if (newLanguage != workspacePreferences.getLanguage()) {
workspacePreferences.setLanguage(newLanguage);
Localization.setLanguage(newLanguage);
restartWarning.add(Localization.lang("Changed language") + ": " + newLanguage.getDisplayName());
}

appearancePreferences.setShouldOverrideDefaultFontSize(fontOverrideProperty.getValue());
appearancePreferences.setMainFontSize(Integer.parseInt(fontSizeProperty.getValue()));
workspacePreferences.setShouldOverrideDefaultFontSize(fontOverrideProperty.getValue());
workspacePreferences.setMainFontSize(Integer.parseInt(fontSizeProperty.getValue()));

switch (selectedThemeProperty.get()) {
case LIGHT -> appearancePreferences.setTheme(Theme.light());
case DARK -> appearancePreferences.setTheme(Theme.dark());
case CUSTOM -> appearancePreferences.setTheme(Theme.custom(customPathToThemeProperty.getValue()));
case LIGHT -> workspacePreferences.setTheme(Theme.light());
case DARK -> workspacePreferences.setTheme(Theme.dark());
case CUSTOM -> workspacePreferences.setTheme(Theme.custom(customPathToThemeProperty.getValue()));
}

appearancePreferences.setOpenLastEdited(openLastStartupProperty.getValue());
appearancePreferences.setShowAdvancedHints(showAdvancedHintsProperty.getValue());
appearancePreferences.setWarnAboutDuplicatesInInspection(inspectionWarningDuplicateProperty.getValue());
appearancePreferences.setConfirmDelete(confirmDeleteProperty.getValue());
workspacePreferences.setOpenLastEdited(openLastStartupProperty.getValue());
workspacePreferences.setShowAdvancedHints(showAdvancedHintsProperty.getValue());
workspacePreferences.setWarnAboutDuplicatesInInspection(inspectionWarningDuplicateProperty.getValue());
workspacePreferences.setConfirmDelete(confirmDeleteProperty.getValue());

telemetryPreferences.setCollectTelemetry(collectTelemetryProperty.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String getTabName() {
public void initialize() {
this.viewModel = new NetworkTabViewModel(dialogService, preferencesService);

remoteLabel.setVisible(preferencesService.getAppearancePreferences().shouldShowAdvancedHints());
remoteLabel.setVisible(preferencesService.getWorkspacePreferences().shouldShowAdvancedHints());
remoteServer.selectedProperty().bindBidirectional(viewModel.remoteServerProperty());
remotePort.textProperty().bindBidirectional(viewModel.remotePortProperty());
remotePort.disableProperty().bind(remoteServer.selectedProperty().not());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private void updateResults(int matched, TextFlow description, boolean grammarBas
}

private void setSearchFieldHintTooltip(TextFlow description) {
if (preferencesService.getAppearancePreferences().shouldShowAdvancedHints()) {
if (preferencesService.getWorkspacePreferences().shouldShowAdvancedHints()) {
String genericDescription = Localization.lang("Hint:\n\nTo search all fields for <b>Smith</b>, enter:\n<tt>smith</tt>\n\nTo search the field <b>author</b> for <b>Smith</b> and the field <b>title</b> for <b>electrical</b>, enter:\n<tt>author=Smith and title=electrical</tt>");
List<Text> genericDescriptionTexts = TooltipTextUtil.createTextsFromHtml(genericDescription);

Expand Down
30 changes: 15 additions & 15 deletions src/main/java/org/jabref/gui/theme/ThemeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.model.util.FileUpdateListener;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.AppearancePreferences;
import org.jabref.preferences.WorkspacePreferences;

import com.tobiasdiez.easybind.EasyBind;
import org.slf4j.Logger;
Expand All @@ -40,7 +40,7 @@ public class ThemeManager {

private static final Logger LOGGER = LoggerFactory.getLogger(ThemeManager.class);

private final AppearancePreferences appearancePreferences;
private final WorkspacePreferences workspacePreferences;
private final FileUpdateMonitor fileUpdateMonitor;
private final Consumer<Runnable> updateRunner;

Expand All @@ -50,28 +50,28 @@ public class ThemeManager {
private Scene mainWindowScene;
private final Set<WebEngine> webEngines = Collections.newSetFromMap(new WeakHashMap<>());

public ThemeManager(AppearancePreferences appearancePreferences,
public ThemeManager(WorkspacePreferences workspacePreferences,
FileUpdateMonitor fileUpdateMonitor,
Consumer<Runnable> updateRunner) {
this.appearancePreferences = Objects.requireNonNull(appearancePreferences);
this.workspacePreferences = Objects.requireNonNull(workspacePreferences);
this.fileUpdateMonitor = Objects.requireNonNull(fileUpdateMonitor);
this.updateRunner = Objects.requireNonNull(updateRunner);

this.baseStyleSheet = StyleSheet.create(Theme.BASE_CSS).get();
this.theme = appearancePreferences.getTheme();
this.theme = workspacePreferences.getTheme();

// Watching base CSS only works in development and test scenarios, where the build system exposes the CSS as a
// file (e.g. for Gradle run task it will be in build/resources/main/org/jabref/gui/Base.css)
addStylesheetToWatchlist(this.baseStyleSheet, this::baseCssLiveUpdate);
baseCssLiveUpdate();

EasyBind.subscribe(appearancePreferences.themeProperty(), theme -> updateThemeSettings());
EasyBind.subscribe(appearancePreferences.shouldOverrideDefaultFontSizeProperty(), should -> updateFontSettings());
EasyBind.subscribe(appearancePreferences.mainFontSizeProperty(), size -> updateFontSettings());
EasyBind.subscribe(workspacePreferences.themeProperty(), theme -> updateThemeSettings());
EasyBind.subscribe(workspacePreferences.shouldOverrideDefaultFontSizeProperty(), should -> updateFontSettings());
EasyBind.subscribe(workspacePreferences.mainFontSizeProperty(), size -> updateFontSettings());
}

private void updateThemeSettings() {
Theme newTheme = Objects.requireNonNull(appearancePreferences.getTheme());
Theme newTheme = Objects.requireNonNull(workspacePreferences.getTheme());

if (newTheme.equals(theme)) {
LOGGER.info("Not updating theme because it hasn't changed");
Expand Down Expand Up @@ -160,16 +160,16 @@ private void updateBaseCss() {
private void updateAdditionalCss() {
getMainWindowScene().ifPresent(scene -> scene.getStylesheets().setAll(List.of(
baseStyleSheet.getSceneStylesheet().toExternalForm(),
appearancePreferences.getTheme()
.getAdditionalStylesheet().map(styleSheet -> {
workspacePreferences.getTheme()
.getAdditionalStylesheet().map(styleSheet -> {
URL stylesheetUrl = styleSheet.getSceneStylesheet();
if (stylesheetUrl != null) {
return stylesheetUrl.toExternalForm();
} else {
return "";
}
})
.orElse("")
.orElse("")
)));
}

Expand Down Expand Up @@ -210,10 +210,10 @@ public void installCss(WebEngine webEngine) {
* @param scene is the scene, the font size should be applied to
*/
public void updateFontStyle(Scene scene) {
if (appearancePreferences.shouldOverrideDefaultFontSize()) {
scene.getRoot().setStyle("-fx-font-size: " + appearancePreferences.getMainFontSize() + "pt;");
if (workspacePreferences.shouldOverrideDefaultFontSize()) {
scene.getRoot().setStyle("-fx-font-size: " + workspacePreferences.getMainFontSize() + "pt;");
} else {
scene.getRoot().setStyle("-fx-font-size: " + appearancePreferences.getDefaultFontSize() + "pt;");
scene.getRoot().setStyle("-fx-font-size: " + workspacePreferences.getDefaultFontSize() + "pt;");
}
}

Expand Down
Loading