diff --git a/src/main/java/com/github/mfl28/boundingboxeditor/controller/Controller.java b/src/main/java/com/github/mfl28/boundingboxeditor/controller/Controller.java index 35e6eba..2a1c0ef 100644 --- a/src/main/java/com/github/mfl28/boundingboxeditor/controller/Controller.java +++ b/src/main/java/com/github/mfl28/boundingboxeditor/controller/Controller.java @@ -783,7 +783,9 @@ private List createKeyCombinationHandlers() { new KeyCombinationEventHandler(KeyCombinations.simplifyPolygon, null, event -> view.simplifyCurrentSelectedBoundingPolygon()), new KeyCombinationEventHandler(KeyCombinations.saveBoundingShapeAsImage, - null, event -> view.saveCurrentSelectedBoundingShapeAsImage()) + null, event -> view.saveCurrentSelectedBoundingShapeAsImage()), + new KeyCombinationEventHandler(KeyCombinations.openSettings, + null, event -> onRegisterSettingsAction()) ); } @@ -1654,6 +1656,9 @@ public static class KeyCombinations { public static final KeyCombination saveBoundingShapeAsImage = new KeyCodeCombination(KeyCode.I, KeyCombination.SHIFT_DOWN); + public static final KeyCombination openSettings = + new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN); + private KeyCombinations() { throw new IllegalStateException("Key Combination Class"); } diff --git a/src/test/java/com/github/mfl28/boundingboxeditor/controller/SceneKeyShortcutTests.java b/src/test/java/com/github/mfl28/boundingboxeditor/controller/SceneKeyShortcutTests.java index 6b7d292..db5eacf 100644 --- a/src/test/java/com/github/mfl28/boundingboxeditor/controller/SceneKeyShortcutTests.java +++ b/src/test/java/com/github/mfl28/boundingboxeditor/controller/SceneKeyShortcutTests.java @@ -26,6 +26,7 @@ import javafx.event.EventType; import javafx.geometry.Point2D; import javafx.scene.Cursor; +import javafx.scene.control.ButtonType; import javafx.scene.input.*; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -74,9 +75,10 @@ void onSceneKeyPressed_ShouldPerformCorrectAction(TestInfo testinfo, FxRobot rob Controller.KeyCombinations.selectFreehandDrawingMode, Controller.KeyCombinations.removeEditingVerticesWhenBoundingPolygonSelected, Controller.KeyCombinations.changeSelectedBoundingShapeCategory, Controller.KeyCombinations.hideNonSelectedBoundingShapes, Controller.KeyCombinations.simplifyPolygon, - Controller.KeyCombinations.saveBoundingShapeAsImage + Controller.KeyCombinations.saveBoundingShapeAsImage, Controller.KeyCombinations.openSettings )); + testOpenSettingsKeyEvent(robot, testinfo); testNavigateNextKeyEvent(testinfo, true, true, "wexor-tmg-L-2p8fapOA8-unsplash.jpg"); testNavigatePreviousKeyEvent(testinfo, true, true, "rachel-hisko-rEM3cK8F1pk-unsplash.jpg"); testNavigateNextKeyEvent(testinfo, false, true, "wexor-tmg-L-2p8fapOA8-unsplash.jpg"); @@ -172,6 +174,20 @@ void onSceneKeyPressed_ShouldPerformCorrectAction(TestInfo testinfo, FxRobot rob testResetImageViewSizeKeyEvent(robot); } + private void testOpenSettingsKeyEvent(FxRobot robot, TestInfo testinfo) { + KeyEvent openSettingsKeyEvent = buildKeyEventFromCombination((KeyCodeCombination) Controller.KeyCombinations.openSettings, KeyEvent.KEY_RELEASED); + Platform.runLater(() -> controller.onRegisterSceneKeyReleased(openSettingsKeyEvent)); + WaitForAsyncUtils.waitForFxEvents(); + + final Stage settingsStage = timeOutGetTopModalStage(robot, "Settings", testinfo); + verifyThat(settingsStage.isShowing(), Matchers.is(true), saveScreenshot(testinfo)); + + timeOutClickOnButtonInDialogStage(robot, settingsStage, ButtonType.CANCEL, testinfo); + timeOutAssertNoTopModelStage(robot, testinfo); + + verifyThat(settingsStage.isShowing(), Matchers.is(false)); + } + private void testSaveCurrentlySelectedBoundingShapeKeyEvent() { final AtomicReference> mockedFileChooser = createMockedFileChooser(null); verifyThat(mockedFileChooser.get(), Matchers.notNullValue());