Skip to content

Commit

Permalink
Fix for issue 5463 (#5481)
Browse files Browse the repository at this point in the history
* Adopted dark mode for Entry Preview

* Adopted dark mode for Entry Preview

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Fix for issue 5463

* Replace magic string by ThemeLoader.DARK_CSS
  • Loading branch information
taerim25 authored and tobiasdiez committed Oct 20, 2019
1 parent 6d5612e commit 1bd9ff8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447)
- After successful import of one or multiple bib entries the main table scrolls to the first imported entry [#5383](https://github.com/JabRef/jabref/issues/5383)
- We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452)

- We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463)

### Removed

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@

-jr-tooltip-fg: derive(-fx-light-text-color, 50%);
}

#previewBody{
background-color: #272b38; /* -fx-control-inner-background*/
color : #7d8591; /* -fx-mid-text-color*/
}
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/preview/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public PreviewPanel(BibDatabaseContext database, DialogService dialogService, Ex
previewView = new PreviewViewer(database, dialogService, Globals.stateManager);
previewView.setLayout(previewPreferences.getCurrentPreviewStyle());
previewView.setContextMenu(createPopupMenu());
previewView.setTheme(this.preferences.get(JabRefPreferences.FX_THEME));
previewView.setOnDragDetected(event -> {
previewView.startFullDrag();

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/jabref/gui/preview/PreviewViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import org.jabref.Globals;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.gui.util.ThemeLoader;
import org.jabref.logic.citationstyle.PreviewLayout;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -112,6 +114,13 @@ public PreviewViewer(BibDatabaseContext database, DialogService dialogService, S

}

public void setTheme(String theme) {
if (theme.equals(ThemeLoader.DARK_CSS)) {
previewView.getEngine().setUserStyleSheetLocation(JabRefFrame.class.getResource(ThemeLoader.DARK_CSS).toString());
}

}

private void highlightSearchPattern() {
if (searchHighlightPattern.isPresent()) {
String pattern = searchHighlightPattern.get().pattern().replace("\\Q", "").replace("\\E", "");
Expand Down Expand Up @@ -175,7 +184,7 @@ private void update() {
}

private void setPreviewText(String text) {
String myText = "<html>" + JS_HIGHLIGHT_FUNCTION + "<body><div id=\"content\">" + text + "</div></body></html>";
String myText = "<html>" + JS_HIGHLIGHT_FUNCTION + "<body id=\"previewBody\"><div id=\"content\">" + text + "</div></body></html>";
previewView.getEngine().setJavaScriptEnabled(true);
previewView.getEngine().loadContent(myText);

Expand Down

0 comments on commit 1bd9ff8

Please sign in to comment.