Add cross-plugin 'Reopen as' menu for SVG and HTML

Introduces 'Reopen as source code' and 'Reopen as image preview' options in the MoreMenu for SVG and HTML files, enabling users to switch between ImageViewer and TextViewer plugins. Updates translation files to support new menu items in multiple languages and refactors related plugin code for extensibility.
This commit is contained in:
ema
2025-10-08 01:54:12 +08:00
parent f7c029f127
commit 432b3b033a
9 changed files with 193 additions and 32 deletions

View File

@@ -21,33 +21,21 @@ using QuickLook.Common.Plugin.MoreMenu;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows.Input;
namespace QuickLook.Plugin.HtmlViewer;
public partial class Plugin
{
public ICommand ViewSourceCodeCommand { get; }
public Plugin()
{
ViewSourceCodeCommand = new RelayCommand(ViewSourceCode);
}
public IEnumerable<IMenuItem> GetMenuItems()
{
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
// HTML <=> HTML TEXT
yield return new MoreMenuItem()
{
Icon = "\uE943",
Header = TranslationHelper.Get("MW_ReopenAsSourceCode", translationFile),
Command = ViewSourceCodeCommand,
Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath)),
};
}
public void ViewSourceCode()
{
PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath);
}
}