Added keybinding to show open dialog
This commit is contained in:
parent
ef367e1d89
commit
c92ccf1f6d
@ -67,6 +67,11 @@ enum class KeybindingOption {
|
||||
* Used to pop stash changes to workspace
|
||||
*/
|
||||
STASH_POP,
|
||||
|
||||
/**
|
||||
* Used to pop stash changes to workspace
|
||||
*/
|
||||
OPEN_ANOTHER_REPOSITORY,
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +111,9 @@ private fun baseKeybindings() = mapOf(
|
||||
KeybindingOption.STASH_POP to listOf(
|
||||
Keybinding(key = Key.S, control = true, shift = true),
|
||||
),
|
||||
KeybindingOption.OPEN_ANOTHER_REPOSITORY to listOf(
|
||||
Keybinding(key = Key.O, control = true),
|
||||
),
|
||||
)
|
||||
|
||||
private fun linuxKeybindings(): Map<KeybindingOption, List<Keybinding>> = baseKeybindings()
|
||||
|
@ -50,12 +50,12 @@ fun Menu(
|
||||
onStashWithMessage: () -> Unit,
|
||||
onQuickActions: () -> Unit,
|
||||
onShowSettingsDialog: () -> Unit,
|
||||
showOpenPopup: Boolean,
|
||||
onShowOpenPopupChange: (Boolean) -> Unit,
|
||||
) {
|
||||
val isPullWithRebaseDefault by menuViewModel.isPullWithRebaseDefault.collectAsState()
|
||||
val lastLoadedTabs by menuViewModel.lastLoadedTabs.collectAsState()
|
||||
val (position, setPosition) = remember { mutableStateOf<LayoutCoordinates?>(null) }
|
||||
var showOpenPopup by remember { mutableStateOf(false) }
|
||||
|
||||
|
||||
Row(
|
||||
modifier = modifier,
|
||||
@ -72,7 +72,7 @@ fun Menu(
|
||||
.onGloballyPositioned { setPosition(it) },
|
||||
title = "Open",
|
||||
icon = painterResource(AppIcons.OPEN),
|
||||
onClick = { showOpenPopup = true },
|
||||
onClick = { onShowOpenPopupChange(true) },
|
||||
)
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ fun Menu(
|
||||
return IntOffset(boundsInRoot.left.toInt(), boundsInRoot.bottom.toInt())
|
||||
}
|
||||
},
|
||||
onDismissRequest = { showOpenPopup = false },
|
||||
onDismissRequest = { onShowOpenPopupChange(false) },
|
||||
properties = PopupProperties(focusable = true),
|
||||
) {
|
||||
val searchFocusRequester = remember { FocusRequester() }
|
||||
@ -223,7 +223,7 @@ fun Menu(
|
||||
PrimaryButton(
|
||||
text = "Open a repository",
|
||||
onClick = {
|
||||
showOpenPopup = false
|
||||
onShowOpenPopupChange(false)
|
||||
onOpenAnotherRepositoryFromPicker()
|
||||
},
|
||||
modifier = Modifier
|
||||
@ -237,7 +237,7 @@ fun Menu(
|
||||
searchFieldFocusRequester = searchFocusRequester,
|
||||
onRemoveRepositoryFromRecent = {},
|
||||
onOpenKnownRepository = {
|
||||
showOpenPopup = false
|
||||
onShowOpenPopupChange(false)
|
||||
onOpenAnotherRepository(it)
|
||||
},
|
||||
)
|
||||
|
@ -10,10 +10,8 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.AppConstants
|
||||
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
||||
@ -108,13 +106,13 @@ fun RepositoryOpenPage(
|
||||
}
|
||||
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
var showOpenPopup by remember { mutableStateOf(false) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.focusable(true)
|
||||
.onPreviewKeyEvent {
|
||||
println("onPreviewKeyEvent: $it")
|
||||
when {
|
||||
it.matchesBinding(KeybindingOption.PULL) -> {
|
||||
repositoryOpenViewModel.pull(PullType.DEFAULT)
|
||||
@ -155,6 +153,11 @@ fun RepositoryOpenPage(
|
||||
true
|
||||
}
|
||||
|
||||
it.matchesBinding(KeybindingOption.OPEN_ANOTHER_REPOSITORY) -> {
|
||||
showOpenPopup = true
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
@ -182,7 +185,9 @@ fun RepositoryOpenPage(
|
||||
}
|
||||
},
|
||||
onQuickActions = { showQuickActionsDialog = true },
|
||||
onShowSettingsDialog = onShowSettingsDialog
|
||||
onShowSettingsDialog = onShowSettingsDialog,
|
||||
showOpenPopup = showOpenPopup,
|
||||
onShowOpenPopupChange = { showOpenPopup = it }
|
||||
)
|
||||
|
||||
RepoContent(
|
||||
|
Loading…
Reference in New Issue
Block a user