Profile selection in the context menu

This commit is contained in:
Frank Skare
2021-07-19 15:22:36 +02:00
parent 35d9d29d40
commit a380f87b5f
5 changed files with 453 additions and 1 deletions

View File

@@ -302,6 +302,38 @@ namespace mpvnet
() => Core.SetBluRayTitle(item.Index));
}
}
MenuItem profiles = FindMenuItem("Profile");
if (profiles != null)
{
profiles.DropDownItems.Clear();
foreach (string profile in ProfileNames)
if (!profile.StartsWith("extension."))
MenuItem.Add(profiles.DropDownItems, profile,
() => {
Core.CommandV("show-text", profile);
Core.CommandV("apply-profile", profile);
});
}
}
private string[] _ProfileNames;
public string[] ProfileNames {
get {
if (_ProfileNames == null)
{
string[] ignore = { "builtin-pseudo-gui", "encoding", "libmpv", "pseudo-gui", "default" };
string profileList = Core.GetPropertyString("profile-list");
var json = profileList.FromJson<List<Dictionary<string, object>>>();
_ProfileNames = json.Select(i => i["name"].ToString())
.Where(i => !ignore.Contains(i)).ToArray();
}
return _ProfileNames;
}
}
MenuItem FindMenuItem(string text, ToolStripItemCollection items)