Compare commits

...
2 Commits
6 changed files with 17 additions and 14 deletions

No files matched your search

@@ -36,6 +36,7 @@ import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
@@ -1387,6 +1388,16 @@ public final class FXUtils {
});
}
public static void clearFocus(Node node) {
Scene scene = node.getScene();
if (scene != null) {
Parent root = scene.getRoot();
if (root != null) {
root.requestFocus();
}
}
}
public static void copyOnDoubleClick(Labeled label) {
label.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
if (e.getButton() == MouseButton.PRIMARY && e.getClickCount() == 2) {
@@ -102,7 +102,7 @@ public abstract class ToolbarListPageSkin<T extends ListPageBase<? extends Node>
ret.setText(text);
ret.setOnAction(e -> {
onClick.run();
ret.getScene().getRoot().requestFocus();
FXUtils.clearFocus(ret);
});
return ret;
}
@@ -181,7 +181,7 @@ public final class VersionsPage extends Control implements WizardPage, Refreshab
JFXButton wikiButton = newToggleButton4(SVG.GLOBE_BOOK);
wikiButton.setOnAction(event -> {
onOpenWiki();
wikiButton.getScene().getRoot().requestFocus();
FXUtils.clearFocus(wikiButton);
});
FXUtils.installFastTooltip(wikiButton, i18n("wiki.tooltip"));
actions.getChildren().add(wikiButton);
@@ -104,7 +104,7 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
lock.lock();
try {
modManager.refreshMods();
return modManager.getMods();
return modManager.getMods().stream().map(ModListPageSkin.ModInfoObject::new).toList();
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
@@ -114,7 +114,7 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
updateSupportedLoaders(modManager);
if (exception == null) {
getItems().setAll(list.stream().map(ModListPageSkin.ModInfoObject::new).toList());
getItems().setAll(list);
} else {
LOG.warning("Failed to load mods", exception);
getItems().clear();
@@ -18,7 +18,6 @@
package org.jackhuang.hmcl.ui.versions;
import com.jfoenix.controls.*;
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
import javafx.animation.PauseTransition;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
@@ -61,7 +60,6 @@ import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.io.CompressingUtils;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.ref.SoftReference;
@@ -289,7 +287,7 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
}
}
static final class ModInfoObject extends RecursiveTreeObject<ModInfoObject> implements Comparable<ModInfoObject> {
static final class ModInfoObject {
private final BooleanProperty active;
private final LocalModFile localModFile;
private final @Nullable ModTranslations.Mod modTranslations;
@@ -403,12 +401,6 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
imageView.setImage(image);
}, Schedulers.javafx());
}
@Override
public int compareTo(@NotNull ModListPageSkin.ModInfoObject o) {
return localModFile.getFileName().toLowerCase(Locale.ROOT)
.compareTo(o.localModFile.getFileName().toLowerCase(Locale.ROOT));
}
}
final class ModInfoDialog extends JFXDialogLayout {
@@ -189,7 +189,7 @@ public final class LocalModFile implements Comparable<LocalModFile> {
@Override
public int compareTo(LocalModFile o) {
return getFileName().compareTo(o.getFileName());
return getFileName().compareToIgnoreCase(o.getFileName());
}
@Override