Increase entitlement, add save functionality
This commit is contained in:
parent
eabcddb4b1
commit
4103cbacfb
3 changed files with 48 additions and 3 deletions
|
@ -18,5 +18,42 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
@IBAction func exportAction(_ sender: Any) {
|
||||
let document = NSApplication.shared.keyWindow?.windowController?.document as? Document;
|
||||
|
||||
let savePanel = NSSavePanel()
|
||||
savePanel.title = "Save"
|
||||
savePanel.allowedFileTypes = ["public.png"]
|
||||
savePanel.begin { (result) in
|
||||
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
|
||||
let canvas = document?.makeComposite()
|
||||
let canvasTiff = canvas?.tiffRepresentation
|
||||
let bitmapImage = NSBitmapImageRep(data: canvasTiff!)
|
||||
let canvasPng = bitmapImage!.representation(using: .png, properties: [:])
|
||||
|
||||
try? canvasPng?.write(to: savePanel.url!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func exportThumbnailAction(_ sender: Any) {
|
||||
let document = NSApplication.shared.keyWindow?.windowController?.document as? Document;
|
||||
|
||||
let savePanel = NSSavePanel()
|
||||
savePanel.title = "Save Thumbnail"
|
||||
savePanel.allowedFileTypes = ["public.png"]
|
||||
savePanel.begin { (result) in
|
||||
if result.rawValue == NSApplication.ModalResponse.OK.rawValue {
|
||||
let canvas = document?.makeThumbnail()
|
||||
let canvasTiff = canvas?.tiffRepresentation
|
||||
let bitmapImage = NSBitmapImageRep(data: canvasTiff!)
|
||||
let canvasPng = bitmapImage!.representation(using: .png, properties: [:])
|
||||
|
||||
try? canvasPng?.write(to: savePanel.url!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -79,8 +79,16 @@
|
|||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="MaD-eL-lbO"/>
|
||||
<menuItem title="Export..." keyEquivalent="s" id="ShN-CZ-HNV" userLabel="Export..."/>
|
||||
<menuItem title="Export Thumbnail..." keyEquivalent="S" id="JR5-se-hvt" userLabel="Export Thumbnail..."/>
|
||||
<menuItem title="Export..." keyEquivalent="s" id="ShN-CZ-HNV" userLabel="Export...">
|
||||
<connections>
|
||||
<action selector="exportAction:" target="Voe-Tx-rLC" id="2gQ-9c-0xy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Export Thumbnail..." keyEquivalent="S" id="JR5-se-hvt" userLabel="Export Thumbnail...">
|
||||
<connections>
|
||||
<action selector="exportThumbnailAction:" target="Voe-Tx-rLC" id="zki-Tz-dom"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="m54-Is-iLE">
|
||||
<connections>
|
||||
<action selector="saveDocument:" target="Ady-hI-5gd" id="fGt-aM-WYN"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Reference in a new issue