Skip to content

Commit

Permalink
Fix various Dark theme issues (#6368)
Browse files Browse the repository at this point in the history
* Fix various dark theme issues

* Reduce code duplication and pass the global objects as dependencies
  • Loading branch information
MootezSaaD authored Apr 28, 2020
1 parent b2682de commit cbf7796
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@
-jr-menu-item-foreground: -fx-light-text-color;
-jr-menu-forground-active: derive(-fx-light-text-color, 50%);

-jr-scrollbar-thumb: derive(-fx-outer-border, -30%);
-jr-scrollbar-thumb: -fx-light-text-color;
-jr-scrollbar-track: derive(-fx-control-inner-background, -90%);

-fx-focused-text-base-color: -fx-dark-text-color;

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

-jr-drag-target: -jr-accent;
-jr-drag-target-hover: -jr-accent;
}

#previewBody{
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.ThemeLoader;
import org.jabref.gui.util.ZipFileChooser;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;

import com.jfoenix.controls.JFXSnackbar;
import com.jfoenix.controls.JFXSnackbar.SnackbarEvent;
Expand All @@ -61,16 +63,22 @@ public class JabRefDialogService implements DialogService {

private static final Duration TOAST_MESSAGE_DISPLAY_TIME = Duration.millis(3000);
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefDialogService.class);
private static JabRefPreferences preferences;
private static ThemeLoader themeLoader;

private final Window mainWindow;
private final JFXSnackbar statusLine;

public JabRefDialogService(Window mainWindow, Pane mainPane) {
public JabRefDialogService(Window mainWindow, Pane mainPane, JabRefPreferences preferences, ThemeLoader themeLoader) {
this.mainWindow = mainWindow;
this.statusLine = new JFXSnackbar(mainPane);
this.preferences = preferences;
this.themeLoader = themeLoader;
}

private static FXDialog createDialog(AlertType type, String title, String content) {
FXDialog alert = new FXDialog(type, title, true);
themeLoader.installCss(alert.getDialogPane().getScene(), preferences);
alert.setHeaderText(null);
alert.setContentText(content);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
Expand Down Expand Up @@ -103,7 +111,7 @@ protected Node createDetailsButton() {

// Reset the dialog graphic using the default style
alert.getDialogPane().setGraphic(graphic);

themeLoader.installCss(alert.getDialogPane().getScene(), preferences);
alert.setHeaderText(null);
alert.setContentText(content);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
Expand All @@ -126,6 +134,7 @@ public <T> Optional<T> showChoiceDialogAndWait(String title, String content, Str
choiceDialog.setHeaderText(title);
choiceDialog.setTitle(title);
choiceDialog.setContentText(content);
themeLoader.installCss(choiceDialog.getDialogPane().getScene(), preferences);
return choiceDialog.showAndWait();
}

Expand All @@ -134,6 +143,7 @@ public Optional<String> showInputDialogAndWait(String title, String content) {
TextInputDialog inputDialog = new TextInputDialog();
inputDialog.setHeaderText(title);
inputDialog.setContentText(content);
themeLoader.installCss(inputDialog.getDialogPane().getScene(), preferences);
return inputDialog.showAndWait();
}

Expand All @@ -142,6 +152,7 @@ public Optional<String> showInputDialogWithDefaultAndWait(String title, String c
TextInputDialog inputDialog = new TextInputDialog(defaultValue);
inputDialog.setHeaderText(title);
inputDialog.setContentText(content);
themeLoader.installCss(inputDialog.getDialogPane().getScene(), preferences);
return inputDialog.showAndWait();
}

Expand All @@ -168,6 +179,7 @@ public void showErrorDialogAndWait(String message, Throwable exception) {
ExceptionDialog exceptionDialog = new ExceptionDialog(exception);
exceptionDialog.getDialogPane().setMaxWidth(mainWindow.getWidth() / 2);
exceptionDialog.setHeaderText(message);
themeLoader.installCss(exceptionDialog.getDialogPane().getScene(), preferences);
exceptionDialog.showAndWait();
}

Expand All @@ -176,6 +188,7 @@ public void showErrorDialogAndWait(String title, String content, Throwable excep
ExceptionDialog exceptionDialog = new ExceptionDialog(exception);
exceptionDialog.setHeaderText(title);
exceptionDialog.setContentText(content);
themeLoader.installCss(exceptionDialog.getDialogPane().getScene(), preferences);
exceptionDialog.showAndWait();
}

Expand Down Expand Up @@ -244,6 +257,7 @@ public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane con
alert.getButtonTypes().setAll(buttonTypes);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(true);
themeLoader.installCss(alert.getDialogPane().getScene(), preferences);
return alert.showAndWait();
}

Expand All @@ -268,6 +282,7 @@ public <V> void showProgressDialogAndWait(String title, String content, Task<V>
task.cancel();
progressDialog.close();
});
themeLoader.installCss(progressDialog.getDialogPane().getScene(), preferences);
progressDialog.show();
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.jabref.gui.undo.UndoRedoAction;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.ThemeLoader;
import org.jabref.logic.autosaveandbackup.AutosaveManager;
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
Expand Down Expand Up @@ -152,6 +153,7 @@ public class JabRefFrame extends BorderPane {

private final SplitPane splitPane = new SplitPane();
private final JabRefPreferences prefs = Globals.prefs;
private final ThemeLoader themeLoader = Globals.getThemeLoader();
private final GlobalSearchBar globalSearchBar = new GlobalSearchBar(this, Globals.stateManager);

private final ProgressBar progressBar = new ProgressBar();
Expand All @@ -169,7 +171,7 @@ public class JabRefFrame extends BorderPane {

public JabRefFrame(Stage mainStage) {
this.mainStage = mainStage;
this.dialogService = new JabRefDialogService(mainStage, this);
this.dialogService = new JabRefDialogService(mainStage, this, prefs, themeLoader);
this.stateManager = Globals.stateManager;
this.pushToApplicationsManager = new PushToApplicationsManager(dialogService, stateManager);
this.undoManager = Globals.undoManager;
Expand Down

0 comments on commit cbf7796

Please sign in to comment.