diff --git a/Changelog.txt b/Changelog.txt index d1716395f..84760c1b5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -6,6 +6,7 @@ * ASSA override tag helper (shortcut + custom templates) * ASSA set/get position * ASSA plugin support + * Allow custom shortcuts for plugins * Shortcuts for video contrast/brightness (mpv only) * Waveform "Right-click + Ctrl" will toggle select of a subtitle * Waveform "Right-click + Shift" will select a range of subtitles diff --git a/src/libse/Common/PluginShortcut.cs b/src/libse/Common/PluginShortcut.cs new file mode 100644 index 000000000..30c2e65b4 --- /dev/null +++ b/src/libse/Common/PluginShortcut.cs @@ -0,0 +1,8 @@ +namespace Nikse.SubtitleEdit.Core.Common +{ + public class PluginShortcut + { + public string Name { get; set; } + public string Shortcut { get; set; } + } +} diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index ab3daf375..140a7720d 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -1867,6 +1867,7 @@ $HorzAlign = Center public class Shortcuts { + public List PluginShortcuts { get; set; } public string GeneralGoToFirstSelectedLine { get; set; } public string GeneralGoToNextEmptyLine { get; set; } public string GeneralMergeSelectedLines { get; set; } @@ -2154,6 +2155,7 @@ $HorzAlign = Center public Shortcuts() { + PluginShortcuts = new List(); GeneralGoToFirstSelectedLine = "Control+L"; GeneralMergeSelectedLines = "Control+Shift+M"; GeneralToggleTranslationMode = "Control+Shift+O"; @@ -6532,6 +6534,18 @@ $HorzAlign = Center node = doc.DocumentElement.SelectSingleNode("Shortcuts"); if (node != null) { + foreach (XmlNode pluginNode in node.SelectNodes("Plugins/Plugin")) + { + var nameNode = pluginNode.SelectSingleNode("Name"); + var shortcutNode = pluginNode.SelectSingleNode("Shortcut"); + if (nameNode != null && shortcutNode != null) + { + var name = nameNode.InnerText; + var shortcut = shortcutNode.InnerText; + shortcuts.PluginShortcuts.Add(new PluginShortcut { Name = name, Shortcut = shortcut }); + } + } + subNode = node.SelectSingleNode("GeneralGoToFirstSelectedLine"); if (subNode != null) { @@ -9042,6 +9056,17 @@ $HorzAlign = Center internal static void WriteShortcuts(Shortcuts shortcuts, XmlWriter textWriter) { textWriter.WriteStartElement("Shortcuts", string.Empty); + + textWriter.WriteStartElement("Plugins", string.Empty); + foreach (var shortcut in shortcuts.PluginShortcuts) + { + textWriter.WriteStartElement("Plugin"); + textWriter.WriteElementString("Name", shortcut.Name); + textWriter.WriteElementString("Shortcut", shortcut.Shortcut); + textWriter.WriteEndElement(); + } + textWriter.WriteEndElement(); + textWriter.WriteElementString("GeneralGoToFirstSelectedLine", shortcuts.GeneralGoToFirstSelectedLine); textWriter.WriteElementString("GeneralGoToNextEmptyLine", shortcuts.GeneralGoToNextEmptyLine); textWriter.WriteElementString("GeneralMergeSelectedLines", shortcuts.GeneralMergeSelectedLines); diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index dfae6f1d9..661b9a5b3 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -5310,6 +5310,7 @@ namespace Nikse.SubtitleEdit.Forms mediaPlayer.VideoPlayerContainerResize(null, null); ShowLineInformationListView(); ShowSourceLineNumber(); + LoadPlugins(); } private void SetAudioVisualizerSettings() @@ -22825,6 +22826,12 @@ namespace Nikse.SubtitleEdit.Forms item.ShortcutKeys = UiUtil.GetKeys(shortcut); } + var shortcutCustom = Configuration.Settings.Shortcuts.PluginShortcuts.FirstOrDefault(p => p.Name == name); + if (shortcutCustom != null) + { + item.ShortcutKeys = UiUtil.GetKeys(shortcutCustom.Shortcut); + } + if (actionType.Equals("File", StringComparison.OrdinalIgnoreCase)) { AddSeparator(fileMenuItems.Count, fileToolStripMenuItem, 2); diff --git a/src/ui/Forms/Main.resx b/src/ui/Forms/Main.resx index f1bec5632..d46db0791 100644 --- a/src/ui/Forms/Main.resx +++ b/src/ui/Forms/Main.resx @@ -464,75 +464,75 @@ iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU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AQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAYQBKgGEASoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAZQBKgGUASoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index d2fa2c454..afb9dfccc 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -45,6 +45,7 @@ namespace Nikse.SubtitleEdit.Forms.Options private bool _oldListViewShowWpm; private readonly Dictionary _newShortcuts = new Dictionary(); private List _rulesProfiles; + private List _pluginShortcuts; private class ComboBoxLanguage { @@ -76,14 +77,16 @@ namespace Nikse.SubtitleEdit.Forms.Options public class ShortcutHelper { - public ShortcutHelper(PropertyInfo shortcut, bool isMenuItem) + public ShortcutHelper(PropertyInfo shortcut, bool isMenuItem, bool isPlugin = false) { Shortcut = shortcut; IsMenuItem = isMenuItem; + IsPlugin = isPlugin; } public PropertyInfo Shortcut { get; set; } public bool IsMenuItem { get; set; } + public bool IsPlugin { get; set; } } private static string GetRelativePath(string fileName) @@ -1543,6 +1546,8 @@ namespace Nikse.SubtitleEdit.Forms.Options AddNode(audioVisualizerNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsLeft)); AddNode(audioVisualizerNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsRight)); _shortcuts.Nodes.Add(audioVisualizerNode); + + LoadPluginsShortcuts(); } private void ShowShortcutsTreeView() @@ -2061,9 +2066,13 @@ namespace Nikse.SubtitleEdit.Forms.Options gs.FFmpegLocation = textBoxFFmpegPath.Text; // save shortcuts + Configuration.Settings.Shortcuts.PluginShortcuts = _pluginShortcuts; foreach (var kvp in _newShortcuts) { - kvp.Key.Shortcut.SetValue(Configuration.Settings.Shortcuts, kvp.Value, null); + if (!kvp.Key.IsPlugin) + { + kvp.Key.Shortcut.SetValue(Configuration.Settings.Shortcuts, kvp.Value, null); + } } Configuration.Settings.Save(); @@ -2628,6 +2637,42 @@ namespace Nikse.SubtitleEdit.Forms.Options section.Visible = true; } + private void LoadPluginsShortcuts() + { + if (_pluginShortcuts == null) + { + _pluginShortcuts = Configuration.Settings.Shortcuts.PluginShortcuts.Select(p => new PluginShortcut { Name = p.Name, Shortcut = p.Shortcut }).ToList(); + } + + var pluginsNode = new ShortcutNode(LanguageSettings.Current.PluginsGet.Title); + foreach (var pluginFileName in Directory.GetFiles(Configuration.PluginsDirectory, "*.DLL")) + { + Main.GetPropertiesAndDoAction(pluginFileName, out var name, out _, out var version, out var description, out var actionType, out _, out var mi); + if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) + { + var text = GetPluginShortcutText(name); + var shortcutNode = new ShortcutNode(text) + { + Text = text, + ShortcutText = name, + Shortcut = new ShortcutHelper(null, true, true), + }; + pluginsNode.Nodes.Add(shortcutNode); + } + } + + if (pluginsNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(pluginsNode); + } + } + + private string GetPluginShortcutText(string name) + { + var shortcut = _pluginShortcuts.FirstOrDefault(p => p.Name == name); + return shortcut == null ? $"{name} [{LanguageSettings.Current.General.None}]" : $"{name} [{shortcut.Shortcut}]"; + } + private void ListBoxKeyDownSearch(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape || @@ -2998,11 +3043,26 @@ namespace Nikse.SubtitleEdit.Forms.Options var shortcutText = GetCurrentShortcutText(); var existsIn = new StringBuilder(); var sh = (ShortcutHelper)treeViewShortcuts.SelectedNode.Tag; + + if (sh.IsPlugin) + { + var cleanShortcut = shortcutText.RemoveChar('[').RemoveChar(']'); + var existingShortCut = _pluginShortcuts.FirstOrDefault(p => p.Name == text); + if (existingShortCut == null) + { + _pluginShortcuts.Add(new PluginShortcut { Name = text, Shortcut = cleanShortcut }); + } + else + { + existingShortCut.Shortcut = cleanShortcut; + } + } + foreach (ShortcutNode parent in _shortcuts.Nodes) { foreach (ShortcutNode subNode in parent.Nodes) { - if (sh != null && subNode.Shortcut.Shortcut.Name == sh.Shortcut.Name) + if (sh != null && !sh.IsPlugin && subNode.Shortcut.Shortcut.Name == sh.Shortcut.Name) { subNode.Text = text + " " + shortcutText; }