mac/menu: replace deprecated openFile() usage

This commit is contained in:
der richter 2024-03-03 15:30:20 +01:00
parent 996ec6feca
commit cb807ff063
1 changed files with 8 additions and 8 deletions

View File

@ -298,24 +298,24 @@ class MenuBar: NSObject {
@objc func preferences(_ menuItem: NSMenuItem) { @objc func preferences(_ menuItem: NSMenuItem) {
guard let menuConfig = getConfigFromMenu(menuItem: menuItem), guard let menuConfig = getConfigFromMenu(menuItem: menuItem),
let fileName = menuConfig.file else { return } let fileName = menuConfig.file else { return }
let configPaths: [String] = [ let configPaths: [URL] = [
NSHomeDirectory() + "/.config/mpv/", URL(fileURLWithPath: NSHomeDirectory() + "/.config/mpv/", isDirectory: true),
NSHomeDirectory() + "/.mpv/", URL(fileURLWithPath: NSHomeDirectory() + "/.mpv/", isDirectory: true),
] ]
for path in configPaths { for path in configPaths {
let configFile = path + fileName let configFile = path.appendingPathComponent(fileName, isDirectory: false)
if FileManager.default.fileExists(atPath: configFile) { if FileManager.default.fileExists(atPath: configFile.path) {
if NSWorkspace.shared.openFile(configFile) { if NSWorkspace.shared.open(configFile) {
return return
} }
NSWorkspace.shared.openFile(path) NSWorkspace.shared.open(path)
alert(title: "No Application found to open your config file.", text: "Please open the \(fileName) file with your preferred text editor in the now open folder to edit your config.") alert(title: "No Application found to open your config file.", text: "Please open the \(fileName) file with your preferred text editor in the now open folder to edit your config.")
return return
} }
if NSWorkspace.shared.openFile(path) { if NSWorkspace.shared.open(path) {
alert(title: "No config file found.", text: "Please create a \(fileName) file with your preferred text editor in the now open folder.") alert(title: "No config file found.", text: "Please create a \(fileName) file with your preferred text editor in the now open folder.")
return return
} }