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 { @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,7 +53,12 @@ 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 {
mp4 = try MP42File(url: url) do {
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 {
-1
View File
@@ -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)
+1 -4
View File
@@ -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]) {