mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
- rename Network widget to Speed
This commit is contained in:
@@ -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()
|
||||
@@ -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)
|
||||
|
||||
@@ -62,6 +62,11 @@
|
||||
<string>51383185408,198466408448</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>speed</key>
|
||||
<dict>
|
||||
<key>Default</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<true/>
|
||||
<key>Widgets</key>
|
||||
<dict>
|
||||
<key>network</key>
|
||||
<key>speed</key>
|
||||
<dict>
|
||||
<key>Default</key>
|
||||
<true/>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "<group>"; };
|
||||
9A3E17DA247A94BC00449CD1 /* readers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = readers.swift; sourceTree = "<group>"; };
|
||||
9A3E17DC247A94C300449CD1 /* config.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = config.plist; sourceTree = "<group>"; };
|
||||
9A3E17E7247AA8E100449CD1 /* Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = "<group>"; };
|
||||
9A3E17E7247AA8E100449CD1 /* Speed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Speed.swift; sourceTree = "<group>"; };
|
||||
9A3E17E9247B07BF00449CD1 /* popup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = popup.swift; sourceTree = "<group>"; };
|
||||
9A41530B24ABC3AF00A2BDA7 /* Disk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disk.swift; sourceTree = "<group>"; };
|
||||
9A5349CD23D8832E00C23824 /* Reachability.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Reachability.framework; path = Carthage/Build/Mac/Reachability.framework; sourceTree = "<group>"; };
|
||||
@@ -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 */,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user