diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 8ea162f4..7a0b2d2f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -53,6 +53,8 @@ public class AppController implements Initializable { public static final String DRAG_OVER_CLASS = "drag-over"; + private MainApp application; + @FXML private MenuItem exportWallet; @@ -96,7 +98,7 @@ public class AppController implements Initializable { } void initializeView() { - //setOsxApplicationMenu(); + setOsxApplicationMenu(); rootStack.setOnDragOver(event -> { if(event.getGestureSource() != rootStack && event.getDragboard().hasFiles()) { @@ -201,6 +203,10 @@ public class AppController implements Initializable { return connectionService; } + public void setApplication(MainApp application) { + this.application = application; + } + private void setOsxApplicationMenu() { if(org.controlsfx.tools.Platform.getCurrent().getPlatformId().toLowerCase().equals("mac")) { MenuToolkit tk = MenuToolkit.toolkit(); @@ -347,6 +353,14 @@ public class AppController implements Initializable { tabs.getTabs().remove(tabs.getSelectionModel().getSelectedItem()); } + public void quit(ActionEvent event) { + try { + application.stop(); + } catch (Exception e) { + e.printStackTrace(); + } + } + public void showTxHex(ActionEvent event) { CheckMenuItem item = (CheckMenuItem)event.getSource(); EventManager.get().post(new TransactionTabChangedEvent(tabs.getSelectionModel().getSelectedItem(), item.isSelected())); diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index 069ddbf1..8bc22deb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -19,8 +19,12 @@ import java.util.Optional; public class MainApp extends Application { public static final String APP_NAME = "Sparrow"; + private Stage mainStage; + @Override public void start(Stage stage) throws Exception { + this.mainStage = stage; + GlyphFontRegistry.register(new FontAwesome5()); GlyphFontRegistry.register(new FontAwesome5Brands()); @@ -42,6 +46,7 @@ public class MainApp extends Application { FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("app.fxml")); Parent root = transactionLoader.load(); AppController appController = transactionLoader.getController(); + appController.setApplication(this); Scene scene = new Scene(root); scene.getStylesheets().add(getClass().getResource("app.css").toExternalForm()); @@ -57,6 +62,11 @@ public class MainApp extends Application { stage.show(); } + @Override + public void stop() throws Exception { + mainStage.close(); + } + public static void main(String[] args) { launch(args); } diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 08683698..bc580d43 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -28,8 +28,10 @@ + + - +