Files
openclaw/apps/macos/Sources/OpenClaw/SettingsWindowOpener.swift
Peter Steinberger 2264816f1d ci(macos): add enforced periphery dead-code lane and delete the 12 current findings (#105743)
* refactor(macos): delete dead code flagged by periphery

* ci(macos): add enforced periphery dead-code lane

* fix(ci): scope-label the periphery skip message

* chore(i18n): sync native inventory line coordinates
2026-07-12 16:39:15 -07:00

37 lines
1.0 KiB
Swift

import AppKit
@objc
private protocol SettingsWindowMenuActions {
@objc(showSettingsWindow:)
optional func showSettingsWindow(_ sender: Any?)
@objc(showPreferencesWindow:)
optional func showPreferencesWindow(_ sender: Any?)
}
@MainActor
final class SettingsWindowOpener {
static let shared = SettingsWindowOpener()
static let windowID = "settings"
private var openSettingsAction: (@MainActor () -> Void)?
func register(openWindow: @escaping @MainActor () -> Void) {
self.openSettingsAction = openWindow
}
func open() {
NSApp.activate(ignoringOtherApps: true)
if let openSettingsAction {
openSettingsAction()
return
}
// Fallback path: mimic the built-in Settings menu item action.
let didOpen = NSApp.sendAction(#selector(SettingsWindowMenuActions.showSettingsWindow(_:)), to: nil, from: nil)
if !didOpen {
_ = NSApp.sendAction(#selector(SettingsWindowMenuActions.showPreferencesWindow(_:)), to: nil, from: nil)
}
}
}