Postpone loading fonts
This commit is contained in:
@@ -30,20 +30,11 @@ import javafx.beans.property.SimpleStringProperty;
|
|||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ScrollPane;
|
|
||||||
import javafx.scene.control.ToggleGroup;
|
import javafx.scene.control.ToggleGroup;
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.Text;
|
|
||||||
import org.jackhuang.hmcl.setting.*;
|
import org.jackhuang.hmcl.setting.*;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
|
||||||
import org.jackhuang.hmcl.ui.construct.FontComboBox;
|
|
||||||
import org.jackhuang.hmcl.ui.construct.MultiFileItem;
|
|
||||||
import org.jackhuang.hmcl.ui.construct.Validator;
|
import org.jackhuang.hmcl.ui.construct.Validator;
|
||||||
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
|
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
|
||||||
import org.jackhuang.hmcl.upgrade.UpdateChannel;
|
import org.jackhuang.hmcl.upgrade.UpdateChannel;
|
||||||
@@ -75,7 +66,7 @@ public final class SettingsPage extends SettingsView implements DecoratorPage {
|
|||||||
cboDownloadSource.getSelectionModel().select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.instance().getDownloadProvider()));
|
cboDownloadSource.getSelectionModel().select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.instance().getDownloadProvider()));
|
||||||
cboDownloadSource.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.instance().setDownloadProvider(DownloadProviders.getDownloadProvider(newValue.intValue())));
|
cboDownloadSource.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.instance().setDownloadProvider(DownloadProviders.getDownloadProvider(newValue.intValue())));
|
||||||
|
|
||||||
cboFont.getSelectionModel().select(Settings.instance().getFont().getFamily());
|
cboFont.initValue(Settings.instance().getFont());
|
||||||
cboFont.valueProperty().addListener((a, b, newValue) -> {
|
cboFont.valueProperty().addListener((a, b, newValue) -> {
|
||||||
Font font = Font.font(newValue, Settings.instance().getFont().getSize());
|
Font font = Font.font(newValue, Settings.instance().getFont().getSize());
|
||||||
Settings.instance().setFont(font);
|
Settings.instance().setFont(font);
|
||||||
|
|||||||
@@ -24,11 +24,10 @@ import javafx.scene.control.ListCell;
|
|||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
|
|
||||||
public class FontComboBox extends JFXComboBox<String> {
|
public class FontComboBox extends JFXComboBox<String> {
|
||||||
|
private boolean loaded = false;
|
||||||
|
|
||||||
public FontComboBox(@NamedArg(value = "fontSize", defaultValue = "12.0") double fontSize,
|
public FontComboBox(@NamedArg(value = "fontSize", defaultValue = "12.0") double fontSize,
|
||||||
@NamedArg(value = "enableStyle", defaultValue = "false") boolean enableStyle) {
|
@NamedArg(value = "enableStyle", defaultValue = "false") boolean enableStyle) {
|
||||||
super(FXCollections.observableArrayList(Font.getFamilies()));
|
|
||||||
|
|
||||||
valueProperty().addListener((a, b, newValue) -> {
|
valueProperty().addListener((a, b, newValue) -> {
|
||||||
if (enableStyle)
|
if (enableStyle)
|
||||||
setStyle("-fx-font-family: \"" + newValue + "\";");
|
setStyle("-fx-font-family: \"" + newValue + "\";");
|
||||||
@@ -44,5 +43,15 @@ public class FontComboBox extends JFXComboBox<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setOnMouseClicked(e -> {
|
||||||
|
if (loaded) return;
|
||||||
|
getItems().setAll(Font.getFamilies());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initValue(Font font) {
|
||||||
|
getItems().setAll(font.getFamily());
|
||||||
|
getSelectionModel().select(font.getFamily());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user