Skip to content

Commit

Permalink
feat: added option to kill the process in the Top Process (CPU/RAM/Ba…
Browse files Browse the repository at this point in the history
…ttery) (#569)
  • Loading branch information
exelban committed Aug 19, 2021
1 parent bf5b4c4 commit d6362c5
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Kit/helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
Expand All @@ -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 {
Expand Down

0 comments on commit d6362c5

Please sign in to comment.