NetNewsWire/Mac/CrashReporter/CrashReportWindowController...

63 lines
1.3 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CrashReportWindowController.swift
// NetNewsWire
//
// Created by Brent Simmons on 12/28/18.
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import AppKit
final class CrashReportWindowController: NSWindowController {
@IBOutlet var textView: NSTextView! {
didSet {
textView.font = NSFont.userFixedPitchFont(ofSize: 0.0)
textView.textContainerInset = NSSize(width: 5.0, height: 5.0)
textView.string = crashLogText
}
}
@IBOutlet var sendCrashLogButton: NSButton!
@IBOutlet var dontSendButton: NSButton!
var testing = false // If true, crashLog wont actually be sent.
private var crashLogText: String!
private var didSendCrashLog = false {
didSet {
sendCrashLogButton.isEnabled = !didSendCrashLog
dontSendButton.isEnabled = !didSendCrashLog
}
}
convenience init(crashLogText: String) {
self.init(windowNibName: "CrashReporterWindow")
self.crashLogText = crashLogText
}
override func windowDidLoad() {
super.windowDidLoad()
window!.center()
}
// MARK: - Actions
@IBAction func sendCrashReport(_ sender: Any?) {
guard !didSendCrashLog else {
return
}
didSendCrashLog = true
if !testing {
CrashReporter.sendCrashLogText(crashLogText)
}
close()
}
@IBAction func dontSendCrashReport(_ sender: Any?) {
close()
}
}