Fix command palette Open Settings action routing
This commit is contained in:
parent
566eda80b5
commit
cc06fb84e3
4 changed files with 68 additions and 4 deletions
|
|
@ -3258,9 +3258,27 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
|
|||
)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static func presentPreferencesWindow(
|
||||
sendShowSettingsAction: @MainActor () -> Bool = {
|
||||
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
|
||||
},
|
||||
showFallbackSettingsWindow: @MainActor () -> Void = {
|
||||
SettingsWindowController.shared.show()
|
||||
},
|
||||
activateApplication: @MainActor () -> Void = {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
) {
|
||||
let handledByResponderChain = sendShowSettingsAction()
|
||||
if !handledByResponderChain {
|
||||
showFallbackSettingsWindow()
|
||||
}
|
||||
activateApplication()
|
||||
}
|
||||
|
||||
@objc func openPreferencesWindow() {
|
||||
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
Self.presentPreferencesWindow()
|
||||
}
|
||||
|
||||
func refreshMenuBarExtraForDebug() {
|
||||
|
|
|
|||
|
|
@ -3923,7 +3923,7 @@ struct ContentView: View {
|
|||
AppDelegate.shared?.jumpToLatestUnread()
|
||||
}
|
||||
registry.register(commandId: "palette.openSettings") {
|
||||
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
|
||||
AppDelegate.presentPreferencesWindow()
|
||||
}
|
||||
registry.register(commandId: "palette.checkForUpdates") {
|
||||
AppDelegate.shared?.checkForUpdates(nil)
|
||||
|
|
|
|||
|
|
@ -1701,7 +1701,7 @@ private struct AcknowledgmentsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private final class SettingsWindowController: NSWindowController, NSWindowDelegate {
|
||||
final class SettingsWindowController: NSWindowController, NSWindowDelegate {
|
||||
static let shared = SettingsWindowController()
|
||||
|
||||
private init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue