Skip to content

Commit ba0e937

Browse files
committed
Implemented settings keybinding and other labels
1 parent 1d3a76e commit ba0e937

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/main/kotlin/com/jetpackduba/gitnuro/keybindings/Keybinding.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ enum class KeybindingOption {
9292
* Used to change current tab to the one in the right
9393
*/
9494
CHANGE_CURRENT_TAB_RIGHT,
95+
96+
/**
97+
* Used to open the settings screen
98+
*/
99+
SETTINGS,
95100
}
96101

97102

@@ -148,6 +153,9 @@ private fun baseKeybindings() = mapOf(
148153
Keybinding(key = Key.DirectionRight, alt = true),
149154
Keybinding(key = Key.Tab, control = true),
150155
),
156+
KeybindingOption.SETTINGS to listOf(
157+
Keybinding(key = Key.S, control = true, alt = true),
158+
),
151159
)
152160

153161
private fun linuxKeybindings(): Map<KeybindingOption, List<Keybinding>> = baseKeybindings()

src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fun Menu(
9696
title = "Pull",
9797
tooltipText = pullTooltip,
9898
icon = painterResource(AppIcons.DOWNLOAD),
99+
keybinding = KeybindingOption.PULL.keyBinding,
99100
onClick = { menuViewModel.pull(PullType.DEFAULT) },
100101
extendedListItems = pullContextMenuItems(
101102
isPullWithRebaseDefault = isPullWithRebaseDefault,
@@ -120,6 +121,7 @@ fun Menu(
120121
tooltipText = "Push current branch changes",
121122
icon = painterResource(AppIcons.UPLOAD),
122123
onClick = { menuViewModel.push() },
124+
keybinding = KeybindingOption.PUSH.keyBinding,
123125
extendedListItems = pushContextMenuItems(
124126
onPushWithTags = {
125127
menuViewModel.push(force = false, pushTags = true)
@@ -150,6 +152,7 @@ fun Menu(
150152
title = "Stash",
151153
tooltipText = "Stash uncommitted changes",
152154
icon = painterResource(AppIcons.STASH),
155+
keybinding = KeybindingOption.STASH.keyBinding,
153156
onClick = { menuViewModel.stash() },
154157
extendedListItems = stashContextMenuItems(
155158
onStashWithMessage = onStashWithMessage
@@ -191,7 +194,7 @@ fun Menu(
191194
icon = painterResource(AppIcons.SETTINGS),
192195
onClick = onShowSettingsDialog,
193196
tooltip = "Gitnuro's settings",
194-
keybinding = KeybindingOption.STASH_POP.keyBinding,
197+
keybinding = KeybindingOption.SETTINGS.keyBinding,
195198
)
196199
}
197200
}
@@ -399,6 +402,7 @@ fun ExtendedMenuButton(
399402
title: String,
400403
tooltipText: String,
401404
icon: Painter,
405+
keybinding: Keybinding?,
402406
onClick: () -> Unit,
403407
extendedListItems: List<ContextMenuElement>,
404408
) {
@@ -415,6 +419,11 @@ fun ExtendedMenuButton(
415419
modifier = Modifier
416420
.fillMaxHeight()
417421
.weight(1f),
422+
trailingContent = if (keybinding != null) {
423+
{ KeybindingHint(keybinding) }
424+
} else {
425+
null
426+
}
418427
) {
419428
Column(
420429
modifier = Modifier

src/main/kotlin/com/jetpackduba/gitnuro/ui/RepositoryOpen.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ fun RepositoryOpenPage(
158158
true
159159
}
160160

161+
it.matchesBinding(KeybindingOption.SETTINGS) -> {
162+
onShowSettingsDialog()
163+
true
164+
}
165+
161166
else -> false
162167
}
163168

src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ fun WelcomeView(
136136
onOpenRepository()
137137
true
138138
}
139+
it.matchesBinding(KeybindingOption.SETTINGS) -> {
140+
onShowSettings()
141+
true
142+
}
139143
else -> false
140144
}
141145
},

0 commit comments

Comments
 (0)