Skip to content

Commit

Permalink
Add open settings keyboard shortcut. (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfl28 committed Nov 11, 2023
1 parent 6ddbe9b commit 71410cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,9 @@ private List<KeyCombinationEventHandler> 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())
);
}

Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<MockedConstruction<FileChooser>> mockedFileChooser = createMockedFileChooser(null);
verifyThat(mockedFileChooser.get(), Matchers.notNullValue());
Expand Down

0 comments on commit 71410cf

Please sign in to comment.