Skip to content

Commit

Permalink
Implemented settings keybinding and other labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JetpackDuba committed Feb 22, 2025
1 parent 1d3a76e commit ba0e937
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ enum class KeybindingOption {
* Used to change current tab to the one in the right
*/
CHANGE_CURRENT_TAB_RIGHT,

/**
* Used to open the settings screen
*/
SETTINGS,
}


Expand Down Expand Up @@ -148,6 +153,9 @@ private fun baseKeybindings() = mapOf(
Keybinding(key = Key.DirectionRight, alt = true),
Keybinding(key = Key.Tab, control = true),
),
KeybindingOption.SETTINGS to listOf(
Keybinding(key = Key.S, control = true, alt = true),
),
)

private fun linuxKeybindings(): Map<KeybindingOption, List<Keybinding>> = baseKeybindings()
Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fun Menu(
title = "Pull",
tooltipText = pullTooltip,
icon = painterResource(AppIcons.DOWNLOAD),
keybinding = KeybindingOption.PULL.keyBinding,
onClick = { menuViewModel.pull(PullType.DEFAULT) },
extendedListItems = pullContextMenuItems(
isPullWithRebaseDefault = isPullWithRebaseDefault,
Expand All @@ -120,6 +121,7 @@ fun Menu(
tooltipText = "Push current branch changes",
icon = painterResource(AppIcons.UPLOAD),
onClick = { menuViewModel.push() },
keybinding = KeybindingOption.PUSH.keyBinding,
extendedListItems = pushContextMenuItems(
onPushWithTags = {
menuViewModel.push(force = false, pushTags = true)
Expand Down Expand Up @@ -150,6 +152,7 @@ fun Menu(
title = "Stash",
tooltipText = "Stash uncommitted changes",
icon = painterResource(AppIcons.STASH),
keybinding = KeybindingOption.STASH.keyBinding,
onClick = { menuViewModel.stash() },
extendedListItems = stashContextMenuItems(
onStashWithMessage = onStashWithMessage
Expand Down Expand Up @@ -191,7 +194,7 @@ fun Menu(
icon = painterResource(AppIcons.SETTINGS),
onClick = onShowSettingsDialog,
tooltip = "Gitnuro's settings",
keybinding = KeybindingOption.STASH_POP.keyBinding,
keybinding = KeybindingOption.SETTINGS.keyBinding,
)
}
}
Expand Down Expand Up @@ -399,6 +402,7 @@ fun ExtendedMenuButton(
title: String,
tooltipText: String,
icon: Painter,
keybinding: Keybinding?,
onClick: () -> Unit,
extendedListItems: List<ContextMenuElement>,
) {
Expand All @@ -415,6 +419,11 @@ fun ExtendedMenuButton(
modifier = Modifier
.fillMaxHeight()
.weight(1f),
trailingContent = if (keybinding != null) {
{ KeybindingHint(keybinding) }
} else {
null
}
) {
Column(
modifier = Modifier
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ fun RepositoryOpenPage(
true
}

it.matchesBinding(KeybindingOption.SETTINGS) -> {
onShowSettingsDialog()
true
}

else -> false
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ fun WelcomeView(
onOpenRepository()
true
}
it.matchesBinding(KeybindingOption.SETTINGS) -> {
onShowSettings()
true
}
else -> false
}
},
Expand Down

0 comments on commit ba0e937

Please sign in to comment.