Add back the import sheet for unsupported brands.
This commit is contained in:
3 files changed
+15
-5
No files matched your search
@@ -11,16 +11,19 @@ import IOKit.pwr_mgt
|
|||||||
@objc(SBDocument) class Document: NSDocument {
|
@objc(SBDocument) class Document: NSDocument {
|
||||||
|
|
||||||
var mp4: MP42File
|
var mp4: MP42File
|
||||||
|
var unsupportedMp4Brand: Bool
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
self.options = [:]
|
self.options = [:]
|
||||||
self.optimize = false
|
self.optimize = false
|
||||||
|
self.unsupportedMp4Brand = false
|
||||||
self.mp4 = MP42File()
|
self.mp4 = MP42File()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc init(mp4: MP42File) throws {
|
@objc init(mp4: MP42File) throws {
|
||||||
self.options = [:]
|
self.options = [:]
|
||||||
self.optimize = false
|
self.optimize = false
|
||||||
|
self.unsupportedMp4Brand = false
|
||||||
self.mp4 = mp4
|
self.mp4 = mp4
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@@ -35,6 +38,12 @@ import IOKit.pwr_mgt
|
|||||||
let documentWindowController = DocumentWindowController()
|
let documentWindowController = DocumentWindowController()
|
||||||
addWindowController(documentWindowController)
|
addWindowController(documentWindowController)
|
||||||
documentWindowController.showWindow(self)
|
documentWindowController.showWindow(self)
|
||||||
|
|
||||||
|
if let url = fileURL, unsupportedMp4Brand {
|
||||||
|
// We can't edit this file, so ask the user if it wants to import it
|
||||||
|
documentWindowController.showImportSheet(fileURLs: [url])
|
||||||
|
fileURL = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Read
|
// MARK: Read
|
||||||
@@ -44,8 +53,13 @@ import IOKit.pwr_mgt
|
|||||||
override open var isEntireFileLoaded: Bool { get { return false } }
|
override open var isEntireFileLoaded: Bool { get { return false } }
|
||||||
|
|
||||||
override func read(from url: URL, ofType typeName: String) throws {
|
override func read(from url: URL, ofType typeName: String) throws {
|
||||||
|
do {
|
||||||
mp4 = try MP42File(url: url)
|
mp4 = try MP42File(url: url)
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
unsupportedMp4Brand = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func revert(toContentsOf url: URL, ofType typeName: String) throws {
|
override func revert(toContentsOf url: URL, ofType typeName: String) throws {
|
||||||
mp4 = try MP42File(url: url)
|
mp4 = try MP42File(url: url)
|
||||||
|
|||||||
@@ -537,7 +537,6 @@ class DocumentWindowController: NSWindowController, TracksViewControllerDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objc func showImportSheet(fileURLs: [URL]) {
|
@objc func showImportSheet(fileURLs: [URL]) {
|
||||||
do {
|
do {
|
||||||
let controller = try FileImportController(fileURLs: fileURLs, delegate: self)
|
let controller = try FileImportController(fileURLs: fileURLs, delegate: self)
|
||||||
|
|||||||
@@ -284,10 +284,7 @@
|
|||||||
|
|
||||||
- (nullable __kindof NSDocument *)documentForURL:(NSURL *)url
|
- (nullable __kindof NSDocument *)documentForURL:(NSURL *)url
|
||||||
{
|
{
|
||||||
NSArray<__kindof NSDocument *> *documents = nil;
|
NSArray<__kindof NSDocument *> *documents = [self.documents copy];
|
||||||
@synchronized(self) {
|
|
||||||
documents = [self.documents copy];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NSDocument *doc in documents) {
|
for (NSDocument *doc in documents) {
|
||||||
if ([doc.fileURL isEqualTo:url.filePathURL]) {
|
if ([doc.fileURL isEqualTo:url.filePathURL]) {
|
||||||
|
|||||||
Reference in new issue
Block a user