优化更新窗口 (#3317)

* 优化更新窗口

* fix NPE
This commit is contained in:
Glavo 2024-10-09 01:40:26 +08:00 committed by GitHub
parent 7937f8ddf5
commit c7f248a092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 4 deletions

View File

@ -166,6 +166,16 @@ public final class MessageDialogPane extends HBox {
return this;
}
public Builder addAction(String text, @Nullable Runnable action) {
JFXButton btnAction = new JFXButton(text);
btnAction.getStyleClass().add("dialog-accept");
if (action != null) {
btnAction.setOnAction(e -> action.run());
}
dialog.addButton(btnAction);
return this;
}
public Builder ok(@Nullable Runnable ok) {
JFXButton btnOk = new JFXButton(i18n("button.ok"));
btnOk.getStyleClass().add("dialog-accept");

View File

@ -237,10 +237,13 @@ public final class MainPage extends StackPane implements DecoratorPage {
doAnimation(show);
if (show && getLatestVersion() != null && !Objects.equals(config().getPromptedVersion(), getLatestVersion().getVersion())) {
Controllers.confirm("", i18n("update.bubble.title", getLatestVersion().getVersion()), MessageDialogPane.MessageType.INFO, () -> {
config().setPromptedVersion(getLatestVersion().getVersion());
onUpgrade();
}, null);
Controllers.dialog(new MessageDialogPane.Builder("", i18n("update.bubble.title", getLatestVersion().getVersion()), MessageDialogPane.MessageType.INFO)
.addAction(i18n("button.view"), () -> {
config().setPromptedVersion(getLatestVersion().getVersion());
onUpgrade();
})
.addCancel(null)
.build());
}
}

View File

@ -183,6 +183,7 @@ button.retry=Retry
button.save=Save
button.save_as=Save As
button.select_all=Select All
button.view=View
button.yes=Yes
chat=Join Group Chat

View File

@ -192,6 +192,7 @@ button.retry=重試
button.save=儲存
button.save_as=另存為
button.select_all=全選
button.view=查看
button.yes=
chat=官方群組

View File

@ -193,6 +193,7 @@ button.retry=重试
button.save=保存
button.save_as=另存为
button.select_all=全选
button.view=查看
button.yes=
chat=官方群组