完善关于页面
This commit is contained in:
parent
02165abde2
commit
7a330ec3f3
@ -43,6 +43,8 @@ public class AppConfig {
|
||||
shortcutKeys.add(createShortcutKey("openConfigItem", ALT_S));
|
||||
shortcutKeys.add(createShortcutKey("pluginManager", ""));
|
||||
shortcutKeys.add(createShortcutKey("countItem", ""));
|
||||
shortcutKeys.add(createShortcutKey("aboutItem", ""));
|
||||
|
||||
config.setShortcutKey(shortcutKeys);
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -10,6 +10,18 @@ import java.util.regex.Pattern;
|
||||
* @author 许轲
|
||||
*/
|
||||
public class AppConstants {
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
public static final String VERSION = "1.0.12";
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
public static final String AUTHOR = "JCNC";
|
||||
/**
|
||||
* 软件名称
|
||||
*/
|
||||
public static final String APP_NAME = "JNotepad";
|
||||
/**
|
||||
* 初始宽度
|
||||
*/
|
||||
|
||||
@ -20,6 +20,9 @@ public class TextConstants {
|
||||
public static final String WORD_WRAP = "WORD_WRAP";
|
||||
public static final String PLUGIN = "PLUGIN";
|
||||
public static final String MANAGER_PLUGIN = "MANAGER_PLUGIN";
|
||||
|
||||
public static final String ABOUT = "ABOUT";
|
||||
|
||||
public static final String STATISTICS = "STATISTICS";
|
||||
public static final String OPEN_CONFIGURATION_FILE = "OPEN_CONFIGURATION_FILE";
|
||||
public static final String TOP = "TOP";
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler.menubar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
|
||||
/**
|
||||
* 打开关于页面程序。
|
||||
*
|
||||
* <p>当用户选择关于时,将创建一个新的Stage。</p>
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class About implements EventHandler<ActionEvent> {
|
||||
/**
|
||||
* 处理关于页面。
|
||||
*
|
||||
* @param event 事件对象
|
||||
*/
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
addAboutStage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关于页面。
|
||||
*/
|
||||
public void addAboutStage() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ import javafx.util.Duration;
|
||||
public class CustomTitleBar extends HBox {
|
||||
private static CustomTitleBar instance;
|
||||
|
||||
private CustomTitleBar() {
|
||||
public CustomTitleBar() {
|
||||
// 设置样式和布局
|
||||
this.setAlignment(Pos.CENTER);
|
||||
|
||||
|
||||
@ -1,13 +1,20 @@
|
||||
package org.jcnc.jnotepad.views.manager;
|
||||
|
||||
import atlantafx.base.theme.Styles;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
@ -22,6 +29,7 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jcnc.jnotepad.common.constants.AppConstants.*;
|
||||
import static org.jcnc.jnotepad.common.constants.TextConstants.*;
|
||||
|
||||
/**
|
||||
@ -130,6 +138,116 @@ public class TopMenuBarManager {
|
||||
});
|
||||
registerPluginMenuItem(topMenuBar.getCountItem(), STATISTICS, "countItem", event -> {
|
||||
});
|
||||
|
||||
//帮助菜单
|
||||
registerHelpMenuItem(topMenuBar.getAboutItem(), ABOUT, "aboutItem", event -> {
|
||||
Stage aboutStage = new Stage();
|
||||
String leftBtnText = " 确定 ";
|
||||
|
||||
String rightBtnText = " 取消 ";
|
||||
Button leftBtn = new Button();
|
||||
leftBtn.getStyleClass().addAll(Styles.SMALL);
|
||||
leftBtn.setText(leftBtnText);
|
||||
|
||||
Button rightBtn = new Button();
|
||||
rightBtn.getStyleClass().addAll(Styles.SMALL);
|
||||
rightBtn.setText(rightBtnText);
|
||||
aboutStage.getIcons().add(UiUtil.getAppIcon());
|
||||
aboutStage.setTitle("关于 " + APP_NAME);
|
||||
BorderPane root = new BorderPane();
|
||||
VBox textBox = new VBox();
|
||||
VBox iconBox = new VBox();
|
||||
ImageView iconImageView = new ImageView(new Image("icon.png"));
|
||||
iconImageView.setFitWidth(50);
|
||||
iconImageView.setFitHeight(50);
|
||||
iconBox.setPadding(new Insets(20));
|
||||
|
||||
iconBox.getChildren().addAll(iconImageView);
|
||||
|
||||
|
||||
textBox.setPadding(new Insets(10));
|
||||
|
||||
HBox titleBox = new HBox(5);
|
||||
titleBox.setPadding(new Insets(10, 0, 0, 0));
|
||||
|
||||
Label titleLabel = new Label(APP_NAME);
|
||||
titleLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
|
||||
|
||||
Label versionLabel = new Label(VERSION);
|
||||
versionLabel.setPadding(new Insets(0.5, 0, 0, 0));
|
||||
versionLabel.setStyle("-fx-font-size: 15px; -fx-font-weight: bold;");
|
||||
|
||||
titleBox.getChildren().addAll(titleLabel, versionLabel);
|
||||
|
||||
Label descriptionLabel = new Label(APP_NAME + "是一款自由的集成开发环境。");
|
||||
descriptionLabel.setPadding(new Insets(8, 0, 8, 0));
|
||||
descriptionLabel.setStyle("-fx-font-size: 14px;");
|
||||
|
||||
VBox linkBox = new VBox(7);
|
||||
Hyperlink repositoryLink = new Hyperlink();
|
||||
repositoryLink.setText("仓库地址");
|
||||
repositoryLink.setOnAction(event1 -> {
|
||||
openWebsite("https://gitee.com/jcnc-org/JNotepad");
|
||||
});
|
||||
repositoryLink.setVisited(true);
|
||||
repositoryLink.setMnemonicParsing(true);
|
||||
repositoryLink.setStyle("-color-link-fg-visited:-color-accent-fg;");
|
||||
|
||||
Hyperlink feedBackLink = new Hyperlink();
|
||||
feedBackLink.setText("提交反馈");
|
||||
feedBackLink.setOnAction(event1 -> {
|
||||
openWebsite("https://gitee.com/jcnc-org/JNotepad/issues/new/choose");
|
||||
});
|
||||
feedBackLink.setVisited(true);
|
||||
feedBackLink.setMnemonicParsing(true);
|
||||
feedBackLink.setStyle("-color-link-fg-visited:-color-accent-fg;");
|
||||
|
||||
Hyperlink qLink = new Hyperlink();
|
||||
qLink.setText("加入QQ群");
|
||||
qLink.setOnAction(event1 -> {
|
||||
openWebsite("https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=x3QF-jrJAKTiwu8kV5-giBk2ow66Kzyr&authKey=qNqrQauD7Ra4fXH%2Ftu4ylHXCyrf2EOYj9oMYOmFjlzYmrgDL8Yd0m2qhrQQEBL25&noverify=0&group_code=386279455");
|
||||
});
|
||||
qLink.setVisited(true);
|
||||
qLink.setMnemonicParsing(true);
|
||||
qLink.setStyle("-color-link-fg-visited:-color-accent-fg;");
|
||||
|
||||
linkBox.getChildren().addAll(repositoryLink, feedBackLink, qLink);
|
||||
|
||||
Label authorLabel = new Label("Copyleft © 2023 " + AUTHOR + ".");
|
||||
authorLabel.setPadding(new Insets(8, 0, 8, 0));
|
||||
authorLabel.setStyle("-fx-font-size: 14px;");
|
||||
|
||||
textBox.getChildren().addAll(titleBox, descriptionLabel, linkBox, authorLabel);
|
||||
|
||||
HBox bottomBox = new HBox(10);
|
||||
bottomBox.setPadding(new Insets(7, 15, 7, 0));
|
||||
|
||||
bottomBox.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
bottomBox.getChildren().addAll(leftBtn, rightBtn);
|
||||
root.setBottom(bottomBox);
|
||||
|
||||
root.setCenter(textBox);
|
||||
root.setLeft(iconBox);
|
||||
|
||||
Scene scene = new Scene(root, 450, 240);
|
||||
aboutStage.setResizable (false);
|
||||
aboutStage.setScene(scene);
|
||||
aboutStage.show();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开网页方法
|
||||
*/
|
||||
private void openWebsite(String url) {
|
||||
try {
|
||||
LogUtil.getLogger(this.getClass()).info("正在打开---" + url);
|
||||
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
|
||||
} catch (java.io.IOException e) {
|
||||
LogUtil.getLogger(this.getClass()).info("打开失败---" + url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,6 +288,19 @@ public class TopMenuBarManager {
|
||||
setMenuItem(menuItem, buttonName, eventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册帮助菜单项
|
||||
*
|
||||
* @param menuItem 菜单项
|
||||
* @param menuItemName 菜单项名称
|
||||
* @param buttonName 按钮名称
|
||||
* @param eventHandler 操作事件
|
||||
*/
|
||||
public void registerHelpMenuItem(MenuItem menuItem, String menuItemName, String buttonName, EventHandler<ActionEvent> eventHandler) {
|
||||
helpMenuItems.put(menuItemName, menuItem);
|
||||
setMenuItem(menuItem, buttonName, eventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册设置菜单项
|
||||
*
|
||||
@ -310,12 +441,13 @@ public class TopMenuBarManager {
|
||||
*/
|
||||
private void initHelpMenu() {
|
||||
logger.info("初始化帮助菜单!");
|
||||
var helpMenu = topMenuBar.gethelpMenuMenu();
|
||||
var helpMenu = topMenuBar.getHelpMenu();
|
||||
// 插件菜单
|
||||
UiResourceBundle.bindStringProperty(helpMenu.textProperty(), HELP);
|
||||
|
||||
initMenuItems(helpMenuItems, helpMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化设置菜单
|
||||
*/
|
||||
|
||||
@ -136,10 +136,6 @@ public class TopMenuBar extends MenuBar {
|
||||
return pluginMenu;
|
||||
}
|
||||
|
||||
public Menu gethelpMenuMenu() {
|
||||
return helpMenu;
|
||||
}
|
||||
|
||||
|
||||
public Menu getLanguageMenu() {
|
||||
return languageMenu;
|
||||
|
||||
@ -9,6 +9,7 @@ PLUGIN=插件
|
||||
CHINESE=中文
|
||||
title=JNotepad
|
||||
OPEN=打开
|
||||
ABOUT=关于
|
||||
HELP=帮助
|
||||
OPEN_CONFIGURATION_FILE=打开配置文件
|
||||
RENAME=重命名
|
||||
|
||||
@ -4,6 +4,7 @@ NEW_FILE=New File
|
||||
SET=Settings
|
||||
ENGLISH=English
|
||||
STATISTICS=Word Count
|
||||
ABOUT=About
|
||||
COLUMN=Column
|
||||
PLUGIN=Plugins
|
||||
CHINESE=Chinese
|
||||
|
||||
@ -10,6 +10,7 @@ CHINESE=中文
|
||||
title=JNotepad
|
||||
OPEN=打开
|
||||
HELP=帮助
|
||||
ABOUT=关于
|
||||
OPEN_CONFIGURATION_FILE=打开配置文件
|
||||
RENAME=重命名
|
||||
TOP=窗口置顶
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user