SwiftPackages // Boost platform req. to macOS 11.

This commit is contained in:
ShikiSuen 2023-09-29 10:35:56 +08:00
parent 293582fa5d
commit 5b11ffec44
35 changed files with 97 additions and 123 deletions

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "FolderMonitor", name: "FolderMonitor",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "NSAttributedTextView", name: "NSAttributedTextView",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "BookmarkManager", name: "BookmarkManager",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -34,10 +34,8 @@ public class BookmarkManager {
if fileExists(url) { if fileExists(url) {
do { do {
let fileData = try Data(contentsOf: url) let fileData = try Data(contentsOf: url)
if let fileBookmarks = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(fileData) as! [URL: Data]? { try (NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: fileData) as? [URL: Data])?.forEach { bookmark in
for bookmark in fileBookmarks { restoreBookmark(key: bookmark.key, value: bookmark.value)
restoreBookmark(key: bookmark.key, value: bookmark.value)
}
} }
} catch { } catch {
NSLog("Couldn't load bookmarks") NSLog("Couldn't load bookmarks")
@ -82,12 +80,7 @@ public class BookmarkManager {
} }
private func getBookmarkURL() -> URL? { private func getBookmarkURL() -> URL? {
let urls = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask) FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last?.appendingPathComponent("Bookmarks.dict")
if let appSupportURL = urls.last {
let url = appSupportURL.appendingPathComponent("Bookmarks.dict")
return url
}
return nil
} }
private func fileExists(_ url: URL) -> Bool { private func fileExists(_ url: URL) -> Bool {

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "ShiftKeyUpChecker", name: "ShiftKeyUpChecker",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "LineReader", name: "LineReader",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "CandidateWindow", name: "CandidateWindow",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -17,7 +17,7 @@ open class CtlCandidate: NSWindowController, CtlCandidateProtocol {
open var reverseLookupResult: [String] = [] open var reverseLookupResult: [String] = []
open func highlightedColor() -> NSColor { open func highlightedColor() -> NSColor {
var result = NSColor.alternateSelectedControlColor var result = NSColor.controlAccentColor
var colorBlendAmount: Double = NSApplication.isDarkMode ? 0.3 : 0.0 var colorBlendAmount: Double = NSApplication.isDarkMode ? 0.3 : 0.0
if #available(macOS 10.14, *), !NSApplication.isDarkMode, locale == "zh-Hant" { if #available(macOS 10.14, *), !NSApplication.isDarkMode, locale == "zh-Hant" {
colorBlendAmount = 0.15 colorBlendAmount = 0.15

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "CocoaExtension", name: "CocoaExtension",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "Hotenka", name: "Hotenka",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "IMKUtils", name: "IMKUtils",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "LangModelAssembly", name: "LangModelAssembly",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -1,10 +1,10 @@
// swift-tools-version:5.3 // swift-tools-version:5.7
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "MainAssembly", name: "MainAssembly",
platforms: [ platforms: [
.macOS(.v10_13), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -13,9 +13,10 @@ import FolderMonitor
import Shared import Shared
import Uninstaller import Uninstaller
import UpdateSputnik import UpdateSputnik
import UserNotifications
@objc(AppDelegate) @objc(AppDelegate)
public class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate { public class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
public static let shared = AppDelegate() public static let shared = AppDelegate()
private var folderMonitor = FolderMonitor( private var folderMonitor = FolderMonitor(
@ -58,12 +59,11 @@ extension AppDelegate {
// MARK: - Public Functions // MARK: - Public Functions
public extension AppDelegate { public extension AppDelegate {
func userNotificationCenter(_: NSUserNotificationCenter, shouldPresent _: NSUserNotification) -> Bool {
true
}
func applicationWillFinishLaunching(_: Notification) { func applicationWillFinishLaunching(_: Notification) {
NSUserNotificationCenter.default.delegate = self UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge], completionHandler: { _, _ in })
PrefMgr.shared.fixOddPreferences() PrefMgr.shared.fixOddPreferences()
// 使 // 使
@ -72,14 +72,17 @@ public extension AppDelegate {
if PrefMgr.shared.failureFlagForUOMObservation { if PrefMgr.shared.failureFlagForUOMObservation {
LMMgr.relocateWreckedUOMData() LMMgr.relocateWreckedUOMData()
PrefMgr.shared.failureFlagForUOMObservation = false PrefMgr.shared.failureFlagForUOMObservation = false
let userNotification = NSUserNotification() let msgPackage = UNMutableNotificationContent()
userNotification.title = NSLocalizedString("vChewing", comment: "") msgPackage.title = NSLocalizedString("vChewing", comment: "")
userNotification.informativeText = NSLocalizedString( msgPackage.body = NSLocalizedString(
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.", "vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.",
comment: "" comment: ""
) )
userNotification.soundName = NSUserNotificationDefaultSoundName msgPackage.sound = .defaultCritical
NSUserNotificationCenter.default.deliver(userNotification) UNUserNotificationCenter.current().add(
.init(identifier: "vChewing.notification.uomCrash", content: msgPackage, trigger: nil),
withCompletionHandler: nil
)
} }
if !PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() } if !PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() }
@ -125,14 +128,15 @@ public extension AppDelegate {
alert.addButton(withTitle: NSLocalizedString("Not Now", comment: "")) alert.addButton(withTitle: NSLocalizedString("Not Now", comment: ""))
let result = alert.runModal() let result = alert.runModal()
NSApp.popup() NSApp.popup()
if result == NSApplication.ModalResponse.alertFirstButtonReturn { guard result == NSApplication.ModalResponse.alertFirstButtonReturn else { return }
NSWorkspace.shared.openFile( let url = URL(fileURLWithPath: LMMgr.dataFolderPath(isDefaultFolder: true))
LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder" guard let finderURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.finder") else { return }
) let configuration = NSWorkspace.OpenConfiguration()
Uninstaller.uninstall( configuration.promptsUserIfNeeded = true
isSudo: false, selfKill: true, defaultDataFolderPath: LMMgr.dataFolderPath(isDefaultFolder: true) NSWorkspace.shared.open([url], withApplicationAt: finderURL, configuration: configuration)
) Uninstaller.uninstall(
} isSudo: false, selfKill: true, defaultDataFolderPath: LMMgr.dataFolderPath(isDefaultFolder: true)
)
} }
/// ///
@ -143,13 +147,19 @@ public extension AppDelegate {
switch currentMemorySize { switch currentMemorySize {
case 768...: case 768...:
vCLog("WARNING: EXCESSIVE MEMORY FOOTPRINT (\(currentMemorySize)MB).") vCLog("WARNING: EXCESSIVE MEMORY FOOTPRINT (\(currentMemorySize)MB).")
let userNotification = NSUserNotification() let msgPackage = UNMutableNotificationContent()
userNotification.title = NSLocalizedString("vChewing", comment: "") msgPackage.title = NSLocalizedString("vChewing", comment: "")
userNotification.informativeText = NSLocalizedString( msgPackage.body = NSLocalizedString(
"vChewing is rebooted due to a memory-excessive-usage problem. If convenient, please inform the developer that you are having this issue, stating whether you are using an Intel Mac or Apple Silicon Mac. An NSLog is generated with the current memory footprint size.", "vChewing is rebooted due to a memory-excessive-usage problem. If convenient, please inform the developer that you are having this issue, stating whether you are using an Intel Mac or Apple Silicon Mac. An NSLog is generated with the current memory footprint size.",
comment: "" comment: ""
) )
NSUserNotificationCenter.default.deliver(userNotification) UNUserNotificationCenter.current().add(
.init(
identifier: "vChewing.notification.memoryExcessiveUsage",
content: msgPackage, trigger: nil
),
withCompletionHandler: nil
)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
NSApp.terminate(self) NSApp.terminate(self)
} }

View File

@ -17,8 +17,8 @@ import Shared
extension LMMgr: PhraseEditorDelegate { extension LMMgr: PhraseEditorDelegate {
public var currentInputMode: Shared.InputMode { IMEApp.currentInputMode } public var currentInputMode: Shared.InputMode { IMEApp.currentInputMode }
public func openPhraseFile(mode: Shared.InputMode, type: vChewingLM.ReplacableUserDataType, app: String) { public func openPhraseFile(mode: Shared.InputMode, type: vChewingLM.ReplacableUserDataType, appIdentifier: String) {
Self.openPhraseFile(fromURL: Self.userDictDataURL(mode: mode, type: type), app: app) Self.openPhraseFile(fromURL: Self.userDictDataURL(mode: mode, type: type), appIdentifier: appIdentifier)
} }
public func consolidate(text strProcessed: inout String, pragma shouldCheckPragma: Bool) { public func consolidate(text strProcessed: inout String, pragma shouldCheckPragma: Bool) {

View File

@ -311,50 +311,29 @@ public extension LMMgr {
} }
static func openUserDictFile(type: vChewingLM.ReplacableUserDataType, dual: Bool = false, alt: Bool) { static func openUserDictFile(type: vChewingLM.ReplacableUserDataType, dual: Bool = false, alt: Bool) {
let app: String = alt ? "" : "Finder" let appIdentifier: String = alt ? "" : "Finder"
openPhraseFile(fromURL: userDictDataURL(mode: IMEApp.currentInputMode, type: type), app: app) openPhraseFile(fromURL: userDictDataURL(mode: IMEApp.currentInputMode, type: type), appIdentifier: appIdentifier)
guard dual else { return } guard dual else { return }
openPhraseFile(fromURL: userDictDataURL(mode: IMEApp.currentInputMode.reversed, type: type), app: app) openPhraseFile(fromURL: userDictDataURL(mode: IMEApp.currentInputMode.reversed, type: type), appIdentifier: appIdentifier)
} }
/// ///
/// - Remark: App Sandbox app "vim" Sandbox /// - Remark: App Sandbox app "vim" Sandbox
/// - Parameters: /// - Parameters:
/// - url: URL /// - url: URL
/// - app: App binary /// - appIdentifier: App bundle identifier
static func openPhraseFile(fromURL url: URL, app: String = "") { static func openPhraseFile(fromURL url: URL, appIdentifier: String = "") {
if !Self.checkIfUserFilesExistBeforeOpening() { return } if !Self.checkIfUserFilesExistBeforeOpening() { return }
DispatchQueue.main.async { DispatchQueue.main.async {
switch app { switch appIdentifier {
case "vim":
let process = Process()
let pipe = Pipe()
process.executableURL = URL(fileURLWithPath: "/bin/sh/")
process.arguments = ["-c", "open '/usr/bin/vim'", "'\(url.path)'"]
process.standardOutput = pipe
process.standardError = pipe
process.terminationHandler = { process in
vCLog("\ndidFinish: \(!process.isRunning)")
}
let fileHandle = pipe.fileHandleForReading
do {
try process.run()
} catch {
NSWorkspace.shared.openFile(url.path, withApplication: "TextEdit")
}
do {
if let theData = try fileHandle.readToEnd(),
let outStr = String(data: theData, encoding: .utf8)
{
vCLog(outStr)
}
} catch {}
case "Finder": case "Finder":
NSWorkspace.shared.activateFileViewerSelecting([url]) NSWorkspace.shared.activateFileViewerSelecting([url])
default: default:
if !NSWorkspace.shared.openFile(url.path, withApplication: app) { guard let textEditURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.TextEdit") else { return }
NSWorkspace.shared.openFile(url.path, withApplication: "TextEdit") let toolURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: appIdentifier) ?? textEditURL
} let configuration = NSWorkspace.OpenConfiguration()
configuration.promptsUserIfNeeded = true
NSWorkspace.shared.open([url], withApplicationAt: toolURL, configuration: configuration)
} }
} }
} }

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "Megrez", name: "Megrez",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "NotifierUI", name: "NotifierUI",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "PhraseEditorUI", name: "PhraseEditorUI",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -17,6 +17,6 @@ public protocol PhraseEditorDelegate {
-> String -> String
func checkIfPhrasePairExists(userPhrase: String, mode: Shared.InputMode, key unigramKey: String) -> Bool func checkIfPhrasePairExists(userPhrase: String, mode: Shared.InputMode, key unigramKey: String) -> Bool
func consolidate(text strProcessed: inout String, pragma shouldCheckPragma: Bool) func consolidate(text strProcessed: inout String, pragma shouldCheckPragma: Bool)
func openPhraseFile(mode: Shared.InputMode, type: vChewingLM.ReplacableUserDataType, app: String) func openPhraseFile(mode: Shared.InputMode, type: vChewingLM.ReplacableUserDataType, appIdentifier: String)
func tagOverrides(in strProcessed: inout String, mode: Shared.InputMode) func tagOverrides(in strProcessed: inout String, mode: Shared.InputMode)
} }

View File

@ -186,8 +186,8 @@ public struct VwrPhraseEditorUI: View {
} }
private func callExternalAppToOpenPhraseFile() { private func callExternalAppToOpenPhraseFile() {
let app: String = NSEvent.keyModifierFlags.contains(.option) ? "TextEdit" : "Finder" let app: String = NSEvent.keyModifierFlags.contains(.option) ? "com.apple.TextEdit" : "com.apple.finder"
delegate?.openPhraseFile(mode: selInputMode, type: selUserDataType, app: app) delegate?.openPhraseFile(mode: selInputMode, type: selUserDataType, appIdentifier: app)
} }
// MARK: - Main View. // MARK: - Main View.

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "PinyinPhonaConverter", name: "PinyinPhonaConverter",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "PopupCompositionBuffer", name: "PopupCompositionBuffer",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "Shared", name: "Shared",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "SwiftExtension", name: "SwiftExtension",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -223,19 +223,6 @@ public extension BinaryInteger {
} }
} }
// MARK: - File Handle API Compatibility for macOS 10.15.3 and Earlier.
@available(macOS, deprecated: 10.15.4)
extension FileHandle {
public func read(upToCount count: Int) throws -> Data? {
readData(ofLength: count)
}
public func readToEnd() throws -> Data? {
readDataToEndOfFile()
}
}
// MARK: - Index Revolver (only for Array) // MARK: - Index Revolver (only for Array)
// Further discussion: https://forums.swift.org/t/62847 // Further discussion: https://forums.swift.org/t/62847

View File

@ -32,7 +32,6 @@ public extension Binding {
// Ref: https://stackoverflow.com/a/63217861 // Ref: https://stackoverflow.com/a/63217861
@available(macOS 10.15, *) @available(macOS 10.15, *)
@available(macOS, obsoleted: 11)
struct Tooltip: NSViewRepresentable { struct Tooltip: NSViewRepresentable {
let tooltip: String let tooltip: String
@ -47,9 +46,8 @@ struct Tooltip: NSViewRepresentable {
} }
@available(macOS 10.15, *) @available(macOS 10.15, *)
@available(macOS, obsoleted: 11) public extension View {
extension View { func help(_ tooltip: String) -> some View {
public func help(_ tooltip: String) -> some View {
overlay(Tooltip(tooltip: tooltip)) overlay(Tooltip(tooltip: tooltip))
} }
} }

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "Tekkon", name: "Tekkon",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "TooltipUI", name: "TooltipUI",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "Uninstaller", name: "Uninstaller",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -4,7 +4,7 @@ import PackageDescription
let package = Package( let package = Package(
name: "UpdateSputnik", name: "UpdateSputnik",
platforms: [ platforms: [
.macOS(.v10_11), .macOS(.v11),
], ],
products: [ products: [
.library( .library(

View File

@ -233,9 +233,10 @@ public extension SessionCtl {
@objc func showCheatSheet(_: Any? = nil) { @objc func showCheatSheet(_: Any? = nil) {
guard let url = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return } guard let url = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return }
DispatchQueue.main.async { guard let safariURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.Safari") else { return }
NSWorkspace.shared.openFile(url.path, withApplication: "Safari") let configuration = NSWorkspace.OpenConfiguration()
} configuration.promptsUserIfNeeded = true
NSWorkspace.shared.open([url], withApplicationAt: safariURL, configuration: configuration)
} }
@objc func showClientListMgr(_: Any? = nil) { @objc func showClientListMgr(_: Any? = nil) {
@ -380,13 +381,18 @@ public extension SessionCtl {
if !LMMgr.userDataFolderExists { if !LMMgr.userDataFolderExists {
return return
} }
NSWorkspace.shared.openFile( let url = URL(fileURLWithPath: LMMgr.dataFolderPath(isDefaultFolder: false))
LMMgr.dataFolderPath(isDefaultFolder: false), withApplication: "Finder" guard let finderURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.finder") else { return }
) let configuration = NSWorkspace.OpenConfiguration()
configuration.promptsUserIfNeeded = true
NSWorkspace.shared.open([url], withApplicationAt: finderURL, configuration: configuration)
} }
@objc func openAppSupportFolderFromContainer(_: Any? = nil) { @objc func openAppSupportFolderFromContainer(_: Any? = nil) {
NSWorkspace.shared.openFile(LMMgr.appSupportURL.path, withApplication: "Finder") guard let finderURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.finder") else { return }
let configuration = NSWorkspace.OpenConfiguration()
configuration.promptsUserIfNeeded = true
NSWorkspace.shared.open([LMMgr.appSupportURL], withApplicationAt: finderURL, configuration: configuration)
} }
@objc func openUserPhrases(_: Any? = nil) { @objc func openUserPhrases(_: Any? = nil) {

View File

@ -8,6 +8,7 @@
import AppKit import AppKit
import MainAssembly import MainAssembly
import UniformTypeIdentifiers
class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewDataSource { class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewDataSource {
@IBOutlet var tblClients: NSTableView! @IBOutlet var tblClients: NSTableView!
@ -33,7 +34,7 @@ class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewData
window?.setPosition(vertical: .center, horizontal: .right, padding: 20) window?.setPosition(vertical: .center, horizontal: .right, padding: 20)
localize() localize()
tblClients.delegate = self tblClients.delegate = self
tblClients.registerForDraggedTypes([.init(rawValue: kUTTypeFileURL as String)]) tblClients.registerForDraggedTypes([.fileURL])
tblClients.allowsMultipleSelection = true tblClients.allowsMultipleSelection = true
tblClients.dataSource = self tblClients.dataSource = self
tblClients.action = #selector(onItemClicked(_:)) tblClients.action = #selector(onItemClicked(_:))
@ -125,7 +126,7 @@ extension CtlClientListMgr {
) )
dlgOpenPath.showsResizeIndicator = true dlgOpenPath.showsResizeIndicator = true
dlgOpenPath.allowsMultipleSelection = true dlgOpenPath.allowsMultipleSelection = true
dlgOpenPath.allowedFileTypes = ["app"] dlgOpenPath.allowedContentTypes = [UTType.applicationBundle]
dlgOpenPath.allowsOtherFileTypes = false dlgOpenPath.allowsOtherFileTypes = false
dlgOpenPath.showsHiddenFiles = true dlgOpenPath.showsHiddenFiles = true
dlgOpenPath.canChooseFiles = true dlgOpenPath.canChooseFiles = true
@ -240,7 +241,7 @@ extension CtlClientListMgr {
neta info: NSDraggingInfo, onError: @escaping () -> Void?, handler: (([URL]) -> Void)? = nil neta info: NSDraggingInfo, onError: @escaping () -> Void?, handler: (([URL]) -> Void)? = nil
) { ) {
let board = info.draggingPasteboard let board = info.draggingPasteboard
let type = NSPasteboard.PasteboardType(rawValue: kUTTypeApplicationBundle as String) let type = UTType.applicationBundle
let options: [NSPasteboard.ReadingOptionKey: Any] = [ let options: [NSPasteboard.ReadingOptionKey: Any] = [
.urlReadingFileURLsOnly: true, .urlReadingFileURLsOnly: true,
.urlReadingContentsConformToTypes: [type], .urlReadingContentsConformToTypes: [type],

View File

@ -431,7 +431,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
dlgOpenFile.canChooseFiles = true dlgOpenFile.canChooseFiles = true
dlgOpenFile.canChooseDirectories = false dlgOpenFile.canChooseDirectories = false
dlgOpenFile.allowsMultipleSelection = false dlgOpenFile.allowsMultipleSelection = false
dlgOpenFile.allowedFileTypes = ["cin2", "vcin", "cin"] dlgOpenFile.allowedContentTypes = ["cin2", "vcin", "cin"].compactMap { .init(filenameExtension: $0) }
dlgOpenFile.allowsOtherFileTypes = true dlgOpenFile.allowsOtherFileTypes = true
let bolPreviousPathValidity = LMMgr.checkCassettePathValidity( let bolPreviousPathValidity = LMMgr.checkCassettePathValidity(

View File

@ -198,7 +198,7 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
guard let self = self else { return } guard let self = self else { return }
let app: String = NSEvent.keyModifierFlags.contains(.option) ? "TextEdit" : "Finder" let app: String = NSEvent.keyModifierFlags.contains(.option) ? "TextEdit" : "Finder"
LMMgr.shared.openPhraseFile(mode: self.selInputMode, type: self.selUserDataType, app: app) LMMgr.shared.openPhraseFile(mode: self.selInputMode, type: self.selUserDataType, appIdentifier: app)
} }
} }