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.
|
|
|
|
|
//
|
|
|
|
|
|
2019-02-12 07:35:42 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 07:56:43 +01:00
|
|
|
|
@IBOutlet var sendCrashLogButton: NSButton!
|
|
|
|
|
@IBOutlet var dontSendButton: NSButton!
|
|
|
|
|
|
|
|
|
|
var testing = false // If true, crashLog won’t actually be sent.
|
2018-12-29 21:31:27 +01:00
|
|
|
|
|
|
|
|
|
private var crashLogText: String!
|
2018-12-29 07:56:43 +01:00
|
|
|
|
|
|
|
|
|
private var didSendCrashLog = false {
|
|
|
|
|
didSet {
|
|
|
|
|
sendCrashLogButton.isEnabled = !didSendCrashLog
|
|
|
|
|
dontSendButton.isEnabled = !didSendCrashLog
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 21:31:27 +01:00
|
|
|
|
convenience init(crashLogText: String) {
|
2018-12-29 07:56:43 +01:00
|
|
|
|
self.init(windowNibName: "CrashReporterWindow")
|
2018-12-29 21:31:27 +01:00
|
|
|
|
self.crashLogText = crashLogText
|
2018-12-29 07:56:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 21:31:27 +01:00
|
|
|
|
override func windowDidLoad() {
|
|
|
|
|
super.windowDidLoad()
|
2018-12-29 07:56:43 +01:00
|
|
|
|
window!.center()
|
|
|
|
|
}
|
2018-12-29 06:49:32 +01:00
|
|
|
|
|
|
|
|
|
// MARK: - Actions
|
|
|
|
|
|
|
|
|
|
@IBAction func sendCrashReport(_ sender: Any?) {
|
2018-12-29 07:56:43 +01:00
|
|
|
|
guard !didSendCrashLog else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
didSendCrashLog = true
|
|
|
|
|
if !testing {
|
2018-12-29 21:31:27 +01:00
|
|
|
|
CrashReporter.sendCrashLogText(crashLogText)
|
2018-12-29 07:56:43 +01:00
|
|
|
|
}
|
2019-01-28 00:04:25 +01:00
|
|
|
|
close()
|
2018-12-29 06:49:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 07:56:43 +01:00
|
|
|
|
@IBAction func dontSendCrashReport(_ sender: Any?) {
|
2018-12-29 06:49:32 +01:00
|
|
|
|
close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|