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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
11 changes: 11 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,17 @@ 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%);
}
Expand Down
3 changes: 3 additions & 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,9 @@ private void onDatabaseLoadingFailed(Exception ex) {

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

new TabBarManager(tabPane, stateManager, preferences.getWorkspacePreferences());
priyanshu16095 marked this conversation as resolved.
Show resolved Hide resolved

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 {

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());
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
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 @@ -878,6 +878,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