From ac5fc3f96e45e7f24a4c3fe2b83b76c3f4403ddc Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:21:28 +0200 Subject: [PATCH] Revert "Revert "Adjustment of Windows Power Overlay is now optional"" This reverts commit 8804d195670fd7a367b152d3ae78230ba7f34de6. --- app/AppConfig.cs | 1 + app/Extra.Designer.cs | 1 + app/Extra.cs | 9 +++++++++ app/Properties/Strings.Designer.cs | 11 ++++++++++- app/Properties/Strings.de.resx | 3 +++ app/Properties/Strings.es.resx | 3 +++ app/Properties/Strings.fr.resx | 3 +++ app/Properties/Strings.it.resx | 3 +++ app/Properties/Strings.resx | 3 +++ app/Properties/Strings.tr.resx | 3 +++ app/Properties/Strings.uk.resx | 3 +++ app/Properties/Strings.zh-CN.resx | 3 +++ app/Properties/Strings.zh-TW.resx | 3 +++ app/Settings.cs | 12 +++++++----- 14 files changed, 55 insertions(+), 6 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 76780195..cfb6fa26 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -69,6 +69,7 @@ public class AppConfig { config = new Dictionary(); config["performance_mode"] = 0; + config["auto_apply_power_plan"] = 1; string jsonString = JsonSerializer.Serialize(config); File.WriteAllText(configFile, jsonString); } diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index 76a6cdcb..cbf1945d 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -74,6 +74,7 @@ namespace GHelper checkSleepLid = new CheckBox(); checkShutdownLid = new CheckBox(); groupOther = new GroupBox(); + checkApplyWindowsPowerMode = new CheckBox(); checkKeyboardAuto = new CheckBox(); checkUSBC = new CheckBox(); checkNoOverdrive = new CheckBox(); diff --git a/app/Extra.cs b/app/Extra.cs index 9209c3a2..eae36690 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -73,6 +73,7 @@ namespace GHelper checkNoOverdrive.Text = Properties.Strings.DisableOverdrive; checkTopmost.Text = Properties.Strings.WindowTop; checkUSBC.Text = Properties.Strings.OptimizedUSBC; + checkApplyWindowsPowerMode.Text = Properties.Strings.ApplyWindowsPowerPlan; labelBacklight.Text = Properties.Strings.Keyboard; labelBacklightBar.Text = Properties.Strings.Lightbar; @@ -176,6 +177,8 @@ namespace GHelper checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1); checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged; + checkApplyWindowsPowerMode.Checked = Program.config.getConfig("auto_apply_power_plan") == 1; + int kb_brightness = Program.config.getConfig("keyboard_brightness"); trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3; @@ -299,5 +302,11 @@ namespace GHelper Top = Program.settingsForm.Top; Left = Program.settingsForm.Left - Width - 5; } + + private void checkApplyWindowsPowerMode_CheckedChanged(object sender, EventArgs e) + { + CheckBox chk = (CheckBox)sender; + Program.config.setConfig("auto_apply_power_plan", chk.Checked ? 1 : 0); + } } } diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 1d7a5479..bd136139 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -169,7 +169,16 @@ namespace GHelper.Properties { } /// - /// Looks up a localized string similar to Breathe. + /// Looks up a localized string similar to Auto Adjust Windows Power Plan. + /// + internal static string ApplyWindowsPowerPlan { + get { + return ResourceManager.GetString("ApplyWindowsPowerPlan", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Breathe. /// internal static string AuraBreathe { get { diff --git a/app/Properties/Strings.de.resx b/app/Properties/Strings.de.resx index 32da890a..a4ea4fb9 100644 --- a/app/Properties/Strings.de.resx +++ b/app/Properties/Strings.de.resx @@ -94,6 +94,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.es.resx b/app/Properties/Strings.es.resx index 791c96dd..37c76352 100644 --- a/app/Properties/Strings.es.resx +++ b/app/Properties/Strings.es.resx @@ -153,6 +153,9 @@ Aplicar límites de energía + + Auto Adjust Windows Power Plan + Respiración diff --git a/app/Properties/Strings.fr.resx b/app/Properties/Strings.fr.resx index 32da890a..40e9f2b4 100644 --- a/app/Properties/Strings.fr.resx +++ b/app/Properties/Strings.fr.resx @@ -301,6 +301,9 @@ Run on Startup + + Auto Adjust Windows Power Plan + Shutdown diff --git a/app/Properties/Strings.it.resx b/app/Properties/Strings.it.resx index 32da890a..a4ea4fb9 100644 --- a/app/Properties/Strings.it.resx +++ b/app/Properties/Strings.it.resx @@ -94,6 +94,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index d255a48f..6d47593a 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -153,6 +153,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.tr.resx b/app/Properties/Strings.tr.resx index 37b7146e..1e9811f7 100644 --- a/app/Properties/Strings.tr.resx +++ b/app/Properties/Strings.tr.resx @@ -153,6 +153,9 @@ Güç Sınırlarını Uygula + + Auto Adjust Windows Power Plan + Nefes diff --git a/app/Properties/Strings.uk.resx b/app/Properties/Strings.uk.resx index f2df1532..f2c89463 100644 --- a/app/Properties/Strings.uk.resx +++ b/app/Properties/Strings.uk.resx @@ -153,6 +153,9 @@ Застосувати потужність + + Auto Adjust Windows Power Plan + Дихання diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index 65426d2d..98fbf9f2 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -153,6 +153,9 @@ 应用功率限制 + + Auto Adjust Windows Power Plan + 呼吸 diff --git a/app/Properties/Strings.zh-TW.resx b/app/Properties/Strings.zh-TW.resx index 9b9b6bff..ac4c8472 100644 --- a/app/Properties/Strings.zh-TW.resx +++ b/app/Properties/Strings.zh-TW.resx @@ -153,6 +153,9 @@ 套用功率限制 + + Auto Adjust Windows Power Plan + 呼吸 diff --git a/app/Settings.cs b/app/Settings.cs index 5552f6ea..3a796f8e 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1286,11 +1286,13 @@ namespace GHelper AutoFans(); AutoPower(1000); - - if (Program.config.getConfigPerfString("scheme") is not null) - NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); - else - NativeMethods.SetPowerScheme(PerformanceMode); + if (Program.config.getConfigPerf("auto_apply_power_plan") == 1) + { + if (Program.config.getConfigPerfString("scheme") is not null) + NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); + else + NativeMethods.SetPowerScheme(PerformanceMode); + } if (Program.config.getConfigPerf("auto_boost") != -1) {