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

Fix various Dark theme issues #6368

Merged
merged 2 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
-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
11 changes: 11 additions & 0 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import javafx.stage.Window;
import javafx.util.Duration;

import org.jabref.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
Expand Down Expand Up @@ -126,6 +127,7 @@ public <T> Optional<T> showChoiceDialogAndWait(String title, String content, Str
choiceDialog.setHeaderText(title);
choiceDialog.setTitle(title);
choiceDialog.setContentText(content);
Globals.getThemeLoader().installCss(choiceDialog.getDialogPane().getScene(), Globals.prefs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are trying to remove the Globals class (in the long term). To facilitate this, could you please extract the themeLoader and preferences, and initialize them by passing the global objects as dependencies through the constructor (i.e. move Globals from this class to the caller)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have refactored the code but I m not sure if I've done it correctly

return choiceDialog.showAndWait();
}

Expand All @@ -148,12 +150,14 @@ public Optional<String> showInputDialogWithDefaultAndWait(String title, String c
@Override
public void showInformationDialogAndWait(String title, String content) {
FXDialog alert = createDialog(AlertType.INFORMATION, title, content);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work, if you move this line inside the createDialog? Then you could reduce some code duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! didn't really pay attention.

alert.showAndWait();
}

@Override
public void showWarningDialogAndWait(String title, String content) {
FXDialog alert = createDialog(AlertType.WARNING, title, content);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
alert.showAndWait();
}

Expand Down Expand Up @@ -188,6 +192,7 @@ public void showErrorDialogAndWait(String message) {
@Override
public boolean showConfirmationDialogAndWait(String title, String content) {
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait().filter(buttonType -> buttonType == ButtonType.OK).isPresent();
}

Expand All @@ -196,6 +201,7 @@ public boolean showConfirmationDialogAndWait(String title, String content, Strin
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
alert.getButtonTypes().setAll(ButtonType.CANCEL, okButtonType);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}

Expand All @@ -206,6 +212,7 @@ public boolean showConfirmationDialogAndWait(String title, String content,
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
alert.getButtonTypes().setAll(okButtonType, cancelButtonType);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}

Expand All @@ -214,6 +221,7 @@ public boolean showConfirmationDialogWithOptOutAndWait(String title, String cont
String optOutMessage, Consumer<Boolean> optOutAction) {
FXDialog alert = createDialogWithOptOut(AlertType.CONFIRMATION, title, content, optOutMessage, optOutAction);
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait().filter(buttonType -> buttonType == ButtonType.YES).isPresent();
}

Expand All @@ -225,6 +233,7 @@ public boolean showConfirmationDialogWithOptOutAndWait(String title, String cont
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.YES);
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
alert.getButtonTypes().setAll(okButtonType, cancelButtonType);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}

Expand All @@ -244,6 +253,7 @@ public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane con
alert.getButtonTypes().setAll(buttonTypes);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(true);
Globals.getThemeLoader().installCss(alert.getDialogPane().getScene(), Globals.prefs);
return alert.showAndWait();
}

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

Expand Down