Add back the import sheet for unsupported brands.

This commit is contained in:
Damiano Galassi committed 2018-02-14 09:10:50 +01:00
1 parent 181682c880
commit 22b1cbdd08
3 files changed
+16 -6

No files matched your search

+15 -1
View File
@@ -11,16 +11,19 @@ import IOKit.pwr_mgt
@objc(SBDocument) class Document: NSDocument {
var mp4: MP42File
var unsupportedMp4Brand: Bool
override init() {
self.options = [:]
self.optimize = false
self.unsupportedMp4Brand = false
self.mp4 = MP42File()
}
@objc init(mp4: MP42File) throws {
self.options = [:]
self.optimize = false
self.unsupportedMp4Brand = false
self.mp4 = mp4
super.init()
@@ -35,6 +38,12 @@ import IOKit.pwr_mgt
let documentWindowController = DocumentWindowController()
addWindowController(documentWindowController)
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
@@ -44,7 +53,12 @@ import IOKit.pwr_mgt
override open var isEntireFileLoaded: Bool { get { return false } }
override func read(from url: URL, ofType typeName: String) throws {
mp4 = try MP42File(url: url)
do {
mp4 = try MP42File(url: url)
}
catch {
unsupportedMp4Brand = true
}
}
override func revert(toContentsOf url: URL, ofType typeName: String) throws {
-1
View File
@@ -537,7 +537,6 @@ class DocumentWindowController: NSWindowController, TracksViewControllerDelegate
}
}
@objc func showImportSheet(fileURLs: [URL]) {
do {
let controller = try FileImportController(fileURLs: fileURLs, delegate: self)
+1 -4
View File
@@ -284,10 +284,7 @@
- (nullable __kindof NSDocument *)documentForURL:(NSURL *)url
{
NSArray<__kindof NSDocument *> *documents = nil;
@synchronized(self) {
documents = [self.documents copy];
}
NSArray<__kindof NSDocument *> *documents = [self.documents copy];
for (NSDocument *doc in documents) {
if ([doc.fileURL isEqualTo:url.filePathURL]) {