mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-03-10 01:02:55 +08:00
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:
@@ -0,0 +1,49 @@
|
||||
// Copyright © 2017-2025 QL-Win Contributors
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using QuickLook.Common.Commands;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin.MoreMenu;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace QuickLook.Plugin.ImageViewer;
|
||||
|
||||
public partial class Plugin
|
||||
{
|
||||
public IEnumerable<IMenuItem> GetMenuItems()
|
||||
{
|
||||
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
|
||||
string extension = Path.GetExtension(_currentPath).ToLower();
|
||||
|
||||
var reopen = extension switch
|
||||
{
|
||||
// SVG IMAGE <=> XML TEXT
|
||||
".svg" => new MoreMenuItem()
|
||||
{
|
||||
Icon = "\uE943",
|
||||
Header = TranslationHelper.Get("MW_ReopenAsSourceCode", translationFile),
|
||||
Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath)),
|
||||
},
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (reopen is not null)
|
||||
yield return reopen;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin;
|
||||
using QuickLook.Common.Plugin.MoreMenu;
|
||||
using QuickLook.Plugin.ImageViewer.AnimatedImage.Providers;
|
||||
using QuickLook.Plugin.ImageViewer.Webview;
|
||||
using System;
|
||||
@@ -28,7 +29,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace QuickLook.Plugin.ImageViewer;
|
||||
|
||||
public class Plugin : IViewer
|
||||
public partial class Plugin : IViewer, IMoreMenu
|
||||
{
|
||||
private static readonly HashSet<string> WellKnownExtensions = new(
|
||||
[
|
||||
@@ -56,6 +57,7 @@ public class Plugin : IViewer
|
||||
]);
|
||||
|
||||
private ImagePanel _ip;
|
||||
private string _currentPath;
|
||||
private MetaProvider _meta;
|
||||
|
||||
private IWebImagePanel _ipWeb;
|
||||
@@ -63,6 +65,8 @@ public class Plugin : IViewer
|
||||
|
||||
public int Priority => 0;
|
||||
|
||||
public IEnumerable<IMenuItem> MenuItems => GetMenuItems();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// Option of UseColorProfile:
|
||||
@@ -137,6 +141,8 @@ public class Plugin : IViewer
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
{
|
||||
_currentPath = path;
|
||||
|
||||
if (WebHandler.TryView(path, context, _metaWeb, out _ipWeb))
|
||||
return;
|
||||
|
||||
|
||||
@@ -138,4 +138,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Translations.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Translations>
|
||||
<ca>
|
||||
<MW_ReopenAsSourceCode>Torna a obrir com a codi font</MW_ReopenAsSourceCode>
|
||||
</ca>
|
||||
<he>
|
||||
<MW_ReopenAsSourceCode>פתח מחדש כקוד מקור</MW_ReopenAsSourceCode>
|
||||
</he>
|
||||
<hi>
|
||||
<MW_ReopenAsSourceCode>सोर्स कोड के रूप में पुनः खोलें</MW_ReopenAsSourceCode>
|
||||
</hi>
|
||||
<hu-HU>
|
||||
<MW_ReopenAsSourceCode>Újranyitás forráskódként</MW_ReopenAsSourceCode>
|
||||
</hu-HU>
|
||||
<id-ID>
|
||||
<MW_ReopenAsSourceCode>Buka ulang sebagai kode sumber</MW_ReopenAsSourceCode>
|
||||
</id-ID>
|
||||
<mr>
|
||||
<MW_ReopenAsSourceCode>स्रोत कोड म्हणून पुन्हा उघडा</MW_ReopenAsSourceCode>
|
||||
</mr>
|
||||
<nb-NO>
|
||||
<MW_ReopenAsSourceCode>Åpne på nytt som kildekode</MW_ReopenAsSourceCode>
|
||||
</nb-NO>
|
||||
<nl-NL>
|
||||
<MW_ReopenAsSourceCode>Opnieuw openen als broncode</MW_ReopenAsSourceCode>
|
||||
</nl-NL>
|
||||
<pt-BR>
|
||||
<MW_ReopenAsSourceCode>Reabrir como código-fonte</MW_ReopenAsSourceCode>
|
||||
</pt-BR>
|
||||
<pt-PT>
|
||||
<MW_ReopenAsSourceCode>Reabrir como código-fonte</MW_ReopenAsSourceCode>
|
||||
</pt-PT>
|
||||
<ru-RU>
|
||||
<MW_ReopenAsSourceCode>Открыть заново как исходный код</MW_ReopenAsSourceCode>
|
||||
</ru-RU>
|
||||
<sk>
|
||||
<MW_ReopenAsSourceCode>Znovu otvoriť ako zdrojový kód</MW_ReopenAsSourceCode>
|
||||
</sk>
|
||||
<tr-TR>
|
||||
<MW_ReopenAsSourceCode>Kaynak kod olarak yeniden aç</MW_ReopenAsSourceCode>
|
||||
</tr-TR>
|
||||
<vi>
|
||||
<MW_ReopenAsSourceCode>Mở lại dưới dạng mã nguồn</MW_ReopenAsSourceCode>
|
||||
</vi>
|
||||
<en>
|
||||
<MW_ReopenAsSourceCode>Reopen as source code</MW_ReopenAsSourceCode>
|
||||
</en>
|
||||
<ko>
|
||||
<MW_ReopenAsSourceCode>소스 코드로 다시 열기</MW_ReopenAsSourceCode>
|
||||
</ko>
|
||||
<de>
|
||||
<MW_ReopenAsSourceCode>Als Quellcode erneut öffnen</MW_ReopenAsSourceCode>
|
||||
</de>
|
||||
<fr>
|
||||
<MW_ReopenAsSourceCode>Rouvrir en tant que code source</MW_ReopenAsSourceCode>
|
||||
</fr>
|
||||
<ja>
|
||||
<MW_ReopenAsSourceCode>ソースコードとして再度開く</MW_ReopenAsSourceCode>
|
||||
</ja>
|
||||
<zh-CN>
|
||||
<MW_ReopenAsSourceCode>以源代码方式重新打开</MW_ReopenAsSourceCode>
|
||||
</zh-CN>
|
||||
<zh-TW>
|
||||
<MW_ReopenAsSourceCode>以原始碼方式重新開啟</MW_ReopenAsSourceCode>
|
||||
</zh-TW>
|
||||
<es>
|
||||
<MW_ReopenAsSourceCode>Reabrir como código fuente</MW_ReopenAsSourceCode>
|
||||
</es>
|
||||
<it>
|
||||
<MW_ReopenAsSourceCode>Riapri come codice sorgente</MW_ReopenAsSourceCode>
|
||||
</it>
|
||||
<ar>
|
||||
<MW_ReopenAsSourceCode>إعادة الفتح كرمز مصدر</MW_ReopenAsSourceCode>
|
||||
</ar>
|
||||
<pl>
|
||||
<MW_ReopenAsSourceCode>Otwórz ponownie jako kod źródłowy</MW_ReopenAsSourceCode>
|
||||
</pl>
|
||||
<el>
|
||||
<MW_ReopenAsSourceCode>Επαναάνοιγμα ως πηγαίος κώδικας</MW_ReopenAsSourceCode>
|
||||
</el>
|
||||
<uk-UA>
|
||||
<MW_ReopenAsSourceCode>Відкрити знову як вихідний код</MW_ReopenAsSourceCode>
|
||||
</uk-UA>
|
||||
<sv>
|
||||
<MW_ReopenAsSourceCode>Öppna igen som källkod</MW_ReopenAsSourceCode>
|
||||
</sv>
|
||||
</Translations>
|
||||
Reference in New Issue
Block a user