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.
40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
import Foundation
|
|
import Cocoa
|
|
|
|
class InfoViewController: NSViewController {
|
|
var document: Document?
|
|
|
|
@IBOutlet weak var nameLabel: NSTextField!
|
|
@IBOutlet weak var authorNameField: NSTextField!
|
|
@IBOutlet weak var timeSpentLabel: NSTextField!
|
|
@IBOutlet weak var strokeCountField: NSTextField!
|
|
@IBOutlet weak var layerCountLabel: NSTextField!
|
|
|
|
override func viewWillAppear() {
|
|
super.viewDidAppear()
|
|
|
|
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."
|
|
} else {
|
|
authorNameField.stringValue = "Author name: " + document!.info.authorName
|
|
}
|
|
|
|
strokeCountField.stringValue = "Number of strokes: " + String(document!.info.strokeCount)
|
|
|
|
let formatter = DateComponentsFormatter()
|
|
formatter.allowedUnits = [.hour, .minute, .second]
|
|
formatter.unitsStyle = .full
|
|
|
|
let formattedString = formatter.string(from: TimeInterval(document!.info.trackedTime))!
|
|
|
|
timeSpentLabel.stringValue = "Time spent: " + formattedString
|
|
|
|
layerCountLabel.stringValue = "Number of layers: " + String(document!.info.layers.count)
|
|
}
|
|
}
|