Allow configuring display of scheduler limit
This commit is contained in:
@@ -44,6 +44,7 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
deinit
|
||||
{
|
||||
UserDefaults.standard.removeObserver( self, forKeyPath: "displayCPUTemperature" )
|
||||
UserDefaults.standard.removeObserver( self, forKeyPath: "displaySchedulerLimit" )
|
||||
UserDefaults.standard.removeObserver( self, forKeyPath: "colorizeStatusItemText" )
|
||||
UserDefaults.standard.removeObserver( self, forKeyPath: "convertToFahrenheit" )
|
||||
UserDefaults.standard.removeObserver( self, forKeyPath: "hideStatusIcon" )
|
||||
@@ -55,6 +56,7 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
{
|
||||
UserDefaults.standard.setValue( true, forKey: "automaticallyCheckForUpdates" )
|
||||
UserDefaults.standard.setValue( true, forKey: "displayCPUTemperature" )
|
||||
UserDefaults.standard.setValue( true, forKey: "displaySchedulerLimit" )
|
||||
UserDefaults.standard.setValue( true, forKey: "colorizeStatusItemText" )
|
||||
UserDefaults.standard.setValue( NSDate(), forKey: "LastLaunch" )
|
||||
}
|
||||
@@ -101,6 +103,7 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
}
|
||||
|
||||
UserDefaults.standard.addObserver( self, forKeyPath: "displayCPUTemperature", options: [], context: nil )
|
||||
UserDefaults.standard.addObserver( self, forKeyPath: "displaySchedulerLimit", options: [], context: nil )
|
||||
UserDefaults.standard.addObserver( self, forKeyPath: "colorizeStatusItemText", options: [], context: nil )
|
||||
UserDefaults.standard.addObserver( self, forKeyPath: "convertToFahrenheit", options: [], context: nil )
|
||||
UserDefaults.standard.addObserver( self, forKeyPath: "hideStatusIcon", options: [], context: nil )
|
||||
@@ -156,6 +159,7 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
let keyPaths =
|
||||
[
|
||||
"displayCPUTemperature",
|
||||
"displaySchedulerLimit",
|
||||
"colorizeStatusItemText",
|
||||
"convertToFahrenheit",
|
||||
"hideStatusIcon",
|
||||
@@ -250,6 +254,7 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
|
||||
if let n1 = self.infoViewController?.speedLimit,
|
||||
let n2 = self.infoViewController?.temperature,
|
||||
UserDefaults.standard.bool( forKey: "displaySchedulerLimit" ),
|
||||
UserDefaults.standard.bool( forKey: "displayCPUTemperature" ),
|
||||
n1 > 0,
|
||||
n2 > 0
|
||||
@@ -257,7 +262,8 @@ class ApplicationDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate
|
||||
let temp = transformer.transformedValue( n2 ) as? String ?? "--"
|
||||
title = "\( n1 )% \( temp )"
|
||||
}
|
||||
else if let n = self.infoViewController?.speedLimit, n > 0
|
||||
else if let n = self.infoViewController?.speedLimit, n > 0,
|
||||
UserDefaults.standard.bool( forKey: "displaySchedulerLimit" )
|
||||
{
|
||||
title = "\( n )%"
|
||||
}
|
||||
|
||||
@@ -34,6 +34,14 @@ public class PreferencesWindowController: NSWindowController
|
||||
}
|
||||
}
|
||||
|
||||
@objc public dynamic var displaySchedulerLimit = UserDefaults.standard.bool( forKey: "displaySchedulerLimit" )
|
||||
{
|
||||
didSet
|
||||
{
|
||||
UserDefaults.standard.setValue( self.displaySchedulerLimit, forKey: "displaySchedulerLimit" )
|
||||
}
|
||||
}
|
||||
|
||||
@objc public dynamic var colorizeStatusItemText = UserDefaults.standard.bool( forKey: "colorizeStatusItemText" )
|
||||
{
|
||||
didSet
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="700" height="297"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1710" height="1069"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1536" height="935"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="734" height="367"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="765" height="398"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="15" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BG6-RK-yaR">
|
||||
<rect key="frame" x="20" y="20" width="339" height="327"/>
|
||||
<rect key="frame" x="20" y="20" width="339" height="358"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aiX-U8-MD5">
|
||||
<rect key="frame" x="-2" y="310" width="300" height="18"/>
|
||||
<rect key="frame" x="-2" y="341" width="300" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Display the CPU temperature in the menu bar" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="g0X-sq-6lh">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -35,6 +35,16 @@
|
||||
<binding destination="-2" name="value" keyPath="self.displayCPUTemperature" id="6xq-av-dp9"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="228-He-qR8">
|
||||
<rect key="frame" x="-2" y="310" width="261" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Display scheduler limit in the menu bar" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="r2t-uh-2lL">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="self.displaySchedulerLimit" id="kZ4-qm-Woa"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Rog-WF-H8d">
|
||||
<rect key="frame" x="-2" y="279" width="59" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Label" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="YMx-Az-Ken">
|
||||
@@ -263,6 +273,7 @@
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
@@ -276,10 +287,11 @@
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="mxk-B1-lA8">
|
||||
<rect key="frame" x="367" y="20" width="347" height="347"/>
|
||||
<rect key="frame" x="367" y="20" width="378" height="378"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="mxk-B1-lA8" secondAttribute="height" multiplier="1:1" id="1gH-bx-NiI"/>
|
||||
</constraints>
|
||||
|
||||
Reference in New Issue
Block a user