mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
- update readers update interval (moved to one list of intervals)
This commit is contained in:
@@ -37,7 +37,7 @@ public protocol Reader_p {
|
||||
func unlock() -> Void
|
||||
|
||||
func initStoreValues(title: String, store: UnsafePointer<Store>) -> Void
|
||||
func setInterval(_ value: Double) -> Void
|
||||
func setInterval(_ value: Int) -> Void
|
||||
}
|
||||
|
||||
public protocol ReaderInternal_p {
|
||||
@@ -159,9 +159,9 @@ open class Reader<T>: ReaderInternal_p {
|
||||
self.active = false
|
||||
}
|
||||
|
||||
public func setInterval(_ value: Double) {
|
||||
os_log(.debug, log: self.log, "Set update interval: %.0f sec", value)
|
||||
self.repeatTask?.reset(.seconds(value), restart: true)
|
||||
public func setInterval(_ value: Int) {
|
||||
os_log(.debug, log: self.log, "Set update interval: %d sec", value)
|
||||
self.repeatTask?.reset(.seconds(Double(value)), restart: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,14 @@ import ModuleKit
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var usagePerCoreState: Bool = false
|
||||
private var hyperthreadState: Bool = false
|
||||
private var updateIntervalValue: String = "1"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 1
|
||||
|
||||
private let title: String
|
||||
private let store: UnsafePointer<Store>
|
||||
private var hasHyperthreadingCores = false
|
||||
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
private var hyperthreadView: NSView? = nil
|
||||
|
||||
@@ -33,7 +32,7 @@ internal class Settings: NSView, Settings_v {
|
||||
self.store = store
|
||||
self.hyperthreadState = store.pointee.bool(key: "\(self.title)_hyperhreading", defaultValue: self.hyperthreadState)
|
||||
self.usagePerCoreState = store.pointee.bool(key: "\(self.title)_usagePerCore", defaultValue: self.usagePerCoreState)
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
if !self.usagePerCoreState {
|
||||
self.hyperthreadState = false
|
||||
}
|
||||
@@ -64,7 +63,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: Constants.Settings.margin + (rowHeight + Constants.Settings.margin) * num, width: self.frame.width - (Constants.Settings.margin*2), height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -95,11 +94,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,11 @@ import ModuleKit
|
||||
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var removableState: Bool = false
|
||||
private var updateIntervalValue: String = "10"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 10
|
||||
|
||||
public var selectedDiskHandler: (String) -> Void = {_ in }
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
private let title: String
|
||||
private let store: UnsafePointer<Store>
|
||||
@@ -32,7 +31,7 @@ internal class Settings: NSView, Settings_v {
|
||||
self.store = store
|
||||
self.selectedDisk = store.pointee.string(key: "\(self.title)_disk", defaultValue: "")
|
||||
self.removableState = store.pointee.bool(key: "\(self.title)_removable", defaultValue: self.removableState)
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
|
||||
super.init(frame: CGRect(
|
||||
x: 0,
|
||||
@@ -60,7 +59,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: Constants.Settings.margin + (rowHeight + Constants.Settings.margin) * 2, width: self.frame.width - (Constants.Settings.margin*2), height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -136,11 +135,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ import StatsKit
|
||||
import ModuleKit
|
||||
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var updateIntervalValue: String = "1"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 1
|
||||
|
||||
private let title: String
|
||||
private let store: UnsafePointer<Store>
|
||||
@@ -24,7 +23,7 @@ internal class Settings: NSView, Settings_v {
|
||||
private var labelState: Bool = false
|
||||
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
public init(_ title: String, store: UnsafePointer<Store>, list: UnsafeMutablePointer<[Fan]>) {
|
||||
self.title = title
|
||||
@@ -41,7 +40,7 @@ internal class Settings: NSView, Settings_v {
|
||||
self.wantsLayer = true
|
||||
self.canDrawConcurrently = true
|
||||
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.labelState = store.pointee.bool(key: "\(self.title)_label", defaultValue: self.labelState)
|
||||
}
|
||||
|
||||
@@ -71,7 +70,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: height - rowHeight, width: view.frame.width, height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -124,11 +123,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ import StatsKit
|
||||
import ModuleKit
|
||||
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var updateIntervalValue: String = "1"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 1
|
||||
private var selectedGPU: String
|
||||
|
||||
private let title: String
|
||||
@@ -23,7 +22,7 @@ internal class Settings: NSView, Settings_v {
|
||||
|
||||
public var selectedGPUHandler: (String) -> Void = {_ in }
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
private var hyperthreadView: NSView? = nil
|
||||
|
||||
@@ -33,7 +32,7 @@ internal class Settings: NSView, Settings_v {
|
||||
self.title = title
|
||||
self.store = store
|
||||
self.selectedGPU = store.pointee.string(key: "\(self.title)_gpu", defaultValue: "")
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
|
||||
super.init(frame: CGRect(
|
||||
x: 0,
|
||||
@@ -60,7 +59,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: Constants.Settings.margin + (rowHeight + Constants.Settings.margin) * num, width: self.frame.width - (Constants.Settings.margin*2), height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -108,11 +107,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,18 @@ import StatsKit
|
||||
import ModuleKit
|
||||
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var updateIntervalValue: String = "1"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 1
|
||||
|
||||
private let title: String
|
||||
private let store: UnsafePointer<Store>
|
||||
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
public init(_ title: String, store: UnsafePointer<Store>) {
|
||||
self.title = title
|
||||
self.store = store
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
|
||||
super.init(frame: CGRect(
|
||||
x: 0,
|
||||
@@ -53,7 +52,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: Constants.Settings.margin + (rowHeight + Constants.Settings.margin) * num, width: self.frame.width - (Constants.Settings.margin*2), height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -61,11 +60,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,14 @@ import ModuleKit
|
||||
|
||||
internal class Settings: NSView, Settings_v {
|
||||
private var unitsValue: String = "system"
|
||||
private var updateIntervalValue: String = "3"
|
||||
private let listOfUpdateIntervals: [String] = ["1", "2", "3", "5", "10", "15", "30"]
|
||||
private var updateIntervalValue: Int = 3
|
||||
|
||||
private let title: String
|
||||
private let store: UnsafePointer<Store>
|
||||
private var button: NSPopUpButton?
|
||||
private let list: UnsafeMutablePointer<[Sensor_t]>
|
||||
public var callback: (() -> Void) = {}
|
||||
public var setInterval: ((_ value: Double) -> Void) = {_ in }
|
||||
public var setInterval: ((_ value: Int) -> Void) = {_ in }
|
||||
|
||||
public init(_ title: String, store: UnsafePointer<Store>, list: UnsafeMutablePointer<[Sensor_t]>) {
|
||||
self.title = title
|
||||
@@ -40,7 +39,7 @@ internal class Settings: NSView, Settings_v {
|
||||
self.wantsLayer = true
|
||||
self.canDrawConcurrently = true
|
||||
|
||||
self.updateIntervalValue = store.pointee.string(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.updateIntervalValue = store.pointee.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.unitsValue = store.pointee.string(key: "temperature_units", defaultValue: self.unitsValue)
|
||||
}
|
||||
|
||||
@@ -77,7 +76,7 @@ internal class Settings: NSView, Settings_v {
|
||||
frame: NSRect(x: Constants.Settings.margin, y: height - rowHeight, width: view.frame.width, height: rowHeight),
|
||||
title: LocalizedString("Update interval"),
|
||||
action: #selector(changeUpdateInterval),
|
||||
items: self.listOfUpdateIntervals.map{ "\($0) sec" },
|
||||
items: ReaderUpdateIntervals.map{ "\($0) sec" },
|
||||
selected: "\(self.updateIntervalValue) sec"
|
||||
))
|
||||
|
||||
@@ -145,11 +144,9 @@ internal class Settings: NSView, Settings_v {
|
||||
}
|
||||
|
||||
@objc private func changeUpdateInterval(_ sender: NSMenuItem) {
|
||||
let newUpdateInterval = sender.title.replacingOccurrences(of: " sec", with: "")
|
||||
self.updateIntervalValue = newUpdateInterval
|
||||
store.pointee.set(key: "\(self.title)_updateInterval", value: self.updateIntervalValue)
|
||||
|
||||
if let value = Double(self.updateIntervalValue) {
|
||||
if let value = Int(sender.title.replacingOccurrences(of: " sec", with: "")) {
|
||||
self.updateIntervalValue = value
|
||||
self.store.pointee.set(key: "\(self.title)_updateInterval", value: value)
|
||||
self.setInterval(value)
|
||||
}
|
||||
}
|
||||
|
||||
67
Stats.xcodeproj/xcshareddata/xcschemes/CPU.xcscheme
Normal file
67
Stats.xcodeproj/xcshareddata/xcschemes/CPU.xcscheme
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1210"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9A97CEC92537331B00742D8F"
|
||||
BuildableName = "CPU.framework"
|
||||
BlueprintName = "CPU"
|
||||
ReferencedContainer = "container:Stats.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9A97CEC92537331B00742D8F"
|
||||
BuildableName = "CPU.framework"
|
||||
BlueprintName = "CPU"
|
||||
ReferencedContainer = "container:Stats.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -91,7 +91,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
self.updateActivity.invalidate()
|
||||
self.updateActivity.repeats = true
|
||||
|
||||
guard let updateInterval = updateIntervals(rawValue: store.string(key: "update-interval", defaultValue: updateIntervals.atStart.rawValue)) else {
|
||||
guard let updateInterval = AppUpdateIntervals(rawValue: store.string(key: "update-interval", defaultValue: AppUpdateIntervals.atStart.rawValue)) else {
|
||||
return
|
||||
}
|
||||
os_log(.debug, log: log, "Application update interval is '%s'", "\(updateInterval.rawValue)")
|
||||
|
||||
@@ -18,9 +18,9 @@ class ApplicationSettings: NSView {
|
||||
private let height: CGFloat = 480
|
||||
private let deviceInfoHeight: CGFloat = 300
|
||||
|
||||
private var updateIntervalValue: updateInterval {
|
||||
private var updateIntervalValue: AppUpdateInterval {
|
||||
get {
|
||||
return store.string(key: "update-interval", defaultValue: updateIntervals.atStart.rawValue)
|
||||
return store.string(key: "update-interval", defaultValue: AppUpdateIntervals.atStart.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class ApplicationSettings: NSView {
|
||||
frame: NSRect(x: rowHorizontalPadding*0.5, y: rowHeight*2, width: rightPanel.frame.width - (rowHorizontalPadding*1.5), height: rowHeight),
|
||||
title: LocalizedString("Check for updates"),
|
||||
action: #selector(self.toggleUpdateInterval),
|
||||
items: updateIntervals.allCases.map{ $0.rawValue },
|
||||
items: AppUpdateIntervals.allCases.map{ $0.rawValue },
|
||||
selected: self.updateIntervalValue
|
||||
))
|
||||
|
||||
@@ -310,7 +310,7 @@ class ApplicationSettings: NSView {
|
||||
}
|
||||
|
||||
@objc private func toggleUpdateInterval(_ sender: NSMenuItem) {
|
||||
if let newUpdateInterval = updateIntervals(rawValue: sender.title) {
|
||||
if let newUpdateInterval = AppUpdateIntervals(rawValue: sender.title) {
|
||||
store.set(key: "update-interval", value: newUpdateInterval.rawValue)
|
||||
NotificationCenter.default.post(name: .changeCronInterval, object: nil, userInfo: nil)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ class SettingsWindow: NSWindow, NSWindowDelegate {
|
||||
self.collectionBehavior = .moveToActiveSpace
|
||||
self.titlebarAppearsTransparent = true
|
||||
self.appearance = NSAppearance(named: .darkAqua)
|
||||
// self.center()
|
||||
self.setIsVisible(true)
|
||||
self.center()
|
||||
self.setIsVisible(false)
|
||||
|
||||
let windowController = NSWindowController()
|
||||
windowController.window = self
|
||||
|
||||
@@ -91,7 +91,7 @@ extension AppDelegate {
|
||||
NSApp.setActivationPolicy(dockIconStatus)
|
||||
}
|
||||
|
||||
if updateIntervals(rawValue: store.string(key: "update-interval", defaultValue: updateIntervals.atStart.rawValue)) != .never {
|
||||
if AppUpdateIntervals(rawValue: store.string(key: "update-interval", defaultValue: AppUpdateIntervals.atStart.rawValue)) != .never {
|
||||
self.checkForNewVersion()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
public typealias updateInterval = String
|
||||
public enum updateIntervals: updateInterval {
|
||||
public typealias AppUpdateInterval = String
|
||||
public enum AppUpdateIntervals: AppUpdateInterval {
|
||||
case atStart = "At start"
|
||||
case separator_1 = "separator_1"
|
||||
case oncePerDay = "Once per day"
|
||||
@@ -21,7 +21,7 @@ public enum updateIntervals: updateInterval {
|
||||
case separator_2 = "separator_2"
|
||||
case never = "Never"
|
||||
}
|
||||
extension updateIntervals: CaseIterable {}
|
||||
extension AppUpdateIntervals: CaseIterable {}
|
||||
|
||||
public struct KeyValue_t {
|
||||
let key: String
|
||||
@@ -51,6 +51,8 @@ public let SpeedBase: [KeyValue_t] = [
|
||||
KeyValue_t(key: "byte", value: "Byte", additional: DataSizeBase.byte)
|
||||
]
|
||||
|
||||
public let ReaderUpdateIntervals: [Int] = [1, 2, 3, 5, 10, 15, 30]
|
||||
|
||||
public struct Units {
|
||||
public let bytes: Int64
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ public class Store {
|
||||
self.defaults.set(value, forKey: key)
|
||||
}
|
||||
|
||||
public func set(key: String, value: Int) {
|
||||
self.defaults.set(value, forKey: key)
|
||||
}
|
||||
|
||||
public func reset() {
|
||||
self.defaults.dictionaryRepresentation().keys.forEach { key in
|
||||
self.defaults.removeObject(forKey: key)
|
||||
|
||||
Reference in New Issue
Block a user