Fix even more deprecation warnings
This commit is contained in:
3 files changed
+32
-5
No files matched your search
@@ -482,13 +482,17 @@ final class DocumentWindowController: NSWindowController, TracksViewControllerDe
|
|||||||
|
|
||||||
@IBAction func selectFile(_ sender: Any) {
|
@IBAction func selectFile(_ sender: Any) {
|
||||||
guard let windowForSheet = doc.windowForSheet else { return }
|
guard let windowForSheet = doc.windowForSheet else { return }
|
||||||
let supportedFileFormats = MP42FileImporter.supportedFileFormats() + ["txt", "csv"]
|
|
||||||
|
|
||||||
let panel = NSOpenPanel()
|
let panel = NSOpenPanel()
|
||||||
panel.allowsMultipleSelection = true
|
panel.allowsMultipleSelection = true
|
||||||
panel.canChooseFiles = true
|
panel.canChooseFiles = true
|
||||||
panel.canChooseDirectories = false
|
panel.canChooseDirectories = false
|
||||||
panel.allowedFileTypes = supportedFileFormats
|
|
||||||
|
if #available(macOS 11, *) {
|
||||||
|
panel.allowedContentTypes = MP42FileImporter.supportedContentTypes() + [.text, .commaSeparatedText]
|
||||||
|
} else {
|
||||||
|
panel.allowedFileTypes = MP42FileImporter.supportedFileFormats() + ["txt", "csv"]
|
||||||
|
}
|
||||||
|
|
||||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||||
if response == NSApplication.ModalResponse.OK {
|
if response == NSApplication.ModalResponse.OK {
|
||||||
|
|||||||
@@ -907,7 +907,16 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
if let url = artwork as? URL {
|
if let url = artwork as? URL {
|
||||||
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
|
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
|
||||||
|
|
||||||
if let type = value?.typeIdentifier, UTTypeConformsTo(type as CFString, "public.jpeg" as CFString), let data = try? Data(contentsOf: url) {
|
var isJpeg = false
|
||||||
|
if #available(macOS 11, *) {
|
||||||
|
isJpeg = value?.contentType?.conforms(to: .jpeg) ?? false
|
||||||
|
} else {
|
||||||
|
if let type = value?.typeIdentifier, UTTypeConformsTo(type as CFString, "public.jpeg" as CFString) {
|
||||||
|
isJpeg = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if isJpeg, let data = try? Data(contentsOf: url) {
|
||||||
return MP42Image(data: data, type: MP42_ART_JPEG)
|
return MP42Image(data: data, type: MP42_ART_JPEG)
|
||||||
} else if let image = NSImage(contentsOf: url) {
|
} else if let image = NSImage(contentsOf: url) {
|
||||||
return MP42Image(image: image)
|
return MP42Image(image: image)
|
||||||
|
|||||||
@@ -280,9 +280,18 @@ final class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDel
|
|||||||
private func destination(for url: URL) -> URL {
|
private func destination(for url: URL) -> URL {
|
||||||
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
|
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
|
||||||
|
|
||||||
|
var isMpeg4 = false
|
||||||
|
if #available(macOS 11, *) {
|
||||||
|
isMpeg4 = value?.contentType?.conforms(to: .mpeg4Movie) ?? false
|
||||||
|
} else {
|
||||||
|
if let type = value?.typeIdentifier, UTTypeConformsTo(type as CFString, "public.mpeg-4" as CFString) {
|
||||||
|
isMpeg4 = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let destination = prefs.destination {
|
if let destination = prefs.destination {
|
||||||
return destination.appendingPathComponent(url.lastPathComponent).deletingPathExtension().appendingPathExtension(prefs.fileType)
|
return destination.appendingPathComponent(url.lastPathComponent).deletingPathExtension().appendingPathExtension(prefs.fileType)
|
||||||
} else if let type = value?.typeIdentifier, UTTypeConformsTo(type as CFString, "public.mpeg-4" as CFString) {
|
} else if isMpeg4 {
|
||||||
return url
|
return url
|
||||||
} else {
|
} else {
|
||||||
return url.deletingPathExtension().appendingPathExtension(prefs.fileType)
|
return url.deletingPathExtension().appendingPathExtension(prefs.fileType)
|
||||||
@@ -719,7 +728,12 @@ final class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDel
|
|||||||
panel.allowsMultipleSelection = true
|
panel.allowsMultipleSelection = true
|
||||||
panel.canChooseFiles = true
|
panel.canChooseFiles = true
|
||||||
panel.canChooseDirectories = true
|
panel.canChooseDirectories = true
|
||||||
panel.allowedFileTypes = MP42FileImporter.supportedFileFormats()
|
|
||||||
|
if #available(macOS 11, *) {
|
||||||
|
panel.allowedContentTypes = MP42FileImporter.supportedContentTypes()
|
||||||
|
} else {
|
||||||
|
panel.allowedFileTypes = MP42FileImporter.supportedFileFormats()
|
||||||
|
}
|
||||||
|
|
||||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||||
if response == NSApplication.ModalResponse.OK {
|
if response == NSApplication.ModalResponse.OK {
|
||||||
|
|||||||
Reference in new issue
Block a user