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

The entry preview window does not load my customized visual theme #7068

Closed
1 task done
crystalfp opened this issue Nov 3, 2020 · 4 comments · Fixed by #7071
Closed
1 task done

The entry preview window does not load my customized visual theme #7068

crystalfp opened this issue Nov 3, 2020 · 4 comments · Fixed by #7071
Labels
entry-preview good first issue An issue intended for project-newcomers. Varies in difficulty. ui

Comments

@crystalfp
Copy link

JabRef 5.2--2020-10-15--13a80ba
Windows 10 10.0 amd64
Java 14.0.2

The entry preview window does not load my customized visual theme as the rest of the GUI. I loaded my customized visual theme (copy of the source Dark.css file) but was not able to change colors of the preview textarea to match the dark theme of the rest of the GUI. Instead selecting "Dark theme" from Options > Appearance correctly makes the background dark.

image

Steps to reproduce the behavior:

  1. From the source tree take the Dark.css file
  2. Open Options > Appearance and select this file as "Custom theme"
  3. Restart JabRef and double click on an entry. The preview textarea has a white background
  4. If you select instead "Dark theme" the background is correctly dark.

I suspect the problem is in file: jabref-master\src\main\java\org\jabref\gui\preview\PreviewViewer.java where I don’t see any reference to theme in JS_HIGHLIGHT_FUNCTION definition or in setPreviewText() function, so the #previewBody block in Dark.css has no effect.

@Siedlerchr
Copy link
Member

Siedlerchr commented Nov 3, 2020

The file is right, but the highlight function is only used for highlighting search results in the preview.
The real problem lies here. Should be enough to modify the condition

public void setTheme(Theme theme) {
if (theme.getType() == Theme.Type.DARK) {
// We need to load the css file manually, due to a bug in the jdk
// TODO: Remove this workaround as soon as https://github.com/openjdk/jfx/pull/22 is merged
URL url = JabRefFrame.class.getResource(theme.getPath().getFileName().toString());
String dataUrl = "data:text/css;charset=utf-8;base64," +
Base64.getEncoder().encodeToString(StringUtil.getResourceFileAsString(url).getBytes());
previewView.getEngine().setUserStyleSheetLocation(dataUrl);
}
}

@Siedlerchr Siedlerchr added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Nov 3, 2020
@crystalfp
Copy link
Author

Maybe simply adding a toggle "The custom theme is a dark theme" to pass the test if (theme.getType() == Theme.Type.DARK) { is sufficient.

@Siedlerchr
Copy link
Member

I would just change the condition and replace it with != Theme.Type.LIGHT

@crystalfp
Copy link
Author

Eagerly waiting for this change. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
entry-preview good first issue An issue intended for project-newcomers. Varies in difficulty. ui
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants