NetNewsWire/Mac/CrashReporter/CrashReportWindowController.swift

63 lines
1.3 KiB
Swift
Raw Normal View History

2018-12-29 06:49:32 +01:00
//
// CrashReportWindowController.swift
// NetNewsWire
//
// Created by Brent Simmons on 12/28/18.
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import AppKit
2018-12-29 06:49:32 +01:00
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)
2018-12-29 21:31:27 +01:00
textView.string = crashLogText
2018-12-29 06:49:32 +01:00
}
}
@IBOutlet var sendCrashLogButton: NSButton!
@IBOutlet var dontSendButton: NSButton!
var testing = false // If true, crashLog wont actually be sent.
2018-12-29 21:31:27 +01:00
private var crashLogText: String!
private var didSendCrashLog = false {
didSet {
sendCrashLogButton.isEnabled = !didSendCrashLog
dontSendButton.isEnabled = !didSendCrashLog
}
}
2018-12-29 21:31:27 +01:00
convenience init(crashLogText: String) {
self.init(windowNibName: "CrashReporterWindow")
2018-12-29 21:31:27 +01:00
self.crashLogText = crashLogText
}
2018-12-29 21:31:27 +01:00
override func windowDidLoad() {
super.windowDidLoad()
window!.center()
}
2018-12-29 06:49:32 +01:00
// MARK: - Actions
@IBAction func sendCrashReport(_ sender: Any?) {
guard !didSendCrashLog else {
return
}
didSendCrashLog = true
if !testing {
2018-12-29 21:31:27 +01:00
CrashReporter.sendCrashLogText(crashLogText)
}
close()
2018-12-29 06:49:32 +01:00
}
@IBAction func dontSendCrashReport(_ sender: Any?) {
2018-12-29 06:49:32 +01:00
close()
}
}