From ba1672fa32a5a33f233c76a6c3b48e4371354120 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 1 May 2023 20:47:16 +0200 Subject: [PATCH] fix: hiding the `Top processes` separator when 0 processes is selected in the Disk settings --- Modules/Disk/popup.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Modules/Disk/popup.swift b/Modules/Disk/popup.swift index b91194b4..615ddbb2 100644 --- a/Modules/Disk/popup.swift +++ b/Modules/Disk/popup.swift @@ -53,7 +53,6 @@ internal class Popup: PopupWrapper { self.spacing = 0 self.addArrangedSubview(self.disks) - self.addArrangedSubview(separatorView(localizedString("Top processes"), width: self.frame.width)) self.addArrangedSubview(self.processes) self.recalculateHeight() @@ -694,7 +693,7 @@ public class IOProcessView: NSStackView { private var initialized: Bool = false - private var count: Int { + private var numberOfProcesses: Int { Store.shared.int(key: countKey, defaultValue: 5) } private var readColor: NSColor { @@ -708,7 +707,7 @@ public class IOProcessView: NSStackView { private var outputBoxView: NSView? public var height: CGFloat { - CGFloat((self.count+1) * 22) + CGFloat((self.numberOfProcesses+1) * 22) + Constants.Popup.separatorHeight } init(countKey: String, inputColorKey: String, outputColorKey: String) { @@ -731,8 +730,14 @@ public class IOProcessView: NSStackView { public func reinit() { self.subviews.forEach({ $0.removeFromSuperview() }) + if self.numberOfProcesses == 0 { + self.setFrameSize(NSSize(width: self.frame.width, height: 0)) + return + } + + self.addArrangedSubview(separatorView(localizedString("Top processes"), width: Constants.Popup.width)) self.addArrangedSubview(self.legendRow()) - for _ in 0..