29 lines
862 B
Swift
29 lines
862 B
Swift
import Foundation
|
|
import AppKit
|
|
import UniformTypeIdentifiers
|
|
|
|
class ExportAccessoryView : NSView {
|
|
|
|
@IBOutlet weak var typeBox: NSPopUpButton!
|
|
|
|
var savePanel: NSSavePanel? = nil
|
|
|
|
func setSavePanel(_ savePanel: NSSavePanel?) {
|
|
self.savePanel = savePanel
|
|
}
|
|
|
|
func setPossibleOptions(_ options : Array<String>) {
|
|
for option in options {
|
|
typeBox.addItem(withTitle: option.uppercased())
|
|
}
|
|
}
|
|
|
|
@IBAction func changeFileFormat(_ sender: Any) {
|
|
if #available(macOS 11.0, *) {
|
|
savePanel?.allowedContentTypes = [UTType(filenameExtension: (typeBox.titleOfSelectedItem?.lowercased())!)!]
|
|
} else {
|
|
savePanel?.allowedFileTypes?.removeAll()
|
|
savePanel?.allowedFileTypes?.append((typeBox.titleOfSelectedItem?.lowercased())!)
|
|
};
|
|
}
|
|
}
|