diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 64ac61aa..211ef493 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -86,6 +86,9 @@ public class AppController implements Initializable { @FXML private Menu fileMenu; + @FXML + private Menu toolsMenu; + @FXML private Menu helpMenu; @@ -134,7 +137,7 @@ public class AppController implements Initializable { } void initializeView() { - setOsxApplicationMenu(); + setPlatformApplicationMenu(); rootStack.setOnDragOver(event -> { if(event.getGestureSource() != rootStack && event.getDragboard().hasFiles()) { @@ -256,8 +259,9 @@ public class AppController implements Initializable { openTransactionIdItem.disableProperty().bind(onlineProperty().not()); } - private void setOsxApplicationMenu() { - if(org.controlsfx.tools.Platform.getCurrent() == org.controlsfx.tools.Platform.OSX) { + private void setPlatformApplicationMenu() { + org.controlsfx.tools.Platform platform = org.controlsfx.tools.Platform.getCurrent(); + if(platform == org.controlsfx.tools.Platform.OSX) { MenuToolkit tk = MenuToolkit.toolkit(); MenuItem preferences = new MenuItem("Preferences..."); preferences.setOnAction(this::openPreferences); @@ -269,7 +273,10 @@ public class AppController implements Initializable { tk.setApplicationMenu(defaultApplicationMenu); fileMenu.getItems().removeIf(item -> item.getStyleClass().contains("osxHide")); + toolsMenu.getItems().removeIf(item -> item.getStyleClass().contains("osxHide")); helpMenu.getItems().removeIf(item -> item.getStyleClass().contains("osxHide")); + } else if(platform == org.controlsfx.tools.Platform.WINDOWS) { + toolsMenu.getItems().removeIf(item -> item.getStyleClass().contains("windowsHide")); } } @@ -323,6 +330,24 @@ public class AppController implements Initializable { return null; } + public void installUdevRules(ActionEvent event) { + Hwi.EnumerateService enumerateService = new Hwi.EnumerateService(null); + enumerateService.setOnSucceeded(workerStateEvent -> { + Platform.runLater(this::showInstallUdevMessage); + }); + enumerateService.setOnFailed(workerStateEvent -> { + Platform.runLater(this::showInstallUdevMessage); + }); + enumerateService.start(); + } + + public void showInstallUdevMessage() { + TextAreaDialog dialog = new TextAreaDialog("sudo " + Config.get().getHwi().getAbsolutePath() + " installudevrules"); + dialog.setTitle("Install Udev Rules"); + dialog.getDialogPane().setHeaderText("Installing udev rules ensures devices can connect over USB.\nThis command requires root privileges.\nOpen a shell and enter the following:"); + dialog.showAndWait(); + } + public void openTransactionFromFile(ActionEvent event) { Stage window = new Stage(); diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 048938a2..655ba300 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -88,6 +88,7 @@