Skip to content

Commit 1f56b94

Browse files
committed
ui: browser view shortcuts
Signed-off-by: Tommy van der Vorst <tommy@pixelspark.nl>
1 parent db1fb22 commit 1f56b94

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sushitrain/BrowserView.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct BrowserView: View {
102102

103103
@Environment(AppState.self) private var appState
104104
@Environment(\.showToast) private var showToast
105+
@Environment(\.refresh) private var refreshAction: RefreshAction?
105106

106107
var folder: SushitrainFolder
107108
var prefix: String
@@ -372,15 +373,19 @@ struct BrowserView: View {
372373
Picker("View as", selection: self.currentViewStyle()) {
373374
Image(systemName: "list.bullet").tag(BrowserViewStyle.list)
374375
.accessibilityLabel(Text("List"))
376+
.keyboardShortcut("1", modifiers: .command)
375377
Image(systemName: "checklist.unchecked").tag(BrowserViewStyle.thumbnailList)
376378
.accessibilityLabel(Text("List with previews"))
379+
.keyboardShortcut("2", modifiers: .command)
377380
Image(systemName: "square.grid.2x2").tag(BrowserViewStyle.grid)
378381
.accessibilityLabel(Text("Grid"))
382+
.keyboardShortcut("3", modifiers: .command)
379383

380384
if webViewAvailable {
381385
Image(systemName: "doc.text.image")
382386
.tag(BrowserViewStyle.web)
383387
.accessibilityLabel(Text("Web page"))
388+
.keyboardShortcut("4", modifiers: .command)
384389
}
385390
}
386391
.pickerStyle(.segmented)
@@ -394,7 +399,9 @@ struct BrowserView: View {
394399
#if os(macOS)
395400
Button(openInFilesAppLabel, systemImage: "arrow.up.forward.app") {
396401
self.showInFinder()
397-
}.disabled(!canShowInFinder || isSearching)
402+
}
403+
.disabled(!canShowInFinder || isSearching)
404+
.keyboardShortcut("G", modifiers: .command)
398405
#endif
399406

400407
self.folderMenu()
@@ -567,6 +574,14 @@ struct BrowserView: View {
567574
#if os(macOS)
568575
.buttonStyle(.link)
569576
#endif
577+
.keyboardShortcut("R", modifiers: [.command, .shift])
578+
579+
Button("Refresh", systemImage: "arrow.clockwise") {
580+
Task {
581+
Log.info("Refresh from menu")
582+
await self.refreshAction?()
583+
}
584+
}.keyboardShortcut("R", modifiers: .command)
570585

571586
Divider()
572587

0 commit comments

Comments
 (0)