Skip to content

Commit 53e90ea

Browse files
authored
fix: 日志窗口 Ctrl+C 复制 toast 在主窗口显示 (#5581)
1 parent cd989b1 commit 53e90ea

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
*/
1818
package org.jackhuang.hmcl.ui;
1919

20-
import com.jfoenix.controls.JFXButton;
21-
import com.jfoenix.controls.JFXCheckBox;
22-
import com.jfoenix.controls.JFXComboBox;
23-
import com.jfoenix.controls.JFXListView;
20+
import com.jfoenix.controls.*;
2421
import javafx.application.Platform;
2522
import javafx.beans.InvalidationListener;
2623
import javafx.beans.binding.Bindings;
@@ -43,8 +40,12 @@
4340
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
4441
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
4542
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
46-
import org.jackhuang.hmcl.util.*;
47-
import org.jackhuang.hmcl.util.platform.*;
43+
import org.jackhuang.hmcl.util.CircularArrayList;
44+
import org.jackhuang.hmcl.util.Lang;
45+
import org.jackhuang.hmcl.util.Log4jLevel;
46+
import org.jackhuang.hmcl.util.StringUtils;
47+
import org.jackhuang.hmcl.util.platform.ManagedProcess;
48+
import org.jackhuang.hmcl.util.platform.SystemUtils;
4849

4950
import java.io.IOException;
5051
import java.nio.file.Files;
@@ -257,6 +258,7 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
257258
private static final PseudoClass SELECTED = PseudoClass.getPseudoClass("selected");
258259

259260
private final Set<ListCell<Log>> selected = new HashSet<>();
261+
private final JFXSnackbar snackbar = new JFXSnackbar();
260262

261263
LogWindowSkin(LogWindowImpl control) {
262264
super(control);
@@ -265,7 +267,7 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
265267
vbox.setPadding(new Insets(3, 0, 3, 0));
266268
getSkinnable().stackPane.getChildren().setAll(vbox);
267269
getChildren().setAll(getSkinnable().stackPane);
268-
270+
snackbar.registerSnackbarContainer(getSkinnable().stackPane);
269271

270272
{
271273
BorderPane borderPane = new BorderPane();
@@ -381,7 +383,8 @@ protected void updateItem(Log item, boolean empty) {
381383
}
382384
}
383385

384-
FXUtils.copyText(stringBuilder.toString());
386+
FXUtils.copyText(stringBuilder.toString(), null);
387+
snackbar.fireEvent(new JFXSnackbar.SnackbarEvent(new JFXSnackbarLayout(i18n("message.copied"))));
385388
}
386389
});
387390

0 commit comments

Comments
 (0)