change profile using command palette
This commit is contained in:
@@ -41,6 +41,7 @@ namespace mpvnet
|
||||
case "quick-bookmark": QuickBookmark(); break;
|
||||
case "reg-file-assoc": RegisterFileAssociations(args[0]); break;
|
||||
case "scale-window": ScaleWindow(float.Parse(args[0], CultureInfo.InvariantCulture)); break;
|
||||
case "select-profile": SelectProfile(); break;
|
||||
case "shell-execute": ProcessHelp.ShellExecute(args[0]); break;
|
||||
case "show-about": ShowDialog(typeof(AboutWindow)); break;
|
||||
case "show-audio-devices": Msg.ShowInfo(Core.GetPropertyOsdString("audio-device-list")); break;
|
||||
@@ -652,6 +653,19 @@ namespace mpvnet
|
||||
CommandPalette.Instance.SelectFirst();
|
||||
});
|
||||
|
||||
public static void SelectProfile() => App.InvokeOnMainThread(() =>
|
||||
{
|
||||
var items = Core.ProfileNames.Where(i => !i.StartsWith("extension."))
|
||||
.Select(i => new CommandPaletteItem(i, () => {
|
||||
Core.CommandV("show-text", i);
|
||||
Core.CommandV("apply-profile", i);
|
||||
}));
|
||||
|
||||
CommandPalette.Instance.SetItems(items);
|
||||
MainForm.Instance.ShowCommandPalette();
|
||||
CommandPalette.Instance.SelectFirst();
|
||||
});
|
||||
|
||||
public static void ShowMenu() => Core.RaiseShowMenu();
|
||||
|
||||
public static void PlaylistAdd(int value)
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace mpvnet
|
||||
{
|
||||
profilesMenuItem.Items.Clear();
|
||||
|
||||
foreach (string profile in ProfileNames)
|
||||
foreach (string profile in Core.ProfileNames)
|
||||
{
|
||||
if (!profile.StartsWith("extension."))
|
||||
{
|
||||
@@ -387,23 +387,6 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public WpfControls.MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||
|
||||
WpfControls.MenuItem FindMenuItem(string text, WpfControls.ItemCollection items)
|
||||
|
||||
@@ -1516,5 +1516,24 @@ namespace mpvnet
|
||||
track.Text += " " + value + ",";
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user