1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
silica-viewer/SilicaViewer/InfoViewController.swift
Joshua Goins baac84383b 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.
2022-02-28 12:03:08 -04:00

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)
}
}