From 1048dbed40afed0ce6d695b0a2540a6baf5556dd Mon Sep 17 00:00:00 2001 From: stax76 Date: Tue, 26 Dec 2023 09:22:27 +0100 Subject: [PATCH] New menu item and binding: File > Add files to playlist from clipboard (Ctrl+Shift+v) --- docs/changelog.md | 5 +++-- docs/manual.md | 5 ++++- src/MpvNet.Windows/GuiCommand.cs | 10 ++++++++-- src/MpvNet/InputHelp.cs | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index dfe4dd2..c2bd665 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,8 +7,9 @@ - The conf file reader/writer detects if the user prefers space before and after the equal sign. - The portable download includes like the installer debug symbols. - Setup questions on startup removed. -- Pressing shift while drag and drop (and clipboard import) appends - instead of replaces files in the playlist. mpv supports this as well. +- Pressing shift while drag and drop appends instead of replaces + files in the playlist. mpv supports this as well. +- New menu item and binding: `File > Add files to playlist from clipboard` `Ctrl+Shift+v`. - All list operation suffixes are available on the command line. - Improved layout in conf editor. diff --git a/docs/manual.md b/docs/manual.md index 95ded77..f5f7a28 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -241,10 +241,13 @@ Shows a folder browser dialog to open a DVD or BD folder. ISO images don't have to be mounted, but instead can be opened directly with the open-files command. -### open-clipboard +### open-clipboard [\] Opens a single URL or filepath from the clipboard, or multiple files in the file clipboard format. +**append** +Appends files/URLs to the playlist. + ### play-pause Cycles the pause property. In case the playlist is empty, the most recent file from the recent files list is loaded. diff --git a/src/MpvNet.Windows/GuiCommand.cs b/src/MpvNet.Windows/GuiCommand.cs index 424614c..9a7864d 100644 --- a/src/MpvNet.Windows/GuiCommand.cs +++ b/src/MpvNet.Windows/GuiCommand.cs @@ -153,12 +153,15 @@ public class GuiCommand public void OpenFromClipboard(IList args) { - bool append = Control.ModifierKeys == Keys.Shift; + bool append = args.Count == 1 && args[0] == "append"; if (System.Windows.Forms.Clipboard.ContainsFileDropList()) { string[] files = System.Windows.Forms.Clipboard.GetFileDropList().Cast().ToArray(); Player.LoadFiles(files, false, append); + + if (append) + Player.CommandV("show-text", _("Files/URLs were added to the playlist")); } else { @@ -171,11 +174,14 @@ public class GuiCommand if (files.Count == 0) { - Terminal.WriteError("The clipboard does not contain a valid URL or file."); + Terminal.WriteError(_("The clipboard does not contain a valid URL or file.")); return; } Player.LoadFiles(files.ToArray(), false, append); + + if (append) + Player.CommandV("show-text", _("Files/URLs were added to the playlist")); } } diff --git a/src/MpvNet/InputHelp.cs b/src/MpvNet/InputHelp.cs index eeb4bb4..2b0d543 100644 --- a/src/MpvNet/InputHelp.cs +++ b/src/MpvNet/InputHelp.cs @@ -17,8 +17,9 @@ public static class InputHelp new (_("File"), _("Add external subtitle files..."), "script-message-to mpvnet load-sub", "Alt+s"), new (_("File"), "-"), new (_("File"), _("Add files to playlist..."), "script-message-to mpvnet open-files append"), - new (_("File"), _("Recent Files")), + new (_("File"), _("Add files to playlist from clipboard"), "script-message-to mpvnet open-clipboard append", "Ctrl+Shift+v"), new (_("File"), "-"), + new (_("File"), _("Recent Files")), new (_("File"), _("Exit"), "quit", "Esc"), new (_("Playback"), _("Play/Pause"), "script-message-to mpvnet play-pause", "Space"),