Skip to content

Commit

Permalink
Pane: support DisableFan
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen-zen committed Nov 22, 2020
1 parent a9edc20 commit ca8ed08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion YogaSMCNC/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
conf.events = thinkEvents
isOpen = registerNotification()
thinkWakeup()
if !hide {
if !hide, !defaults.bool(forKey: "DisableFan") {
if ECCap == 3 {
if !getBoolean("Dual fan", conf.io_service),
defaults.bool(forKey: "SecondThinkFan") {
Expand Down
24 changes: 18 additions & 6 deletions YogaSMCPane/Base.lproj/YogaSMCPane.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17156" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17156"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -32,6 +32,7 @@
<outlet property="vCycleCount" destination="cFi-NC-K0C" id="axy-Rg-jnS"/>
<outlet property="vDYTCFuncMode" destination="fZZ-Y6-z0X" id="v6d-fS-QEH"/>
<outlet property="vDYTCRevision" destination="W8B-pr-Ckq" id="JAI-9h-llK"/>
<outlet property="vDisableFan" destination="5sT-I1-ipX" id="0X7-Qq-6Zs"/>
<outlet property="vECRead" destination="w0X-ID-3TJ" id="8MX-ad-Owg"/>
<outlet property="vFanSpeed" destination="uDk-6Z-gTN" id="2iO-3w-kaE"/>
<outlet property="vFanStop" destination="IDX-pC-nEt" id="Wby-GI-i2A"/>
Expand Down Expand Up @@ -636,7 +637,7 @@
<slider verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="waU-W1-TYS">
<rect key="frame" x="104" y="220" width="132" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="v4y-UK-MkJ"/>
<sliderCell key="cell" enabled="NO" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="v4y-UK-MkJ"/>
<connections>
<action selector="vPowerLEDSet:" target="-2" id="hHQ-6b-2fj"/>
</connections>
Expand Down Expand Up @@ -693,7 +694,7 @@
<slider verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="96M-Na-T3c">
<rect key="frame" x="104" y="160" width="132" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="t9r-7x-hVj"/>
<sliderCell key="cell" enabled="NO" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="t9r-7x-hVj"/>
<connections>
<action selector="vStandbyLEDSet:" target="-2" id="KKZ-b3-GMv"/>
</connections>
Expand Down Expand Up @@ -750,7 +751,7 @@
<slider verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ANf-1P-ZLt">
<rect key="frame" x="104" y="100" width="132" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="IMC-QI-01L"/>
<sliderCell key="cell" enabled="NO" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="IMC-QI-01L"/>
<connections>
<action selector="vThinkDotSet:" target="-2" id="zbs-Cj-HhV"/>
</connections>
Expand Down Expand Up @@ -807,7 +808,7 @@
<slider verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5gQ-az-9US">
<rect key="frame" x="104" y="50" width="132" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="M4M-Od-9Mh"/>
<sliderCell key="cell" enabled="NO" alignment="left" maxValue="3" tickMarkPosition="below" numberOfTickMarks="4" allowsTickMarkValuesOnly="YES" sliderType="linear" id="M4M-Od-9Mh"/>
<connections>
<action selector="vCustomLEDSet:" target="-2" id="NBM-l9-gYU"/>
</connections>
Expand Down Expand Up @@ -975,6 +976,17 @@
<action selector="vSecondFanSet:" target="-2" id="pIe-wt-kzK"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5sT-I1-ipX">
<rect key="frame" x="294" y="122" width="115" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="DisableFanCtrl" bezelStyle="regularSquare" imagePosition="left" inset="2" id="SAD-xa-6lF">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="vDisableFanSet:" target="-2" id="ruN-p3-7A8"/>
</connections>
</button>
</subviews>
</view>
</tabViewItem>
Expand Down
18 changes: 14 additions & 4 deletions YogaSMCPane/YogaSMCPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ class YogaSMCPane: NSPreferencePane {
defaults.setValue((vFanStop.state == .on), forKey: "AllowFanStop")
_ = scriptHelper(reloadAS, "Reload YogaSMCNC")
}

@IBOutlet weak var vDisableFan: NSButton!
@IBAction func vDisableFanSet(_ sender: NSButton) {
defaults.setValue((vDisableFan.state == .on), forKey: "DisableFan")
_ = scriptHelper(reloadAS, "Reload YogaSMCNC")
}

// Main

@IBOutlet weak var TabView: NSTabView!
Expand Down Expand Up @@ -380,12 +385,17 @@ class YogaSMCPane: NSPreferencePane {
#if DEBUG
if !getBoolean("Dual fan", io_service) {
vSecondFan.isEnabled = true
if defaults.object(forKey: "SecondThinkFan") != nil {
vSecondFan.state = defaults.bool(forKey: "SecondThinkFan") ? .on : .off
}
vSecondFan.state = defaults.bool(forKey: "SecondThinkFan") ? .on : .off
}
#endif
vFanStop.state = defaults.bool(forKey: "AllowFanStop") ? .on : .off
if getBoolean("LEDSupport", io_service) {
vPowerLEDSlider.isEnabled = true
vStandbyLEDSlider.isEnabled = true
vThinkDotSlider.isEnabled = true
vCustomLEDSlider.isEnabled = true
}
vDisableFan.state = defaults.bool(forKey: "DisableFan") ? .on : .off
}

override func awakeFromNib() {
Expand Down

0 comments on commit ca8ed08

Please sign in to comment.