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

Add 'Get New Themes!' Button for Web Page Integration #10349

Merged
merged 21 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added support for customizing the citation command (e.g., `[@key1,@key2]`) when [pushing to external applications](https://docs.jabref.org/cite/pushtoapplications). [#10133](https://github.com/JabRef/jabref/issues/10133)
- We added an integrity check for more special characters. [#8712](https://github.com/JabRef/jabref/issues/8712)
- We added protected terms described as "Computer science". [#10222](https://github.com/JabRef/jabref/pull/10222)
- We added a link "Get more themes..." in the preferences to that points to [themes.jabref.org](https://themes.jabref.org) allowing the user to download new themes. [#10243](https://github.com/JabRef/jabref/issues/10243)
- We added a fetcher for [LOBID](https://lobid.org/resources/api) resources. [koppor#386](https://github.com/koppor/jabref/issues/386)

### Changed

- In the exports listrefs, tablerefs, tablerefsabsbib, use ISO date format in the footer.
- The export formats `listrefs`, `tablerefs`, `tablerefsabsbib`, now use the ISO date format in the footer [#10383](https://github.com/JabRef/jabref/pull/10383).

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import javafx.scene.control.Hyperlink?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.preferences.general.GeneralTab">
Expand Down Expand Up @@ -58,6 +59,8 @@
</HBox>
</GridPane>

<Hyperlink fx:id="moreThemes" text = "%Get more themes..." onAction="#openBrowser"/>

<Label styleClass="sectionHeader" text="%User interface"/>
<CheckBox fx:id="openLastStartup" text="%Open last edited libraries on startup"/>
<CheckBox fx:id="showAdvancedHints"
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/jabref/gui/preferences/general/GeneralTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import javafx.scene.control.TextFormatter;
import javafx.util.converter.IntegerStringConverter;

import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.gui.theme.ThemeTypes;
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.help.HelpFile;
Expand All @@ -33,7 +33,7 @@
public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> implements PreferencesTab {

@FXML private ComboBox<Language> language;
@FXML private ComboBox<GeneralTabViewModel.ThemeTypes> theme;
@FXML private ComboBox<ThemeTypes> theme;
@FXML private TextField customThemePath;
@FXML private Button customThemeBrowse;
@FXML private CheckBox fontOverride;
Expand Down Expand Up @@ -91,14 +91,14 @@ public void initialize() {
fontSize.getEditor().textProperty().bindBidirectional(viewModel.fontSizeProperty());
fontSize.getEditor().setTextFormatter(fontSizeFormatter);

new ViewModelListCellFactory<GeneralTabViewModel.ThemeTypes>()
.withText(GeneralTabViewModel.ThemeTypes::getDisplayName)
new ViewModelListCellFactory<ThemeTypes>()
.withText(ThemeTypes::getDisplayName)
.install(theme);
theme.itemsProperty().bind(viewModel.themesListProperty());
theme.valueProperty().bindBidirectional(viewModel.selectedThemeProperty());
customThemePath.textProperty().bindBidirectional(viewModel.customPathToThemeProperty());
EasyBind.subscribe(viewModel.selectedThemeProperty(), theme -> {
boolean isCustomTheme = theme == GeneralTabViewModel.ThemeTypes.CUSTOM;
boolean isCustomTheme = theme == ThemeTypes.CUSTOM;
customThemePath.disableProperty().set(!isCustomTheme);
customThemeBrowse.disableProperty().set(!isCustomTheme);
});
Expand All @@ -120,7 +120,7 @@ public void initialize() {

alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
ActionFactory actionFactory = new ActionFactory(preferencesService.getKeyBindingRepository());
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService, preferencesService.getFilePreferences()), autosaveLocalLibrariesHelp);

createBackup.selectedProperty().bindBidirectional(viewModel.createBackupProperty());
Expand All @@ -141,4 +141,9 @@ void importTheme() {
public void backupFileDirBrowse() {
viewModel.backupFileDirBrowse();
}

@FXML
public void openBrowser() {
viewModel.openBrowser();
Copy link
Member

Choose a reason for hiding this comment

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

A model opening a browser seems strange. - CAn you move the openBrowser code from the model to here?

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, for sure!

Copy link
Member

@Siedlerchr Siedlerchr Sep 21, 2023

Choose a reason for hiding this comment

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

@koppor this is done elsewhere as well
For example in the about dialog.
And this is our standard approach. All logic goes to the view model

Copy link
Member

Choose a reason for hiding this comment

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

Then, I'll move forward with merge - and will put an agenda item for on our DevCall agenda.

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.preferences.general;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,8 +19,10 @@
import javafx.scene.control.SpinnerValueFactory;

import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.gui.theme.Theme;
import org.jabref.gui.theme.ThemeTypes;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Language;
Expand All @@ -40,31 +43,16 @@
import de.saxsys.mvvmfx.utils.validation.Validator;

public class GeneralTabViewModel implements PreferenceTabViewModel {
protected enum ThemeTypes {
LIGHT(Localization.lang("Light")),
DARK(Localization.lang("Dark")),
CUSTOM(Localization.lang("Custom..."));

private final String displayName;

ThemeTypes(String displayName) {
this.displayName = displayName;
}

public String getDisplayName() {
return displayName;
}
}

protected static SpinnerValueFactory<Integer> fontSizeValueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(9, Integer.MAX_VALUE);

private final ReadOnlyListProperty<Language> languagesListProperty =
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(Language.values()));;
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(Language.values()));
private final ObjectProperty<Language> selectedLanguageProperty = new SimpleObjectProperty<>();

private final ReadOnlyListProperty<ThemeTypes> themesListProperty =
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(ThemeTypes.values()));;
new ReadOnlyListWrapper<>(FXCollections.observableArrayList(ThemeTypes.values()));
private final ObjectProperty<ThemeTypes> selectedThemeProperty = new SimpleObjectProperty<>();
private final StringProperty customPathToThemeProperty = new SimpleStringProperty();

Expand Down Expand Up @@ -321,4 +309,13 @@ public void backupFileDirBrowse() {
dialogService.showDirectorySelectionDialog(dirDialogConfiguration)
.ifPresent(dir -> backupDirectoryProperty.setValue(dir.toString()));
}

public void openBrowser() {
String url = "https://themes.jabref.org";
try {
JabRefDesktop.openBrowser(url, preferences.getFilePreferences());
} catch (IOException e) {
dialogService.showErrorDialogAndWait(Localization.lang("Could not open website."), e);
}
}
}
20 changes: 20 additions & 0 deletions src/main/java/org/jabref/gui/theme/ThemeTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.jabref.gui.theme;

import org.jabref.logic.l10n.Localization;

public enum ThemeTypes {

LIGHT(Localization.lang("Light")),
DARK(Localization.lang("Dark")),
CUSTOM(Localization.lang("Custom..."));

private final String displayName;

ThemeTypes(String displayName) {
this.displayName = displayName;
}

public String getDisplayName() {
return displayName;
}
}
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 @@ -2580,6 +2580,8 @@ Finished\ writing\ metadata\ for\ library\ %0\ (%1\ succeeded,\ %2\ skipped,\ %3
Processing...=Processing...
Writing\ metadata\ to\ %0=Writing metadata to %0

Get\ more\ themes...=Get more themes...

Add\ selected\ entries\ to\ database=Add selected entries to database
The\ selected\ entry\ doesn't\ have\ a\ DOI\ linked\ to\ it.\ Lookup\ a\ DOI\ and\ try\ again.=The selected entry doesn't have a DOI linked to it. Lookup a DOI and try again.
Cited\ By=Cited By
Expand Down