Skip to content

Commit 74bb770

Browse files
SwiftWindsairsquared
authored andcommitted
Fix 'x' not doing anything in About menu
1 parent 73508be commit 74bb770

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

src/main/java/com/airsquared/blobsaver/Controller.java

+27-12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
import javafx.event.ActionEvent;
2929
import javafx.event.EventHandler;
3030
import javafx.fxml.FXML;
31+
import javafx.scene.control.Button;
32+
import javafx.scene.control.Label;
33+
import javafx.scene.control.Menu;
34+
import javafx.scene.control.MenuBar;
35+
import javafx.scene.control.MenuItem;
36+
import javafx.scene.control.TextField;
3137
import javafx.scene.control.*;
3238
import javafx.scene.effect.DropShadow;
3339
import javafx.scene.input.MouseEvent;
@@ -52,12 +58,7 @@
5258

5359
import static com.airsquared.blobsaver.Main.appPrefs;
5460
import static com.airsquared.blobsaver.Main.primaryStage;
55-
import static com.airsquared.blobsaver.Shared.githubIssue;
56-
import static com.airsquared.blobsaver.Shared.newReportableError;
57-
import static com.airsquared.blobsaver.Shared.newUnreportableError;
58-
import static com.airsquared.blobsaver.Shared.redditPM;
59-
import static com.airsquared.blobsaver.Shared.reportError;
60-
import static com.airsquared.blobsaver.Shared.resizeAlertButtons;
61+
import static com.airsquared.blobsaver.Shared.*;
6162

6263
public class Controller {
6364

@@ -335,7 +336,7 @@ public void initialize() {
335336
@Override
336337
public void handle(WindowEvent event) {
337338
useMacOSMenuBar();
338-
log("using macos menu bar");
339+
log("using macOS menu bar");
339340
primaryStage.removeEventHandler(event.getEventType(), this);
340341
}
341342
});
@@ -851,11 +852,23 @@ public void aboutMenuHandler() {
851852
ButtonType viewLicense = new ButtonType("View License");
852853
ButtonType librariesUsed = new ButtonType("Libraries Used");
853854
ButtonType donate = new ButtonType("Donate!");
854-
Alert alert = new Alert(Alert.AlertType.INFORMATION, "About text here", librariesUsed, viewLicense, donate, githubRepo, ButtonType.OK);
855+
ButtonType customOK = new ButtonType("OK", ButtonBar.ButtonData.CANCEL_CLOSE);
856+
Alert alert = new Alert(Alert.AlertType.INFORMATION, "About text here",
857+
librariesUsed, viewLicense, donate, githubRepo, customOK);
855858
alert.setTitle("About");
859+
860+
//Deactivate default behavior for librariesUsed Button:
861+
Button libButton = (Button) alert.getDialogPane().lookupButton(librariesUsed);
862+
libButton.setDefaultButton(false);
863+
864+
//Activate default behavior for OK-Button:
865+
Button OkButton = (Button) alert.getDialogPane().lookupButton(customOK);
866+
OkButton.setDefaultButton(true);
867+
856868
alert.setHeaderText("blobsaver " + Main.appVersion);
857869
alert.setContentText("blobsaver Copyright (c) 2018 airsquared\n\n" +
858870
"This program is licensed under GNU GPL v3.0-only");
871+
859872
resizeAlertButtons(alert);
860873
alert.showAndWait();
861874
switch (alert.getResult().getText()) {
@@ -885,7 +898,7 @@ public void aboutMenuHandler() {
885898
out.close();
886899
licenseFile.deleteOnExit();
887900
licenseFile.setReadOnly();
888-
java.awt.Desktop.getDesktop().edit(licenseFile);
901+
Desktop.getDesktop().edit(licenseFile);
889902
} catch (IOException e) {
890903
e.printStackTrace();
891904
}
@@ -909,7 +922,7 @@ public void aboutMenuHandler() {
909922
out.close();
910923
libsUsedFile.deleteOnExit();
911924
libsUsedFile.setReadOnly();
912-
java.awt.Desktop.getDesktop().edit(libsUsedFile);
925+
Desktop.getDesktop().edit(libsUsedFile);
913926
} catch (IOException e) {
914927
e.printStackTrace();
915928
}
@@ -956,7 +969,7 @@ private void useMacOSMenuBar() {
956969
windowMenu.getItems().add(tk.createMinimizeMenuItem());
957970
windowMenu.getItems().add(tk.createCycleWindowsItem());
958971

959-
MenuItem debugLogMenuItem = new MenuItem("Open/Close Debug log");
972+
MenuItem debugLogMenuItem = new MenuItem("Open/Close Debug Log");
960973
debugLogMenuItem.setOnAction(event -> {
961974
debugLogHandler();
962975
tk.setMenuBar(DebugWindow.getDebugStage(), macOSMenuBar);
@@ -1135,7 +1148,9 @@ public void resetAppHandler() {
11351148
try {
11361149
Alert confirmationAlert = new Alert(Alert.AlertType.CONFIRMATION, "Are you sure you would like to uninstall this application?", ButtonType.NO, ButtonType.YES);
11371150
confirmationAlert.showAndWait();
1138-
if ((confirmationAlert.getResult() == null) || ButtonType.CANCEL.equals(confirmationAlert.getResult()) || ButtonType.NO.equals(confirmationAlert.getResult())) {
1151+
if ((confirmationAlert.getResult() == null)
1152+
|| ButtonType.CANCEL.equals(confirmationAlert.getResult())
1153+
|| ButtonType.NO.equals(confirmationAlert.getResult())) {
11391154
return;
11401155
}
11411156
Preferences prefs = Preferences.userRoot().node("airsquared/blobsaver");

src/main/resources/com/airsquared/blobsaver/blobsaver.fxml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<VBox maxHeight="Infinity" maxWidth="-Infinity" minHeight="580.0" prefWidth="500.0">
2727
<MenuBar fx:id="menuBar">
2828
<Menu mnemonicParsing="false" text="Options">
29-
<MenuItem mnemonicParsing="false" onAction="#debugLogHandler" text="Debug log"/>
29+
<MenuItem mnemonicParsing="false" onAction="#debugLogHandler" text="Debug Log"/>
3030
<MenuItem mnemonicParsing="false" onAction="#checkBlobs" text="Check for valid blobs..."/>
3131
<MenuItem mnemonicParsing="false" onAction="#checkForUpdatesHandler"
3232
text="Check for Updates..."/>
@@ -48,8 +48,8 @@
4848
text="How do I get a crash log?"/>
4949
</Menu>
5050
<MenuItem mnemonicParsing="false" onAction="#newGithubIssue"
51-
text="Send Feedback(Github Issue)"/>
52-
<MenuItem mnemonicParsing="false" onAction="#sendRedditPM" text="Send Feedback(Reddit PM)"/>
51+
text="Send Feedback (Github Issue)"/>
52+
<MenuItem mnemonicParsing="false" onAction="#sendRedditPM" text="Send Feedback (Reddit PM)"/>
5353
<SeparatorMenuItem mnemonicParsing="false"/>
5454
<MenuItem mnemonicParsing="false" onAction="#donate" text="Donate!"/>
5555
<SeparatorMenuItem mnemonicParsing="false"/>

0 commit comments

Comments
 (0)