Make progress on CrashReportWindowController.
This commit is contained in:
parent
844a69446d
commit
1906dff715
|
@ -10,14 +10,6 @@ import Cocoa
|
|||
|
||||
final class CrashReportWindowController: NSWindowController {
|
||||
|
||||
private var crashLog: CrashLog!
|
||||
private static let windowName = "CrashReporterWindow"
|
||||
|
||||
convenience init(crashLog: CrashLog) {
|
||||
self.init(windowNibName: CrashReportWindowController.windowName)
|
||||
self.crashLog = crashLog
|
||||
}
|
||||
|
||||
@IBOutlet var textView: NSTextView! {
|
||||
didSet {
|
||||
textView.font = NSFont.userFixedPitchFont(ofSize: 0.0)
|
||||
|
@ -26,27 +18,60 @@ final class CrashReportWindowController: NSWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
windowFrameAutosaveName = CrashReportWindowController.windowName
|
||||
@IBOutlet var sendCrashLogButton: NSButton!
|
||||
@IBOutlet var dontSendButton: NSButton!
|
||||
|
||||
var testing = false // If true, crashLog won’t actually be sent.
|
||||
|
||||
private var crashLog: CrashLog!
|
||||
|
||||
private var didSendCrashLog = false {
|
||||
didSet {
|
||||
sendCrashLogButton.isEnabled = !didSendCrashLog
|
||||
dontSendButton.isEnabled = !didSendCrashLog
|
||||
}
|
||||
}
|
||||
|
||||
convenience init(crashLog: CrashLog) {
|
||||
self.init(windowNibName: "CrashReporterWindow")
|
||||
self.crashLog = crashLog
|
||||
}
|
||||
|
||||
override func showWindow(_ sender: Any?) {
|
||||
super.showWindow(sender)
|
||||
window!.center()
|
||||
window!.makeKeyAndOrderFront(sender)
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func sendCrashReport(_ sender: Any?) {
|
||||
guard !didSendCrashLog else {
|
||||
return
|
||||
}
|
||||
didSendCrashLog = true
|
||||
if !testing {
|
||||
CrashReporter.sendCrashLog(crashLog)
|
||||
// TODO: some kind of acknowledgement
|
||||
}
|
||||
showThanksSheet()
|
||||
}
|
||||
|
||||
@IBAction func cancel(_ sender: Any?) {
|
||||
@IBAction func dontSendCrashReport(_ sender: Any?) {
|
||||
close()
|
||||
}
|
||||
|
||||
@IBAction func showPrivacyPolicy(_ sender: Any?) {
|
||||
Browser.open(AppConstants.privacyPolicyURL, inBackground: false)
|
||||
}
|
||||
}
|
||||
|
||||
private extension CrashReportWindowController {
|
||||
|
||||
func showThanksSheet() {
|
||||
guard let window = window else {
|
||||
return
|
||||
}
|
||||
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .informational
|
||||
alert.messageText = NSLocalizedString("Crash Report Sent", comment: "Crash Report Window")
|
||||
alert.informativeText = NSLocalizedString("Thank you! This helps us to know about crashing bugs, so we can fix them.", comment: "Crash Report Window")
|
||||
alert.beginSheetModal(for: window)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,13 @@
|
|||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner"/>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="CrashReportWindowController" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="dontSendButton" destination="o4V-7L-v6D" id="Sxa-iT-OTj"/>
|
||||
<outlet property="sendCrashLogButton" destination="fcK-kG-dtY" id="T04-pD-qZq"/>
|
||||
<outlet property="textView" destination="hW5-cq-81L" id="RLj-Ti-pGC"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Crash Log Reporter" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
|
@ -84,7 +90,7 @@
|
|||
<rect key="frame" x="18" y="61" width="460" height="51"/>
|
||||
<textFieldCell key="cell" allowsUndo="NO" id="nou-5k-c1U">
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="title">You can skip this window in the future by telling NetNewsWire to automatically send crash reports. You can also turn this setting on and off in the Preferences window, in the Advanced section.</string>
|
||||
<string key="title">You can skip this window in the future by telling NetNewsWire to automatically send crash logs. You can also turn this setting on and off in the Preferences window, in the Advanced section.</string>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
|
@ -98,6 +104,9 @@
|
|||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="sendCrashReport:" target="-2" id="mob-bL-tRb"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="o4V-7L-v6D">
|
||||
<rect key="frame" x="208" y="13" width="137" height="32"/>
|
||||
|
@ -108,6 +117,9 @@ DQ
|
|||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="dontSendCrashReport:" target="-2" id="r3y-TC-h8U"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fEy-Fg-JhO">
|
||||
<rect key="frame" x="14" y="13" width="137" height="32"/>
|
||||
|
@ -115,6 +127,9 @@ Gw
|
|||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="showPrivacyPolicy:" target="-1" id="7TB-8O-Edu"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
|
|
Loading…
Reference in New Issue