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