Compare commits

...

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
889147480c Add IMoreMenu support to HtmlViewer with View Source Code option
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-10-06 18:40:21 +00:00
copilot-swe-agent[bot]
979c6394c3 Initial plan 2025-10-06 18:29:00 +00:00
4 changed files with 96 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
// 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;
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");
yield return new MoreMenuItem()
{
Icon = "\uE943",
Header = TranslationHelper.Get("MW_ViewSourceCode", translationFile),
MenuItems = null,
Command = ViewSourceCodeCommand,
};
}
public void ViewSourceCode()
{
PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath);
}
}

View File

@@ -16,7 +16,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using QuickLook.Common.Plugin;
using QuickLook.Common.Plugin.MoreMenu;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
@@ -24,15 +26,18 @@ using System.Windows.Threading;
namespace QuickLook.Plugin.HtmlViewer;
public class Plugin : IViewer
public partial class Plugin : IViewer, IMoreMenu
{
private static readonly string[] _extensions = [".mht", ".mhtml", ".htm", ".html"];
private static readonly string[] _extensions = [".mht", ".mhtml", ".htm", ".html", ".svg"];
private static readonly string[] _supportedProtocols = ["http", "https"];
private WebpagePanel _panel;
private string _currentPath;
public int Priority => 0;
public IEnumerable<IMenuItem> MenuItems => GetMenuItems();
public void Init()
{
}
@@ -53,6 +58,7 @@ public class Plugin : IViewer
public void View(string path, ContextObject context)
{
_panel = new WebpagePanel();
_currentPath = path;
context.ViewerContent = _panel;
context.Title = Path.IsPathRooted(path) ? Path.GetFileName(path) : path;

View File

@@ -85,4 +85,10 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Translations.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -3,86 +3,114 @@
<Translations>
<ca>
<WEBVIEW2_NOT_AVAILABLE>Cal instal·lar Microsoft Edge WebView2 per veure aquest fitxer.&#10;Feu clic aquí per descarregar-lo.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Veure codi font</MW_ViewSourceCode>
</ca>
<he>
<WEBVIEW2_NOT_AVAILABLE>צפייה בקובץ זה דורשת התקנת Microsoft Edge WebView2.&#10;לחץ כאן להורדה.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>הצג קוד מקור</MW_ViewSourceCode>
</he>
<hi>
<WEBVIEW2_NOT_AVAILABLE>इस फ़ाइल को देखने के लिए Microsoft Edge WebView2 इंस्टॉल होना आवश्यक है।&#10;डाउनलोड करने के लिए यहां क्लिक करें.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>स्रोत कोड देखें</MW_ViewSourceCode>
</hi>
<hu-HU>
<WEBVIEW2_NOT_AVAILABLE>A fájl megtekintéséhez telepíteni kell a Microsoft Edge WebView2-t.&#10;Kattintson ide a letöltéshez.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Forráskód megtekintése</MW_ViewSourceCode>
</hu-HU>
<id-ID>
<WEBVIEW2_NOT_AVAILABLE>Melihat file ini memerlukan Microsoft Edge WebView2 terinstal.&#10;Klik di sini untuk mengunduhnya.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Lihat Kode Sumber</MW_ViewSourceCode>
</id-ID>
<mr>
<WEBVIEW2_NOT_AVAILABLE>या फाइलचे दृश्य Microsoft Edge WebView2 स्थापित असणे आवश्यक आहे.&#10;डाउनलोडसाठी येथे क्लिक करा.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>स्रोत कोड पहा</MW_ViewSourceCode>
</mr>
<nb-NO>
<WEBVIEW2_NOT_AVAILABLE>For å vise denne filen må Microsoft Edge WebView2 være installert.&#10;Klikk her for å laste ned.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Vis kildekode</MW_ViewSourceCode>
</nb-NO>
<nl-NL>
<WEBVIEW2_NOT_AVAILABLE>Voor het bekijken van dit bestand moet Microsoft Edge WebView2 geïnstalleerd zijn.&#10;Klik hier om te downloaden.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Broncode weergeven</MW_ViewSourceCode>
</nl-NL>
<pt-BR>
<WEBVIEW2_NOT_AVAILABLE>Para visualizar este arquivo, é necessário instalar o Microsoft Edge WebView2.&#10;Clique aqui para baixar.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Ver Código Fonte</MW_ViewSourceCode>
</pt-BR>
<pt-PT>
<WEBVIEW2_NOT_AVAILABLE>Para visualizar este ficheiro, é necessário instalar o Microsoft Edge WebView2.&#10;Clique aqui para descarregar.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Ver Código Fonte</MW_ViewSourceCode>
</pt-PT>
<ru-RU>
<WEBVIEW2_NOT_AVAILABLE>Для просмотра этого файла требуется установка Microsoft Edge WebView2.&#10;Нажмите здесь, чтобы скачать.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Посмотреть исходный код</MW_ViewSourceCode>
</ru-RU>
<sk>
<WEBVIEW2_NOT_AVAILABLE>Na zobrazenie tohto súboru je potrebné nainštalovať Microsoft Edge WebView2.&#10;Kliknite sem pre stiahnutie.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Zobraziť zdrojový kód</MW_ViewSourceCode>
</sk>
<tr-TR>
<WEBVIEW2_NOT_AVAILABLE>Bu dosyayı görüntülemek için Microsoft Edge WebView2'nin yüklü olması gerekir.&#10;İndirmek için buraya tıklayın.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Kaynak Kodu Görüntüle</MW_ViewSourceCode>
</tr-TR>
<vi>
<WEBVIEW2_NOT_AVAILABLE>Để xem tệp này, cần cài đặt Microsoft Edge WebView2.&#10;Nhấn vào đây để tải về.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Xem Mã Nguồn</MW_ViewSourceCode>
</vi>
<en>
<WEBVIEW2_NOT_AVAILABLE>Viewing this file requires Microsoft Edge WebView2 to be installed.&#10;Click here to download it.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>View Source Code</MW_ViewSourceCode>
</en>
<ko>
<WEBVIEW2_NOT_AVAILABLE>이 파일을 보려면 Microsoft Edge WebView2를 설치해야 합니다.&#10;여기를 클릭하여 다운로드하세요.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>소스 코드 보기</MW_ViewSourceCode>
</ko>
<de>
<WEBVIEW2_NOT_AVAILABLE>Für das Anzeigen dieses Dateityps wird MS Edge WebView2 benötigt.&#10;Hier klicken zum Downloaden.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Quellcode anzeigen</MW_ViewSourceCode>
</de>
<fr>
<WEBVIEW2_NOT_AVAILABLE>Microsoft Edge WebView2 est requis pour afficher ce type de fichier.&#10;Cliquez ici pour le télécharger.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Voir le code source</MW_ViewSourceCode>
</fr>
<ja>
<WEBVIEW2_NOT_AVAILABLE>このファイルを閲覧するには、Microsoft Edge WebView2 がインストールされている必要があります。&#10;ここをクリックしてダウンロードを開始する。</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>ソースコードを表示</MW_ViewSourceCode>
</ja>
<zh-CN>
<WEBVIEW2_NOT_AVAILABLE>查看此文件需要安装 Microsoft Edge WebView2。&#10;点击这里开始下载。</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>查看源代码</MW_ViewSourceCode>
</zh-CN>
<zh-TW>
<WEBVIEW2_NOT_AVAILABLE>查看此文件需要安裝 Microsoft Edge WebView2。&#10;點擊這裡開始下載。</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>查看原始碼</MW_ViewSourceCode>
</zh-TW>
<es>
<WEBVIEW2_NOT_AVAILABLE>Es necesario tener instalado Microsoft Edge WebView2 para ver este fichero.&#10;Haga clic aquí para descargarlo.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Ver código fuente</MW_ViewSourceCode>
</es>
<it>
<WEBVIEW2_NOT_AVAILABLE>Visualizzare questo file richiede che Microsoft Edge WebView2 sia installato.&#10;Clicca qui per scaricarlo.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Visualizza codice sorgente</MW_ViewSourceCode>
</it>
<ar>
<WEBVIEW2_NOT_AVAILABLE>مطلوب لعرض هذا الملف. انقر هنا لتحميله Microsoft Edge WebView2</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>عرض الكود المصدري</MW_ViewSourceCode>
</ar>
<pl>
<WEBVIEW2_NOT_AVAILABLE>Wyświetlenie tego pliku wymaga zainstalowania Microsoft Edge WebView2.&#10;Kliknij tutaj, aby go pobrać.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Wyświetl kod źródłowy</MW_ViewSourceCode>
</pl>
<el>
<WEBVIEW2_NOT_AVAILABLE>Για την προβολή αυτού του αρχείου απαιτείται εγκατάσταση του Microsoft Edge WebView2.&#10;Κάντε κλικ εδώ για να το κατεβάσετε.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Προβολή πηγαίου κώδικα</MW_ViewSourceCode>
</el>
<uk-UA>
<WEBVIEW2_NOT_AVAILABLE>Для перегляду цього файлу потрібно встановити Microsoft Edge WebView2.&#10;Натисніть тут, щоб завантажити його.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Переглянути вихідний код</MW_ViewSourceCode>
</uk-UA>
<sv>
<WEBVIEW2_NOT_AVAILABLE>För att visa denna fil krävs att Microsoft Edge WebView2 är installerat.&#10;Klicka här för att ladda ner det.</WEBVIEW2_NOT_AVAILABLE>
<MW_ViewSourceCode>Visa källkod</MW_ViewSourceCode>
</sv>
</Translations>