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