diff --git a/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/Contents.json b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/Contents.json new file mode 100644 index 00000000000..dda0d1d81f0 --- /dev/null +++ b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "baseline_cancel_white_12pt_1x.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "baseline_cancel_white_12pt_2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "baseline_cancel_white_12pt_3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_1x.png b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_1x.png new file mode 100644 index 00000000000..2e69e83f5bd Binary files /dev/null and b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_1x.png differ diff --git a/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_2x.png b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_2x.png new file mode 100644 index 00000000000..ea80f7dcebc Binary files /dev/null and b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_2x.png differ diff --git a/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_3x.png b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_3x.png new file mode 100644 index 00000000000..756d276ed0d Binary files /dev/null and b/Kit/Supporting Files/Assets.xcassets/close_12pt.imageset/baseline_cancel_white_12pt_3x.png differ diff --git a/Kit/helpers.swift b/Kit/helpers.swift index b6faf59f284..ad494c1ba79 100644 --- a/Kit/helpers.swift +++ b/Kit/helpers.swift @@ -654,15 +654,34 @@ public class ProcessView: NSStackView { let imageBox = NSView(frame: NSRect(x: 0, y: 0, width: 0, height: 0)) imageBox.addSubview(self.imageView) + let closeBox = NSView(frame: NSRect(x: 0, y: 0, width: 0, height: 0)) + let closeBtn = NSButton(frame: NSRect(x: 5, y: 5, width: 12, height: 12)) + closeBtn.bezelStyle = .regularSquare + closeBtn.translatesAutoresizingMaskIntoConstraints = false + closeBtn.imageScaling = .scaleNone + closeBtn.image = Bundle(for: type(of: self)).image(forResource: "close_12pt")! + if #available(OSX 10.14, *) { + closeBtn.contentTintColor = .lightGray + } + closeBtn.isBordered = false + closeBtn.action = #selector(closeApp) + closeBtn.target = self + closeBtn.toolTip = localizedString("Close application") + closeBtn.focusRingType = .none + closeBox.addSubview(closeBtn) + self.addArrangedSubview(imageBox) self.addArrangedSubview(self.labelView) self.addArrangedSubview(self.valueView) + self.addArrangedSubview(closeBox) NSLayoutConstraint.activate([ imageBox.widthAnchor.constraint(equalToConstant: self.bounds.height), imageBox.heightAnchor.constraint(equalToConstant: self.bounds.height), self.labelView.heightAnchor.constraint(equalToConstant: 16), self.valueView.widthAnchor.constraint(equalToConstant: self.valueView.bounds.width), + closeBox.widthAnchor.constraint(equalToConstant: self.bounds.height), + closeBox.heightAnchor.constraint(equalToConstant: self.bounds.height), self.widthAnchor.constraint(equalToConstant: self.bounds.width), self.heightAnchor.constraint(equalToConstant: self.bounds.height) ]) @@ -686,6 +705,12 @@ public class ProcessView: NSStackView { self.pid = nil self.toolTip = "" } + + @objc private func closeApp() { + if let pid = self.pid { + _ = syncShell("kill \(pid)") + } + } } public class CAText: CATextLayer {