Add about page
This commit is contained in:
parent
13355ce401
commit
d138ea3ad6
@ -0,0 +1,71 @@
|
||||
package name.nathanmcrae.numbersstation;
|
||||
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Properties;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.Hyperlink;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class AboutController {
|
||||
private static final Logger logger = Logger.getLogger(Main.class.getName());
|
||||
|
||||
@FXML
|
||||
private TextField directoryTextField;
|
||||
|
||||
@FXML
|
||||
private TextField executableTextField;
|
||||
|
||||
@FXML
|
||||
private TextField homepageURLTextField;
|
||||
|
||||
@FXML
|
||||
private TextField logPathTextField;
|
||||
|
||||
@FXML
|
||||
private TextField versionTextField;
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
directoryTextField.setText(Main.getConfigPath().toString());
|
||||
|
||||
String processName = ManagementFactory.getRuntimeMXBean().getName();
|
||||
long pid = Long.parseLong(processName.split("@")[0]);
|
||||
ProcessHandle currentProcess = ProcessHandle.of(pid).orElseThrow();
|
||||
Path executablePath = currentProcess.info().command().map(Paths::get).orElseThrow();
|
||||
executableTextField.setText(executablePath.toString());
|
||||
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Failed to load main view", e);
|
||||
}
|
||||
versionTextField.setText(String.valueOf(properties.get("git.commit.id.full")));
|
||||
|
||||
homepageURLTextField.setText("https://git.nathanmcrae.name/nathanmcrae/numbers-station");
|
||||
|
||||
logPathTextField.setText(Main.getStatePath().resolve("main.log").toString());
|
||||
}
|
||||
|
||||
public void handleAppExecutableButtonPress() {
|
||||
|
||||
}
|
||||
|
||||
public void handleConfigDirectoryButtonPress() {
|
||||
|
||||
}
|
||||
|
||||
public void handleLogFilePathButtonPress() {
|
||||
|
||||
}
|
||||
}
|
@ -41,6 +41,7 @@ import javafx.stage.Stage;
|
||||
public class MainController implements Initializable {
|
||||
private static final Logger logger = Logger.getLogger(Main.class.getName());
|
||||
|
||||
private Stage aboutStage;
|
||||
private Stage helpStage;
|
||||
private Stage settingsStage;
|
||||
private Stage selectStationStage;
|
||||
@ -396,6 +397,27 @@ public class MainController implements Initializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void handleAboutButtonPress() {
|
||||
try {
|
||||
if (aboutStage == null) {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/AboutView.fxml"));
|
||||
Parent root = fxmlLoader.load();
|
||||
aboutStage = new Stage();
|
||||
aboutStage.setTitle("About Numbers Station");
|
||||
aboutStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
|
||||
aboutStage.setScene(new Scene(root));
|
||||
}
|
||||
|
||||
if (aboutStage.isShowing()) {
|
||||
aboutStage.toFront();
|
||||
} else {
|
||||
aboutStage.show();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Exception while opening application about screen", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleHelpButtonPress() {
|
||||
try {
|
||||
if (helpStage == null) {
|
||||
|
26
src/main/resources/AboutView.fxml
Normal file
26
src/main/resources/AboutView.fxml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="209.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.AboutController">
|
||||
<children>
|
||||
<Label layoutX="19.0" layoutY="10.0" text="Application Information">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="20.0" layoutY="110.0" text="Application executable: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="110.0" />
|
||||
<Label layoutX="20.0" layoutY="50.0" text="Homepage:" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="50.0" />
|
||||
<Label layoutX="20.0" layoutY="140.0" text="Config directory: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="140.0" />
|
||||
<Label layoutX="20.0" layoutY="80.0" text="Version:" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="80.0" />
|
||||
<TextField fx:id="versionTextField" editable="false" layoutX="72.0" layoutY="76.0" text="asefa" />
|
||||
<TextField fx:id="executableTextField" editable="false" layoutX="153.0" layoutY="106.0" prefHeight="25.0" prefWidth="403.0" text="sflejk" AnchorPane.leftAnchor="153.0" AnchorPane.rightAnchor="10.0" />
|
||||
<TextField fx:id="directoryTextField" editable="false" layoutX="118.0" layoutY="136.0" prefHeight="25.0" prefWidth="437.0" text="afseijl" AnchorPane.leftAnchor="118.0" AnchorPane.rightAnchor="10.0" />
|
||||
<Label layoutX="20.0" layoutY="168.0" text="Log file: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="170.0" />
|
||||
<TextField fx:id="logPathTextField" editable="false" layoutX="70.0" layoutY="166.0" prefHeight="25.0" prefWidth="485.0" text="afseijl" AnchorPane.leftAnchor="70.0" AnchorPane.rightAnchor="10.0" />
|
||||
<TextField fx:id="homepageURLTextField" editable="false" layoutX="89.0" layoutY="46.0" prefHeight="25.0" prefWidth="501.0" text="asefa" AnchorPane.leftAnchor="89.0" AnchorPane.rightAnchor="10.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
@ -67,7 +67,7 @@
|
||||
<Label alignment="CENTER_RIGHT" layoutY="5.0" prefHeight="17.0" prefWidth="60.0" text="Station: " textAlignment="RIGHT" />
|
||||
<TextField fx:id="stationNameField" editable="false" layoutX="68.0" prefHeight="25.0" prefWidth="153.0" style="-fx-background-color: #EEEEEE; -fx-border-color: #AAAAAA;" text="My Station" />
|
||||
<Button layoutX="602.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleHelpButtonPress" text="Help" AnchorPane.rightAnchor="0.0" />
|
||||
<Button layoutX="516.0" layoutY="1.0" mnemonicParsing="false" text="Settings" AnchorPane.rightAnchor="52.0" />
|
||||
<Button layoutX="516.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleAboutButtonPress" text="About" AnchorPane.rightAnchor="52.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="50.0" prefWidth="640.0" GridPane.rowIndex="1">
|
||||
|
Loading…
x
Reference in New Issue
Block a user