mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-02-11 01:54:24 +01:00
PowerControl: Allow to set Autostart Profile Settings
This commit is contained in:
parent
74729ed391
commit
d423cf220a
|
|
@ -26,10 +26,10 @@ namespace PowerControl.Helper
|
|||
|
||||
public String ProfileName { get; }
|
||||
|
||||
public ProfileSettings(string profileName) : base("PersistentSettings")
|
||||
public ProfileSettings(string prefix, string profileName) : base("PersistentSettings")
|
||||
{
|
||||
this.ProfileName = profileName;
|
||||
this.ConfigFile = Path.Combine(UserProfilesPath, String.Format("PowerControl.Process.{0}.ini", profileName));
|
||||
this.ConfigFile = Path.Combine(UserProfilesPath, String.Format("{0}.{1}.ini", prefix, profileName));
|
||||
|
||||
this.SettingChanging += delegate { };
|
||||
this.SettingChanged += delegate { };
|
||||
|
|
|
|||
|
|
@ -155,10 +155,50 @@ namespace PowerControl.Menu
|
|||
toolStripItem.DropDownItems.Add(item);
|
||||
}
|
||||
|
||||
AddMenuItemsToModifyProfile(
|
||||
PowerControl.Options.Profiles.Controller?.AutostartProfileSettings,
|
||||
toolStripItem.DropDownItems
|
||||
);
|
||||
|
||||
toolStripItem.Visible = Visible && Options.Count > 0;
|
||||
};
|
||||
}
|
||||
|
||||
private void AddMenuItemsToModifyProfile(Helper.ProfileSettings? profileSettings, ToolStripItemCollection dropDownItems)
|
||||
{
|
||||
if (profileSettings is null || PersistentKey is null)
|
||||
return;
|
||||
|
||||
dropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
var headingItem = new ToolStripMenuItem(profileSettings.ProfileName + ": ");
|
||||
dropDownItems.Add(headingItem);
|
||||
|
||||
var persistedValue = profileSettings.GetValue(PersistentKey);
|
||||
|
||||
foreach (var option in Options)
|
||||
{
|
||||
var item = new ToolStripMenuItem("Set: " + option);
|
||||
item.Checked = option == persistedValue;
|
||||
item.Click += delegate { profileSettings.SetValue(PersistentKey, option); };
|
||||
headingItem.DropDownItems.Add(item);
|
||||
}
|
||||
|
||||
if (persistedValue is not null)
|
||||
{
|
||||
headingItem.Text += persistedValue;
|
||||
headingItem.Checked = true;
|
||||
|
||||
headingItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
var unsetItem = headingItem.DropDownItems.Add("Unset");
|
||||
unsetItem.Click += delegate { profileSettings.DeleteKey(PersistentKey); };
|
||||
}
|
||||
else
|
||||
{
|
||||
headingItem.Text += "Not set";
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectIndex(int index)
|
||||
{
|
||||
if (Options.Count == 0)
|
||||
|
|
|
|||
|
|
@ -31,14 +31,20 @@ namespace PowerControl
|
|||
public ProfileSettings? GameProfileSettings { get; private set; }
|
||||
|
||||
public ProfileSettings? SessionProfileSettings { get; private set; }
|
||||
public ProfileSettings AutostartProfileSettings { get; private set; }
|
||||
|
||||
public ProfilesController()
|
||||
{
|
||||
PowerControl.Options.Profiles.Controller = this;
|
||||
MenuStack.Root.ValueChanged += Root_OnOptionValueChange;
|
||||
|
||||
AutostartProfileSettings = new ProfileSettings("PowerControl", "Autostart");
|
||||
|
||||
timer.Start();
|
||||
timer.Tick += Timer_Tick;
|
||||
|
||||
ProfileChanged(null);
|
||||
ApplyProfile(AutostartProfileSettings);
|
||||
}
|
||||
|
||||
~ProfilesController()
|
||||
|
|
@ -106,13 +112,13 @@ namespace PowerControl
|
|||
{
|
||||
Log.TraceLine("ProfilesController: New Process: {0}/{1}", processId, processName);
|
||||
|
||||
var profileSettings = new ProfileSettings(processName);
|
||||
var profileSettings = new ProfileSettings("PowerControl.Process", processName);
|
||||
watchedProcesses.Add(processId, profileSettings);
|
||||
|
||||
// Create memory only SessionProfileSettings
|
||||
if (SessionProfileSettings is null)
|
||||
{
|
||||
SessionProfileSettings = new ProfileSettings("Session:" + processName) { UseConfigFile = false };
|
||||
SessionProfileSettings = new ProfileSettings("PowerControl.Session", "Session." + processName) { UseConfigFile = false };
|
||||
SaveProfile(SessionProfileSettings);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
## 0.6.16
|
||||
|
||||
- PowerControl: Allow to set Autostart Profile Settings
|
||||
- PowerControl: Show Game Profiles menu item
|
||||
- PowerControl: Improve handling of restoring DesktopProfile
|
||||
- All: Support [unofficial APU drivers](https://sourceforge.net/projects/amernimezone/files/Release%20Polaris-Vega-Navi/AMD%20SOC%20Driver%20Variant/) that present themselves as `AMD Radeon 670M`
|
||||
|
|
|
|||
Loading…
Reference in a new issue