Skip to content

Commit

Permalink
#20 Add exit button in menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
introfog committed Nov 3, 2024
1 parent e8bd5b3 commit 3e26c8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,7 @@ public void initialize(FxmlStageHolder fxmlStageHolder) {
super.initialize(fxmlStageHolder);
final Stage primaryStage = fxmlStageHolder.getStage();
primaryStage.setOnCloseRequest(event -> {
event.consume();

AppConfig.getInstance().closeApp();
for (ExecutionController controller: new ArrayList<>(executionTabs.values())) {
controller.close();
}
executionTabPage.getTabs().clear();
primaryStage.close();
close();
});

directoryTabController = new DirectoryTabController(fxmlStageHolder, directory);
Expand Down Expand Up @@ -148,6 +141,12 @@ protected void openAbout() {
menuController.openAbout();
}

@FXML
protected void exitFromMenu() {
close();
closeStage();
}

@FXML
protected void openUpdate() {
menuController.openUpdate();
Expand All @@ -157,4 +156,12 @@ protected void openUpdate() {
protected void foundIssue() {
AppConfig.getInstance().getHostServices().showDocument(AppConstants.LINK_TO_GIT_CONTRIBUTING_FILE);
}

private void close() {
AppConfig.getInstance().closeApp();
for (ExecutionController controller: new ArrayList<>(executionTabs.values())) {
controller.close();
}
executionTabPage.getTabs().clear();
}
}
2 changes: 2 additions & 0 deletions src/main/resources/com/github/introfog/gitwave/view/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<MenuItem mnemonicParsing="false" onAction="#openAbout" text="About" />
<SeparatorMenuItem fx:id="updateMenuItemSeparator" disable="true" mnemonicParsing="false" visible="false" />
<MenuItem fx:id="updateMenuItem" disable="true" mnemonicParsing="false" onAction="#openUpdate" text="Update*" visible="false" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" onAction="#exitFromMenu" text="Exit" />
</items>
</Menu>
</menus>
Expand Down

0 comments on commit 3e26c8f

Please sign in to comment.