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

Hide tab bar #12395

Merged
merged 17 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a feature to hide the tab bar when only one library is open, restore it when multiple libraries are open. [#9971](https://github.com/JabRef/jabref/issues/9971)

### Changed

- We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278)
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,20 @@ TextFlow > .tooltip-text-monospaced {
-fx-padding: 0 0 0 0;
}

.tab-pane.hide-tab-bar .tab-header-area {
-fx-pref-height: 0;
visibility: hidden;
}

.tab-pane.hide-tab-bar .tab-header-area > .headers-region > .tab {
-fx-padding: 0;
-fx-border-width: 0;
-fx-pref-height: 0;
}

.numberColumn > .hits:any-selected {
-fx-background-color: derive(-jr-green, 70%);
}

.table-view,
.tree-table-view {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ private void onDatabaseLoadingFailed(Exception ex) {

private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
TabPane tabPane = this.getTabPane();

if (tabPane == null) {
LOGGER.debug("User interrupted loading. Not showing any library.");
return;
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/org/jabref/gui/TabBarManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.jabref.gui;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.ListChangeListener;
import javafx.scene.control.TabPane;

import org.jabref.gui.util.BindingsHelper;
import org.jabref.model.database.BibDatabaseContext;

public class TabBarManager {
priyanshu16095 marked this conversation as resolved.
Show resolved Hide resolved

private final TabPane tabPane;
private final StateManager stateManager;
private final WorkspacePreferences workspacePreferences;
private final IntegerProperty numberOfOpenDatabases;

public TabBarManager(TabPane tabPane,
StateManager stateManager,
WorkspacePreferences workspacePreferences) {
this.tabPane = tabPane;
this.stateManager = stateManager;
this.workspacePreferences = workspacePreferences;
this.numberOfOpenDatabases = new SimpleIntegerProperty();

stateManager.getOpenDatabases().addListener((ListChangeListener<BibDatabaseContext>) change -> {
this.numberOfOpenDatabases.set(stateManager.getOpenDatabases().size());
subhramit marked this conversation as resolved.
Show resolved Hide resolved
updateTabBarState();
});

BindingsHelper.subscribeFuture(workspacePreferences.confirmHideTabBarProperty(), hideTabBar -> updateTabBarState());
maintainInitialTabBarState(workspacePreferences.shouldHideTabBar());
}

public void updateTabBarState() {
if (workspacePreferences.shouldHideTabBar() && numberOfOpenDatabases.get() == 1) {
if (!tabPane.getStyleClass().contains("hide-tab-bar")) {
tabPane.getStyleClass().add("hide-tab-bar");
}
} else {
tabPane.getStyleClass().remove("hide-tab-bar");
}
}

public void maintainInitialTabBarState(boolean show) {
if (show) {
if (stateManager.getOpenDatabases().size() == 1) {
if (!tabPane.getStyleClass().contains("hide-tab-bar")) {
tabPane.getStyleClass().add("hide-tab-bar");
}
} else {
tabPane.getStyleClass().remove("hide-tab-bar");
}
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/WorkspacePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class WorkspacePreferences {
private final BooleanProperty showAdvancedHints;
private final BooleanProperty warnAboutDuplicatesInInspection;
private final BooleanProperty confirmDelete;
private final BooleanProperty confirmHideTabBar;
private final ObservableList<String> selectedSlrCatalogs;

public WorkspacePreferences(Language language,
Expand All @@ -37,6 +38,7 @@ public WorkspacePreferences(Language language,
boolean showAdvancedHints,
boolean warnAboutDuplicatesInInspection,
boolean confirmDelete,
boolean confirmHideTabBar,
List<String> selectedSlrCatalogs) {
this.language = new SimpleObjectProperty<>(language);
this.shouldOverrideDefaultFontSize = new SimpleBooleanProperty(shouldOverrideDefaultFontSize);
Expand All @@ -48,6 +50,7 @@ public WorkspacePreferences(Language language,
this.showAdvancedHints = new SimpleBooleanProperty(showAdvancedHints);
this.warnAboutDuplicatesInInspection = new SimpleBooleanProperty(warnAboutDuplicatesInInspection);
this.confirmDelete = new SimpleBooleanProperty(confirmDelete);
this.confirmHideTabBar = new SimpleBooleanProperty(confirmHideTabBar);
this.selectedSlrCatalogs = FXCollections.observableArrayList(selectedSlrCatalogs);
}

Expand Down Expand Up @@ -163,6 +166,18 @@ public void setConfirmDelete(boolean confirmDelete) {
this.confirmDelete.set(confirmDelete);
}

public boolean shouldHideTabBar() {
return confirmHideTabBar.get();
}

public BooleanProperty confirmHideTabBarProperty() {
return confirmHideTabBar;
}

public void setHideTabBar(boolean hideTabBar) {
this.confirmHideTabBar.set(hideTabBar);
}

public ObservableList<String> getSelectedSlrCatalogs() {
return selectedSlrCatalogs;
}
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jabref.gui.LibraryTab;
import org.jabref.gui.LibraryTabContainer;
import org.jabref.gui.StateManager;
import org.jabref.gui.TabBarManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
Expand Down Expand Up @@ -79,6 +80,7 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe
private final GuiPreferences preferences;
private final AiService aiService;
private final GlobalSearchBar globalSearchBar;
private final TabBarManager tabBarManager;

private final FileHistoryMenu fileHistory;

Expand Down Expand Up @@ -151,6 +153,8 @@ public JabRefFrame(Stage mainStage,
dialogService,
SearchType.NORMAL_SEARCH);

this.tabBarManager = new TabBarManager(tabbedPane, stateManager, preferences.getWorkspacePreferences());

this.sidePane = new SidePane(
this,
this.preferences,
Expand Down Expand Up @@ -461,7 +465,7 @@ private ContextMenu createTabContextMenuFor(LibraryTab tab) {

contextMenu.getItems().addAll(
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(tab::getBibDatabaseContext, stateManager)),
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(tab::getBibDatabaseContext)),
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(dialogService, stateManager, preferences, tab::getBibDatabaseContext)),
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(tab::getBibDatabaseContext, stateManager, preferences, dialogService)),
new SeparatorMenuItem(),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(this, tab, stateManager)),
Expand Down Expand Up @@ -632,11 +636,17 @@ public void execute() {
}
}

private class OpenDatabaseFolder extends SimpleCommand {
public static class OpenDatabaseFolder extends SimpleCommand {

private final Supplier<BibDatabaseContext> databaseContext;

public OpenDatabaseFolder(Supplier<BibDatabaseContext> databaseContext) {
private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;

public OpenDatabaseFolder(DialogService dialogService, StateManager stateManager, GuiPreferences preferences, Supplier<BibDatabaseContext> databaseContext) {
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.databaseContext = databaseContext;
this.executable.bind(needsSavedLocalDatabase(stateManager));
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ private void createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new JabRefFrame.OpenDatabaseFolder(dialogService, stateManager, preferences, () -> stateManager.getActiveDatabase().orElse(null))),
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(stateManager, preferences, dialogService)),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(stateManager))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
private static final String OVERRIDE_DEFAULT_FONT_SIZE = "overrideDefaultFontSize";
private static final String SHOW_ADVANCED_HINTS = "showAdvancedHints";
private static final String CONFIRM_DELETE = "confirmDelete";
private static final String CONFIRM_HIDE_TAB_BAR = "confirmHideTabBar";
// endregion

private static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeightFX";
Expand Down Expand Up @@ -266,6 +267,7 @@ private JabRefGuiPreferences() {
defaults.put(THEME, Theme.BASE_CSS);
defaults.put(THEME_SYNC_OS, Boolean.FALSE);
defaults.put(CONFIRM_DELETE, Boolean.TRUE);
defaults.put(CONFIRM_HIDE_TAB_BAR, Boolean.TRUE);
defaults.put(SHOW_ADVANCED_HINTS, Boolean.TRUE);
// endregion

Expand Down Expand Up @@ -633,6 +635,7 @@ public WorkspacePreferences getWorkspacePreferences() {
getBoolean(SHOW_ADVANCED_HINTS),
getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION),
getBoolean(CONFIRM_DELETE),
getBoolean(CONFIRM_HIDE_TAB_BAR),
getStringList(SELECTED_SLR_CATALOGS));

EasyBind.listen(workspacePreferences.languageProperty(), (obs, oldValue, newValue) -> {
Expand All @@ -651,6 +654,7 @@ public WorkspacePreferences getWorkspacePreferences() {
EasyBind.listen(workspacePreferences.showAdvancedHintsProperty(), (obs, oldValue, newValue) -> putBoolean(SHOW_ADVANCED_HINTS, newValue));
EasyBind.listen(workspacePreferences.warnAboutDuplicatesInInspectionProperty(), (obs, oldValue, newValue) -> putBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION, newValue));
EasyBind.listen(workspacePreferences.confirmDeleteProperty(), (obs, oldValue, newValue) -> putBoolean(CONFIRM_DELETE, newValue));
EasyBind.listen(workspacePreferences.confirmHideTabBarProperty(), (obs, oldValue, newValue) -> putBoolean(CONFIRM_HIDE_TAB_BAR, newValue));
workspacePreferences.getSelectedSlrCatalogs().addListener((ListChangeListener<String>) change ->
putStringList(SELECTED_SLR_CATALOGS, workspacePreferences.getSelectedSlrCatalogs()));
return workspacePreferences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
text="%Warn about unresolved duplicates when closing inspection window"/>

<CheckBox fx:id="confirmDelete" text="%Show confirmation dialog when deleting entries"/>
<CheckBox fx:id="confirmHideTabBar" text="%Hide tab bar when single library is present"/>

<Label styleClass="sectionHeader" text="%Single instance" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> i
@FXML private CheckBox inspectionWarningDuplicate;

@FXML private CheckBox confirmDelete;
@FXML private CheckBox confirmHideTabBar;
@FXML private ComboBox<BibDatabaseMode> biblatexMode;
@FXML private CheckBox alwaysReformatBib;
@FXML private CheckBox autosaveLocalLibraries;
Expand Down Expand Up @@ -119,6 +120,7 @@ public void initialize() {
showAdvancedHints.selectedProperty().bindBidirectional(viewModel.showAdvancedHintsProperty());
inspectionWarningDuplicate.selectedProperty().bindBidirectional(viewModel.inspectionWarningDuplicateProperty());
confirmDelete.selectedProperty().bindBidirectional(viewModel.confirmDeleteProperty());
confirmHideTabBar.selectedProperty().bindBidirectional(viewModel.confirmHideTabBarProperty());

new ViewModelListCellFactory<BibDatabaseMode>()
.withText(BibDatabaseMode::getFormattedName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class GeneralTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty showAdvancedHintsProperty = new SimpleBooleanProperty();
private final BooleanProperty inspectionWarningDuplicateProperty = new SimpleBooleanProperty();
private final BooleanProperty confirmDeleteProperty = new SimpleBooleanProperty();
private final BooleanProperty hideTabBarProperty = new SimpleBooleanProperty();

private final ListProperty<BibDatabaseMode> bibliographyModeListProperty = new SimpleListProperty<>();
private final ObjectProperty<BibDatabaseMode> selectedBiblatexModeProperty = new SimpleObjectProperty<>();
Expand Down Expand Up @@ -184,6 +185,7 @@ public void setValues() {
inspectionWarningDuplicateProperty.setValue(workspacePreferences.shouldWarnAboutDuplicatesInInspection());

confirmDeleteProperty.setValue(workspacePreferences.shouldConfirmDelete());
hideTabBarProperty.setValue(workspacePreferences.shouldHideTabBar());

bibliographyModeListProperty.setValue(FXCollections.observableArrayList(BibDatabaseMode.values()));
selectedBiblatexModeProperty.setValue(libraryPreferences.getDefaultBibDatabaseMode());
Expand Down Expand Up @@ -225,6 +227,7 @@ public void storeSettings() {
workspacePreferences.setWarnAboutDuplicatesInInspection(inspectionWarningDuplicateProperty.getValue());

workspacePreferences.setConfirmDelete(confirmDeleteProperty.getValue());
workspacePreferences.setHideTabBar(confirmHideTabBarProperty().getValue());

libraryPreferences.setDefaultBibDatabaseMode(selectedBiblatexModeProperty.getValue());

Expand Down Expand Up @@ -371,6 +374,10 @@ public BooleanProperty confirmDeleteProperty() {
return this.confirmDeleteProperty;
}

public BooleanProperty confirmHideTabBarProperty() {
return this.hideTabBarProperty;
}

public ListProperty<BibDatabaseMode> biblatexModeListProperty() {
return this.bibliographyModeListProperty;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ Attached\ files=Attached files
Show\ confirmation\ dialog\ when\ deleting\ entries=Show confirmation dialog when deleting entries
Show\ confirmation\ dialog\ when\ deleting\ attached\ files=Show confirmation dialog when deleting attached files

Hide\ tab\ bar\ when\ single\ library\ is\ present=Hide tab bar when single library is present

Persist\ password\ between\ sessions=Persist password between sessions

Persist\ api\ keys\ between\ sessions=Persist api keys between sessions
Expand Down
Loading