diff --git a/docs/Changelog.md b/docs/Changelog.md index 5b4efe9..637948c 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,4 +1,5 @@ +- New feature to change profile using the command palette. - Progress command shows time and date. - New show-santa-logo (green and grumpy) option. - New quick bookmark feature, see manual. diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 520bfc0..6475c53 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -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) diff --git a/src/Misc/MainForm.cs b/src/Misc/MainForm.cs index 98ecce6..83dbeb8 100644 --- a/src/Misc/MainForm.cs +++ b/src/Misc/MainForm.cs @@ -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>>(); - _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) diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index a66ab64..045ded1 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -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>>(); + _ProfileNames = json.Select(i => i["name"].ToString()) + .Where(i => !ignore.Contains(i)).ToArray(); + } + + return _ProfileNames; + } + } } } diff --git a/src/Resources/input.conf.txt b/src/Resources/input.conf.txt index 5610df2..0cd612d 100644 --- a/src/Resources/input.conf.txt +++ b/src/Resources/input.conf.txt @@ -114,6 +114,8 @@ Alt+2 script-message mpv.net window-scale 2.0 #menu: View > Zoom > 200 % Alt+3 script-message mpv.net window-scale 3.0 #menu: View > Zoom > 300 % F8 script-message mpv.net show-playlist #menu: View > Show Playlist +Ctrl+p script-message mpv.net select-profile #menu: View > Show Profile Selection +Ctrl+P script-message mpv.net show-profiles #menu: View > Show Profiles Ctrl+7 script-message mpv.net show-audio-tracks #menu: View > Show Audio Tracks Ctrl+8 script-message mpv.net show-subtitle-tracks #menu: View > Show Subtitle Tracks b cycle border #menu: View > Toggle Border @@ -122,7 +124,6 @@ t script-binding stats/display-stats-toggle #menu: View > Toggle Statist Del script-binding osc/visibility #menu: View > Toggle OSC Visibility i script-message mpv.net show-info #menu: View > Show File/Stream Info p show-progress #menu: View > Show Progress -Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles F9 show-text ${track-list} 5000 #menu: View > Show Tracks Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info Alt+r script-message mpv.net show-recent #menu: View > Show Recent