chore: 添加帮助按钮、代码整理

This commit is contained in:
octopus_yan 2024-11-15 23:44:39 +08:00
parent 1dc6e95340
commit 5ac5297184
5 changed files with 90 additions and 70 deletions

View File

@ -146,54 +146,6 @@ public class MainController extends BaseController<MainViewModel> {
);
}
/**
* 设置文件拖拽效果
*/
private void setDragAction(Pane fileBox) {
// 进入
fileBox.setOnDragEntered(dragEvent -> {
var dragboard = dragEvent.getDragboard();
if (dragboard.hasFiles() && isPboFile(dragboard.getFiles().getFirst())) {
selectFileBox.setVisible(true);
dragFileView.setVisible(true);
}
});
//离开
fileBox.setOnDragExited(_ -> {
selectFileBox.setVisible(false);
dragFileView.setVisible(false);
});
//
fileBox.setOnDragOver(dragEvent -> {
var dragboard = dragEvent.getDragboard();
if (dragEvent.getGestureSource() != fileBox && dragboard.hasFiles()) {
/* allow for both copying and moving, whatever user chooses */
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
dragEvent.consume();
});
// 松手
fileBox.setOnDragDropped(dragEvent -> {
dragFileView.setVisible(false);
var db = dragEvent.getDragboard();
boolean success = false;
var file = db.getFiles().getFirst();
if (db.hasFiles() && isPboFile(file)) {
selectFile(file);
success = true;
}
/* 让源知道字符串是否已成功传输和使用 */
dragEvent.setDropCompleted(success);
dragEvent.consume();
});
}
/**
* 打开文件选择器
*/
@ -215,6 +167,13 @@ public class MainController extends BaseController<MainViewModel> {
ViewUtil.openDecorated("翻译设置", "setup/translate-view");
}
/**
* 帮助
*/
public void openHelp() {
Context.openUrl("https://www.52pojie.cn/thread-1891962-1-1.html");
}
/**
* 关于
*/
@ -222,6 +181,26 @@ public class MainController extends BaseController<MainViewModel> {
ViewUtil.openDecorated("关于", "about-view");
}
public void startTranslate() {
viewModel.startTranslate();
}
public void startPack() {
viewModel.pack();
}
public void selectAllLog() {
logArea.selectAll();
}
public void copyLog() {
logArea.copy();
}
public void clearLog() {
logArea.clear();
}
/**
* 显示加载PBO文件
*/
@ -289,27 +268,55 @@ public class MainController extends BaseController<MainViewModel> {
}
}
public void startTranslate() {
viewModel.startTranslate();
}
// ======================================{ private }========================================
public void startPack() {
viewModel.pack();
}
/**
* 设置文件拖拽效果
*/
private void setDragAction(Pane fileBox) {
public void selectAllLog() {
logArea.selectAll();
// 进入
fileBox.setOnDragEntered(dragEvent -> {
var dragboard = dragEvent.getDragboard();
if (dragboard.hasFiles() && isPboFile(dragboard.getFiles().getFirst())) {
selectFileBox.setVisible(true);
dragFileView.setVisible(true);
}
});
public void copyLog() {
logArea.copy();
//离开
fileBox.setOnDragExited(_ -> {
selectFileBox.setVisible(false);
dragFileView.setVisible(false);
});
//
fileBox.setOnDragOver(dragEvent -> {
var dragboard = dragEvent.getDragboard();
if (dragEvent.getGestureSource() != fileBox && dragboard.hasFiles()) {
/* allow for both copying and moving, whatever user chooses */
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
dragEvent.consume();
});
public void clearLog() {
logArea.clear();
// 松手
fileBox.setOnDragDropped(dragEvent -> {
dragFileView.setVisible(false);
var db = dragEvent.getDragboard();
boolean success = false;
var file = db.getFiles().getFirst();
if (db.hasFiles() && isPboFile(file)) {
selectFile(file);
success = true;
}
/* 让源知道字符串是否已成功传输和使用 */
dragEvent.setDropCompleted(success);
// ======================================{ }========================================
dragEvent.consume();
});
}
/**
* 打开文件

View File

@ -37,10 +37,14 @@ public class AboutController extends BaseController<AboutViewModel> {
}
public void openGitee() {
Context.openUrl("https://gitee.com/octopus_yan/dayz-mod-translator");
Context.openUrl("https://gitee.com/octopus_yan/dayz-mod-translator/releases");
}
public void openGithub() {
Context.openUrl("https://github.com/octopusYan/dayz-mod-translator");
Context.openUrl("https://github.com/octopusYan/dayz-mod-translator/releases");
}
public void openForum() {
Context.openUrl("https://www.52pojie.cn/thread-1891962-1-1.html");
}
}

View File

@ -1,5 +1,5 @@
#root #titleBox {
-fx-padding: 0 0 0 120;
-fx-padding: 0 0 0 70;
-fx-background-color: -color-neutral-muted;
}
@ -9,6 +9,6 @@
}
#root #infoBox {
-fx-spacing: 25;
-fx-padding: 50 0 0 120;
-fx-spacing: 20;
-fx-padding: 30 0 0 70;
}

View File

@ -6,7 +6,7 @@
<VBox xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="cn.octopusyan.dmt.controller.help.AboutController"
stylesheets="@../css/about-view.css"
fx:id="root" prefHeight="400.0" prefWidth="600.0">
fx:id="root" prefHeight="350.0" prefWidth="500.0">
<VBox id="titleBox" alignment="CENTER_LEFT" prefWidth="${root.width}" prefHeight="100">
<Label fx:id="title" text="title"/>
@ -21,5 +21,9 @@
<Hyperlink text="Gitee" onAction="#openGitee"/>
<Hyperlink text="Github" onAction="#openGithub"/>
</HBox>
<HBox spacing="20">
<Label text="发布地址"/>
<Hyperlink text="52pojie.cn" onAction="#openForum"/>
</HBox>
</VBox>
</VBox>

View File

@ -35,6 +35,11 @@
</MenuItem>
</Menu>
<Menu mnemonicParsing="false" text="帮助">
<MenuItem text="帮助" onAction="#openHelp">
<graphic>
<FontIcon iconLiteral="fth-help-circle"/>
</graphic>
</MenuItem>
<MenuItem text="关于" onAction="#openAbout">
<graphic>
<FontIcon iconLiteral="fth-info"/>