diff --git a/SilicaViewer/AppDelegate.swift b/SilicaViewer/AppDelegate.swift index a14717b..0fd0032 100644 --- a/SilicaViewer/AppDelegate.swift +++ b/SilicaViewer/AppDelegate.swift @@ -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 { diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index a7d3a60..0b1c89d 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -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. */ diff --git a/SilicaViewer/InfoViewController.swift b/SilicaViewer/InfoViewController.swift index c0349b0..afe8e31 100644 --- a/SilicaViewer/InfoViewController.swift +++ b/SilicaViewer/InfoViewController.swift @@ -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."