From aab0e01a30151e3073bc3b99d683266726b91cdb Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 14 Sep 2024 15:50:08 +0200 Subject: [PATCH] Open repository keybinding can also be used in welcome page to open file explorer --- .../com/jetpackduba/gitnuro/keybindings/Keybinding.kt | 6 +++--- .../kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt | 3 +-- .../kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt | 9 +++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/keybindings/Keybinding.kt b/src/main/kotlin/com/jetpackduba/gitnuro/keybindings/Keybinding.kt index 97b5253..e9b2ba2 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/keybindings/Keybinding.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/keybindings/Keybinding.kt @@ -69,9 +69,9 @@ enum class KeybindingOption { STASH_POP, /** - * Used to pop stash changes to workspace + * Used to open a repository */ - OPEN_ANOTHER_REPOSITORY, + OPEN_REPOSITORY, /** * Used to open a new tab @@ -131,7 +131,7 @@ private fun baseKeybindings() = mapOf( KeybindingOption.STASH_POP to listOf( Keybinding(key = Key.S, control = true, shift = true), ), - KeybindingOption.OPEN_ANOTHER_REPOSITORY to listOf( + KeybindingOption.OPEN_REPOSITORY to listOf( Keybinding(key = Key.O, control = true), ), KeybindingOption.OPEN_NEW_TAB to listOf( diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt index f2fffb5..ddd0718 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt @@ -22,7 +22,6 @@ import com.jetpackduba.gitnuro.keybindings.KeybindingOption import com.jetpackduba.gitnuro.keybindings.matchesBinding import com.jetpackduba.gitnuro.models.AuthorInfoSimple import com.jetpackduba.gitnuro.ui.components.SecondaryButton -import com.jetpackduba.gitnuro.ui.components.TabInformation import com.jetpackduba.gitnuro.ui.components.TripleVerticalSplitPanel import com.jetpackduba.gitnuro.ui.dialogs.* import com.jetpackduba.gitnuro.ui.diff.Diff @@ -154,7 +153,7 @@ fun RepositoryOpenPage( true } - it.matchesBinding(KeybindingOption.OPEN_ANOTHER_REPOSITORY) -> { + it.matchesBinding(KeybindingOption.OPEN_REPOSITORY) -> { showOpenPopup = true true } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt index 1404f5e..b2c7293 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt @@ -130,6 +130,15 @@ fun WelcomeView( .focusable(true) .focusRequester(welcomeViewFocusRequester) .background(MaterialTheme.colors.surface) + .onPreviewKeyEvent { + when { + it.matchesBinding(KeybindingOption.OPEN_REPOSITORY) -> { + onOpenRepository() + true + } + else -> false + } + }, ) { Column(