Skip to content

Commit d28b066

Browse files
committed
remove set tdp range min
fix load forceShowTDP
1 parent 0ce30f0 commit d28b066

File tree

6 files changed

+52
-39
lines changed

6 files changed

+52
-39
lines changed

src/components/cpu.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,35 @@ const CPUTDPComponent: VFC = () => {
121121
const [enableCustomTDPRange, setEnableCustomTDPRange] = useState<boolean>(Settings.appEnableCustomTDPRange());
122122
const [customTDPRangeMax, setCustomTDPRangeMax] = useState<number>(Settings.appCustomTDPRangeMax());
123123
const [customTDPRangeMin, setCustomTDPRangeMin] = useState<number>(Settings.appCustomTDPRangeMin());
124+
124125
const refresh = () => {
125126
setTDPEnable(Settings.appTDPEnable());
126-
setTDP(Settings.appTDP());
127127
setDisable(Settings.appGPUMode() == GPUMODE.AUTO);
128128
setEnableCustomTDPRange(Settings.appEnableCustomTDPRange());
129129
setCustomTDPRangeMax(Settings.appCustomTDPRangeMax());
130130
setCustomTDPRangeMin(Settings.appCustomTDPRangeMin());
131131
setForceShow(Settings.appForceShowTDP());
132+
133+
if (enableCustomTDPRange) {
134+
setTDP(Math.min(Settings.appTDP(), customTDPRangeMax));
135+
} else {
136+
setTDP(Settings.appTDP());
137+
}
132138
};
133139
useEffect(() => {
134-
PluginManager.listenUpdateComponent(ComponentName.CPU_TDP, [ComponentName.CPU_TDP, ComponentName.GPU_FREQMODE], (_ComponentName, updateType) => {
135-
switch (updateType) {
136-
case (UpdateType.UPDATE): {
137-
refresh();
138-
break;
140+
PluginManager.listenUpdateComponent(ComponentName.CPU_TDP,
141+
[
142+
ComponentName.CPU_TDP,
143+
ComponentName.GPU_FREQMODE,
144+
ComponentName.CUSTOM_TDP
145+
], (_ComponentName, updateType) => {
146+
switch (updateType) {
147+
case (UpdateType.UPDATE): {
148+
refresh();
149+
break;
150+
}
139151
}
140-
}
141-
})
152+
})
142153
}, []);
143154
return (
144155
<>
@@ -148,7 +159,6 @@ const CPUTDPComponent: VFC = () => {
148159
description={localizationManager.getString(localizeStrEnum.FORCE_SHOW_TDP_DESC)}
149160
checked={forceShow || !PluginManager.isPatchSuccess(Patch.TDPPatch)}
150161
onChange={(value) => {
151-
// setForceShow(value);
152162
Settings.setForceShowTDP(value);
153163
}}
154164
/>

src/components/customTDP.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export const CustomTDPComponent: VFC = () => {
77
const [show, setShow] = useState<boolean>(Settings.ensureEnable());
88
const [enableCustomTDPRange, setEnableCustomTDPRange] = useState<boolean>(Settings.appEnableCustomTDPRange());
99
const [customTDPRangeMax, setCustomTDPRangeMax] = useState<number>(Settings.appCustomTDPRangeMax());
10-
const [customTDPRangeMin, setCustomTDPRangeMin] = useState<number>(Settings.appCustomTDPRangeMin());
10+
// const [customTDPRangeMin, setCustomTDPRangeMin] = useState<number>(Settings.appCustomTDPRangeMin());
1111

1212
const hide = (ishide: boolean) => {
1313
setShow(!ishide);
1414
};
1515
const refresh = () => {
1616
setEnableCustomTDPRange(Settings.appEnableCustomTDPRange());
1717
setCustomTDPRangeMax(Settings.appCustomTDPRangeMax());
18-
setCustomTDPRangeMin(Settings.appCustomTDPRangeMin());
18+
// setCustomTDPRangeMin(Settings.appCustomTDPRangeMin());
1919
};
2020

2121
useEffect(() => {
@@ -65,7 +65,7 @@ export const CustomTDPComponent: VFC = () => {
6565
}}
6666
/>
6767
</PanelSectionRow>}
68-
{show && enableCustomTDPRange &&
68+
{/* {show && enableCustomTDPRange &&
6969
<PanelSectionRow>
7070
<SliderField
7171
label={"Min"}
@@ -81,7 +81,7 @@ export const CustomTDPComponent: VFC = () => {
8181
}
8282
}}
8383
/>
84-
</PanelSectionRow>}
84+
</PanelSectionRow>} */}
8585
</div>
8686
)
8787
}

src/i18n/english.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"USE_PERACMODE_PROFILE": "Use per-AC Mode Profile",
5454
"AC_MODE": "AC Mode",
5555
"BAT_MODE": "Battery Mode",
56-
"CUSTOM_TDP_RANGE": "Custom TDP Range",
56+
"CUSTOM_TDP_RANGE": "Custom TDP Slider Range",
5757
"RESET_ALL": "Reset All",
5858
"NATIVE_FREQ_DESC": "Set frequency using system shortcut menu",
5959
"UNLIMITED_DESC": "No limit on GPU frequency, system default scheduling",

src/i18n/schinese.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"USE_PERACMODE_PROFILE": "使用按充电状态设置的配置文件",
5454
"AC_MODE": "充电模式",
5555
"BAT_MODE": "电池模式",
56-
"CUSTOM_TDP_RANGE": "自定义 TDP 范围",
56+
"CUSTOM_TDP_RANGE": "自定义 TDP 滑块范围",
5757
"RESET_ALL": "重置所有设置",
5858
"NATIVE_FREQ_DESC": "使用系统快捷菜单频率设置",
5959
"UNLIMITED_DESC": "不限制 GPU 频率, 系统默认调度",

src/i18n/tchinese.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"USE_PERACMODE_PROFILE": "使用依充電狀態設定的設定檔",
5454
"AC_MODE": "充電模式",
5555
"BAT_MODE": "電池模式",
56-
"CUSTOM_TDP_RANGE": "自訂 TDP 範圍",
56+
"CUSTOM_TDP_RANGE": "自訂 TDP 滑塊範圍",
5757
"RESET_ALL": "重置所有設定",
5858
"NATIVE_FREQ_DESC": "使用系統快捷選單設定頻率",
5959
"UNLIMITED_DESC": "不限制 GPU 頻率,系統預設調度",

src/util/settings.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ export class SettingsData {
162162
@JsonProperty()
163163
public customTDPRangeMax: number;
164164

165-
@JsonProperty()
166-
public customTDPRangeMin: number;
165+
// @JsonProperty()
166+
// public customTDPRangeMin: number;
167167

168168
@JsonProperty()
169169
public forceShowTDP: boolean = false;
@@ -176,14 +176,15 @@ export class SettingsData {
176176

177177
constructor() {
178178
this.customTDPRangeMax = DEFAULT_TDP_MAX;
179-
this.customTDPRangeMin = DEFAULT_TDP_MIN;
179+
// this.customTDPRangeMin = DEFAULT_TDP_MIN;
180180
}
181181

182182
public deepCopy(copyTarget: SettingsData) {
183183
this.enabled = copyTarget.enabled;
184184
this.enableCustomTDPRange = copyTarget.enableCustomTDPRange;
185185
this.customTDPRangeMax = copyTarget.customTDPRangeMax;
186-
this.customTDPRangeMin = copyTarget.customTDPRangeMin;
186+
this.forceShowTDP = copyTarget.forceShowTDP;
187+
// this.customTDPRangeMin = copyTarget.customTDPRangeMin;
187188
this.perApp = {};
188189
Object.entries(copyTarget.perApp).forEach(([key, value]) => {
189190
this.perApp[key] = new AppSettingData();
@@ -438,20 +439,21 @@ export class Settings {
438439
}
439440

440441
static appCustomTDPRangeMin() {
441-
return this._instance.data.customTDPRangeMin;
442-
}
443-
444-
static setCustomTDPRangeMin(customTDPRangeMin: number) {
445-
if (this._instance.data.customTDPRangeMin != customTDPRangeMin) {
446-
this._instance.data.customTDPRangeMin = customTDPRangeMin;
447-
Settings.saveSettingsToLocalStorage();
448-
Backend.applySettings(APPLYTYPE.SET_TDP);
449-
PluginManager.updateComponent(
450-
ComponentName.CUSTOM_TDP,
451-
UpdateType.UPDATE
452-
);
453-
}
454-
}
442+
// return this._instance.data.customTDPRangeMin;
443+
return DEFAULT_TDP_MIN;
444+
}
445+
446+
// static setCustomTDPRangeMin(customTDPRangeMin: number) {
447+
// if (this._instance.data.customTDPRangeMin != customTDPRangeMin) {
448+
// this._instance.data.customTDPRangeMin = customTDPRangeMin;
449+
// Settings.saveSettingsToLocalStorage();
450+
// Backend.applySettings(APPLYTYPE.SET_TDP);
451+
// PluginManager.updateComponent(
452+
// ComponentName.CUSTOM_TDP,
453+
// UpdateType.UPDATE
454+
// );
455+
// }
456+
// }
455457

456458
static appTDPEnable() {
457459
return Settings.ensureApp().tdpEnable ?? true;
@@ -475,11 +477,12 @@ export class Settings {
475477
}
476478

477479
static getTDPMin() {
478-
if (this._instance.data.enableCustomTDPRange) {
479-
return this._instance.data.customTDPRangeMin;
480-
} else {
481-
return 3;
482-
}
480+
// if (this._instance.data.enableCustomTDPRange) {
481+
// return this._instance.data.customTDPRangeMin;
482+
// } else {
483+
// return 3;
484+
// }
485+
return DEFAULT_TDP_MIN;
483486
}
484487

485488
static saveTDPFromQAM(tdp: number, tdpEnable: boolean) {

0 commit comments

Comments
 (0)