diff --git a/ModuleKit/Widgets/Network.swift b/ModuleKit/Widgets/Speed.swift similarity index 95% rename from ModuleKit/Widgets/Network.swift rename to ModuleKit/Widgets/Speed.swift index c38c95a9..251a88a6 100644 --- a/ModuleKit/Widgets/Network.swift +++ b/ModuleKit/Widgets/Speed.swift @@ -1,5 +1,5 @@ // -// Network.swift +// Speed.swift // ModuleKit // // Created by Serhiy Mytrovtsiy on 24/05/2020. @@ -12,17 +12,17 @@ import Cocoa import StatsKit -public enum network_icon_t: String { +public enum speed_icon_t: String { case none = "None" case separator = "separator" case dot = "Dots" case arrow = "Arrows" case char = "Character" } -extension network_icon_t: CaseIterable {} +extension speed_icon_t: CaseIterable {} -public class NetworkWidget: Widget { - private var icon: network_icon_t = .dot +public class SpeedWidget: Widget { + private var icon: speed_icon_t = .dot private var state: Bool = false private var valueState: Bool = true @@ -40,13 +40,13 @@ public class NetworkWidget: Widget { self.store = store super.init(frame: CGRect(x: 0, y: Constants.Widget.margin, width: width, height: Constants.Widget.height - (2*Constants.Widget.margin))) self.title = widgetTitle - self.type = .network + self.type = .speed self.preview = preview self.canDrawConcurrently = true if self.store != nil { self.valueState = store!.pointee.bool(key: "\(self.title)_\(self.type.rawValue)_value", defaultValue: self.valueState) - self.icon = network_icon_t(rawValue: store!.pointee.string(key: "\(self.title)_\(self.type.rawValue)_icon", defaultValue: self.icon.rawValue)) ?? self.icon + self.icon = speed_icon_t(rawValue: store!.pointee.string(key: "\(self.title)_\(self.type.rawValue)_icon", defaultValue: self.icon.rawValue)) ?? self.icon } if self.valueState && self.icon != .none { @@ -202,7 +202,7 @@ public class NetworkWidget: Widget { frame: NSRect(x: 0, y: rowHeight + Constants.Settings.margin, width: view.frame.width, height: rowHeight), title: "Pictogram", action: #selector(toggleIcon), - items: network_icon_t.allCases.map{ return $0.rawValue }, + items: speed_icon_t.allCases.map{ return $0.rawValue }, selected: self.icon.rawValue )) @@ -237,7 +237,7 @@ public class NetworkWidget: Widget { } @objc private func toggleIcon(_ sender: NSMenuItem) { - let newIcon: network_icon_t = network_icon_t(rawValue: sender.title) ?? .none + let newIcon: speed_icon_t = speed_icon_t(rawValue: sender.title) ?? .none self.icon = newIcon self.store?.pointee.set(key: "\(self.title)_\(self.type.rawValue)_icon", value: self.icon.rawValue) self.display() diff --git a/ModuleKit/widget.swift b/ModuleKit/widget.swift index bc7e004c..06e25d35 100644 --- a/ModuleKit/widget.swift +++ b/ModuleKit/widget.swift @@ -57,7 +57,7 @@ public enum widget_t: String { case mini = "mini" case lineChart = "line_chart" case barChart = "bar_chart" - case network = "network" + case speed = "speed" case battery = "battery" case sensors = "sensors" case disk = "disk" @@ -83,7 +83,7 @@ open class Widget: NSView, Widget_p { case .mini: return "Mini" case .lineChart: return "Line chart" case .barChart: return "Bar chart" - case .network: return "Network" + case .speed: return "Speed" case .battery: return "Battery" case .sensors: return "Text" case .disk: return "Text" @@ -141,8 +141,8 @@ func LoadWidget(_ type: widget_t, preview: Bool, name: String, config: NSDiction case .barChart: widget = BarChart(preview: preview, title: name, config: widgetConfig, store: store) break - case .network: - widget = NetworkWidget(preview: preview, title: name, config: widgetConfig, store: store) + case .speed: + widget = SpeedWidget(preview: preview, title: name, config: widgetConfig, store: store) break case .battery: widget = BatterykWidget(preview: preview, title: name, config: widgetConfig, store: store) diff --git a/Modules/Disk/config.plist b/Modules/Disk/config.plist index 58eb9797..badf1211 100644 --- a/Modules/Disk/config.plist +++ b/Modules/Disk/config.plist @@ -62,6 +62,11 @@ 51383185408,198466408448 + speed + + Default + + diff --git a/Modules/Net/config.plist b/Modules/Net/config.plist index 53f09bd2..ad0879cf 100644 --- a/Modules/Net/config.plist +++ b/Modules/Net/config.plist @@ -8,7 +8,7 @@ Widgets - network + speed Default diff --git a/Modules/Net/main.swift b/Modules/Net/main.swift index 7d1345fe..582a07a5 100644 --- a/Modules/Net/main.swift +++ b/Modules/Net/main.swift @@ -129,7 +129,7 @@ public class Network: Module { } self.popupView.usageCallback(value!) - if let widget = self.widget as? NetworkWidget { + if let widget = self.widget as? SpeedWidget { widget.setValue(upload: value!.upload, download: value!.download) } } diff --git a/Stats.xcodeproj/project.pbxproj b/Stats.xcodeproj/project.pbxproj index fc6b8250..c2d9d08a 100644 --- a/Stats.xcodeproj/project.pbxproj +++ b/Stats.xcodeproj/project.pbxproj @@ -34,7 +34,7 @@ 9A3E17DF247A94DC00449CD1 /* ModuleKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9AABEADD243FB13500668CB0 /* ModuleKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9A3E17E2247A94DC00449CD1 /* StatsKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; }; 9A3E17E3247A94DC00449CD1 /* StatsKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C82DA24460F7200FAE3D4 /* StatsKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9A3E17E8247AA8E100449CD1 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3E17E7247AA8E100449CD1 /* Network.swift */; }; + 9A3E17E8247AA8E100449CD1 /* Speed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3E17E7247AA8E100449CD1 /* Speed.swift */; }; 9A3E17EA247B07BF00449CD1 /* popup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3E17E9247B07BF00449CD1 /* popup.swift */; }; 9A41530C24ABC3AF00A2BDA7 /* Disk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A41530B24ABC3AF00A2BDA7 /* Disk.swift */; }; 9A58DE9E24B363D800716A9F /* popup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A58DE9D24B363D800716A9F /* popup.swift */; }; @@ -414,7 +414,7 @@ 9A3E17D8247A94B500449CD1 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 9A3E17DA247A94BC00449CD1 /* readers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = readers.swift; sourceTree = ""; }; 9A3E17DC247A94C300449CD1 /* config.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = config.plist; sourceTree = ""; }; - 9A3E17E7247AA8E100449CD1 /* Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; + 9A3E17E7247AA8E100449CD1 /* Speed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Speed.swift; sourceTree = ""; }; 9A3E17E9247B07BF00449CD1 /* popup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = popup.swift; sourceTree = ""; }; 9A41530B24ABC3AF00A2BDA7 /* Disk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disk.swift; sourceTree = ""; }; 9A5349CD23D8832E00C23824 /* Reachability.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Reachability.framework; path = Carthage/Build/Mac/Reachability.framework; sourceTree = ""; }; @@ -680,7 +680,7 @@ 9A7C61B32440DF810032695D /* Mini.swift */, 9AA64263244B94F300416A33 /* LineChart.swift */, 9A1A7AB924561F0B00A84F7A /* BarChart.swift */, - 9A3E17E7247AA8E100449CD1 /* Network.swift */, + 9A3E17E7247AA8E100449CD1 /* Speed.swift */, 9ABFF911248BF39500C9041A /* Battery.swift */, 9AE29AFD249A82B70071B02D /* Sensors.swift */, 9A41530B24ABC3AF00A2BDA7 /* Disk.swift */, @@ -1316,7 +1316,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9A3E17E8247AA8E100449CD1 /* Network.swift in Sources */, + 9A3E17E8247AA8E100449CD1 /* Speed.swift in Sources */, 9AA64264244B94F300416A33 /* LineChart.swift in Sources */, 9A1A7ABA24561F0B00A84F7A /* BarChart.swift in Sources */, 9A944D55244920690058F32A /* reader.swift in Sources */, diff --git a/Stats/Views/Settings.swift b/Stats/Views/Settings.swift index ba0edff5..6161fdcf 100644 --- a/Stats/Views/Settings.swift +++ b/Stats/Views/Settings.swift @@ -34,8 +34,8 @@ class SettingsWindow: NSWindow, NSWindowDelegate { self.collectionBehavior = .moveToActiveSpace self.titlebarAppearsTransparent = true self.appearance = NSAppearance(named: .darkAqua) - self.center() - self.setIsVisible(false) +// self.center() + self.setIsVisible(true) let windowController = NSWindowController() windowController.window = self @@ -189,7 +189,7 @@ private class SettingsView: NSView { self.navigationView?.addSubview(menu) } self.modules = list -// self.openMenu("CPU") + self.openMenu("Disk") } @objc private func menuCallback(_ notification: Notification) {