Handle document names better
Now it's possible for the document title to be null, just like an author name. Also, the document title is used for the default filename when exporting.
This commit is contained in:
parent
e3b94dee42
commit
baac84383b
3 changed files with 15 additions and 1 deletions
|
@ -71,6 +71,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
|||
let savePanel = NSSavePanel()
|
||||
savePanel.title = "Save Timelapse"
|
||||
savePanel.allowedFileTypes = ["public.mpeg-4"]
|
||||
savePanel.nameFieldStringValue = (document?.getIdealFilename())!
|
||||
|
||||
savePanel.begin { (result) in
|
||||
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
|
||||
guard let archive = Archive(data: (document?.data)!, accessMode: Archive.AccessMode.read) else {
|
||||
|
|
|
@ -113,6 +113,14 @@ class Document: NSDocument {
|
|||
return ofType == "com.procreate"
|
||||
}
|
||||
|
||||
func getIdealFilename() -> String {
|
||||
if (!(info.name.isEmpty)) {
|
||||
return info.name
|
||||
} else {
|
||||
return fileURL!.deletingPathExtension().lastPathComponent
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Pass in an object from the $object array, which always contains a $class key.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,11 @@ class InfoViewController: NSViewController {
|
|||
override func viewWillAppear() {
|
||||
super.viewDidAppear()
|
||||
|
||||
nameLabel.stringValue = "Name: " + document!.info.name
|
||||
if document!.info.authorName.isEmpty {
|
||||
nameLabel.stringValue = "Name is not set."
|
||||
} else {
|
||||
nameLabel.stringValue = "Name: " + document!.info.name
|
||||
}
|
||||
|
||||
if document!.info.authorName.isEmpty {
|
||||
authorNameField.stringValue = "Author name is not set."
|
||||
|
|
Reference in a new issue