mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-13 07:05:24 +08:00
Add CFB extract to directory menu
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
// 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.ExtensionMethods;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Plugin.ArchiveViewer.ArchiveFile;
|
||||
@@ -6,7 +23,6 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// 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.Controls;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin.MoreMenu;
|
||||
using QuickLook.Plugin.ArchiveViewer.CompoundFileBinary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using WindowsAPICodePack.Dialogs;
|
||||
|
||||
namespace QuickLook.Plugin.ArchiveViewer;
|
||||
|
||||
public partial class Plugin
|
||||
{
|
||||
public ICommand ExtractToDirectoryCommand { get; }
|
||||
|
||||
public Plugin()
|
||||
{
|
||||
ExtractToDirectoryCommand = new AsyncRelayCommand(ExtractToDirectoryAsync);
|
||||
}
|
||||
|
||||
public IEnumerable<IMenuItem> GetMenuItems()
|
||||
{
|
||||
if (_path.EndsWith(".eif", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
|
||||
|
||||
yield return new MoreMenuItem()
|
||||
{
|
||||
Icon = FontSymbols.MoveToFolder,
|
||||
Header = TranslationHelper.Get("MW_ExtractToDirectory", translationFile),
|
||||
MenuItems = null,
|
||||
Command = ExtractToDirectoryCommand,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ExtractToDirectoryAsync()
|
||||
{
|
||||
using CommonOpenFileDialog dialog = new()
|
||||
{
|
||||
IsFolderPicker = true,
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (_path.EndsWith(".cfb", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
CompoundFileExtractor.ExtractToDirectory(_path, dialog.FileName);
|
||||
}
|
||||
else if (_path.EndsWith(".eif", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
CompoundFileExtractor.ExtractToDirectory(_path, dialog.FileName);
|
||||
|
||||
string faceDatPath = Path.Combine(dialog.FileName, "face.dat");
|
||||
|
||||
if (File.Exists(faceDatPath))
|
||||
{
|
||||
Dictionary<string, Dictionary<string, int>> faceDat = FaceDatDecoder.Decode(File.ReadAllBytes(faceDatPath));
|
||||
_ = faceDat;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,16 +16,18 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using QuickLook.Common.Plugin;
|
||||
using QuickLook.Common.Plugin.MoreMenu;
|
||||
using QuickLook.Plugin.ArchiveViewer.ArchiveFile;
|
||||
using QuickLook.Plugin.ArchiveViewer.CompoundFileBinary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace QuickLook.Plugin.ArchiveViewer;
|
||||
|
||||
public class Plugin : IViewer
|
||||
public partial class Plugin : IViewer, IMoreMenu
|
||||
{
|
||||
private static readonly string[] _extensions =
|
||||
[
|
||||
@@ -56,9 +58,12 @@ public class Plugin : IViewer
|
||||
];
|
||||
|
||||
private IDisposable _panel;
|
||||
private string _path;
|
||||
|
||||
public int Priority => -5;
|
||||
|
||||
public IEnumerable<IMenuItem> MenuItems => GetMenuItems();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
@@ -70,6 +75,7 @@ public class Plugin : IViewer
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
_path = path;
|
||||
context.PreferredSize = new Size { Width = 800, Height = 400 };
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="PureSharpCompress" Version="0.40.0" />
|
||||
<PackageReference Include="UTF.Unknown" Version="2.6.0" />
|
||||
<PackageReference Include="WindowsAPICodePack.Shell.CommonFileDialogs" Version="1.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -70,4 +71,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Translations.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Translations>
|
||||
<ar>
|
||||
<MW_ExtractToDirectory>استخراج إلى المجلد</MW_ExtractToDirectory>
|
||||
</ar>
|
||||
<ca>
|
||||
<MW_ExtractToDirectory>Extreu a la carpeta</MW_ExtractToDirectory>
|
||||
</ca>
|
||||
<he>
|
||||
<MW_ExtractToDirectory>חלץ לתיקייה</MW_ExtractToDirectory>
|
||||
</he>
|
||||
<hi>
|
||||
<MW_ExtractToDirectory>डायरेक्टरी में निकालें</MW_ExtractToDirectory>
|
||||
</hi>
|
||||
<mr>
|
||||
<MW_ExtractToDirectory>डायरेक्टरीमध्ये काढा</MW_ExtractToDirectory>
|
||||
</mr>
|
||||
<hu-HU>
|
||||
<MW_ExtractToDirectory>Kibontás mappába</MW_ExtractToDirectory>
|
||||
</hu-HU>
|
||||
<nb-NO>
|
||||
<MW_ExtractToDirectory>Pakk ut til mappe</MW_ExtractToDirectory>
|
||||
</nb-NO>
|
||||
<nl-NL>
|
||||
<MW_ExtractToDirectory>Uitpakken naar map</MW_ExtractToDirectory>
|
||||
</nl-NL>
|
||||
<sk>
|
||||
<MW_ExtractToDirectory>Extrahovať do priečinka</MW_ExtractToDirectory>
|
||||
</sk>
|
||||
<id-ID>
|
||||
<MW_ExtractToDirectory>Ekstrak ke folder</MW_ExtractToDirectory>
|
||||
</id-ID>
|
||||
<en>
|
||||
<MW_ExtractToDirectory>Extract to directory</MW_ExtractToDirectory>
|
||||
</en>
|
||||
<ko>
|
||||
<MW_ExtractToDirectory>폴더로 추출</MW_ExtractToDirectory>
|
||||
</ko>
|
||||
<pt-BR>
|
||||
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
|
||||
</pt-BR>
|
||||
<pt-PT>
|
||||
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
|
||||
</pt-PT>
|
||||
<ru-RU>
|
||||
<MW_ExtractToDirectory>Извлечь в папку</MW_ExtractToDirectory>
|
||||
</ru-RU>
|
||||
<tr-TR>
|
||||
<MW_ExtractToDirectory>Klasöre çıkar</MW_ExtractToDirectory>
|
||||
</tr-TR>
|
||||
<vi>
|
||||
<MW_ExtractToDirectory>Trích xuất vào thư mục</MW_ExtractToDirectory>
|
||||
</vi>
|
||||
<pt-PT>
|
||||
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
|
||||
</pt-PT>
|
||||
<fr>
|
||||
<MW_ExtractToDirectory>Extraire vers le dossier</MW_ExtractToDirectory>
|
||||
</fr>
|
||||
<es>
|
||||
<MW_ExtractToDirectory>Extraer a la carpeta</MW_ExtractToDirectory>
|
||||
</es>
|
||||
<it>
|
||||
<MW_ExtractToDirectory>Estrai nella cartella</MW_ExtractToDirectory>
|
||||
</it>
|
||||
<pl>
|
||||
<MW_ExtractToDirectory>Wyodrębnij do folderu</MW_ExtractToDirectory>
|
||||
</pl>
|
||||
<el>
|
||||
<MW_ExtractToDirectory>Εξαγωγή σε φάκελο</MW_ExtractToDirectory>
|
||||
</el>
|
||||
<uk-UA>
|
||||
<MW_ExtractToDirectory>Розпакувати до папки</MW_ExtractToDirectory>
|
||||
</uk-UA>
|
||||
<zh-CN>
|
||||
<MW_ExtractToDirectory>提取到目录</MW_ExtractToDirectory>
|
||||
</zh-CN>
|
||||
<zh-TW>
|
||||
<MW_ExtractToDirectory>提取到資料夾</MW_ExtractToDirectory>
|
||||
</zh-TW>
|
||||
<ja>
|
||||
<MW_ExtractToDirectory>フォルダに抽出</MW_ExtractToDirectory>
|
||||
</ja>
|
||||
<de>
|
||||
<MW_ExtractToDirectory>In Ordner extrahieren</MW_ExtractToDirectory>
|
||||
</de>
|
||||
<sv>
|
||||
<MW_ExtractToDirectory>Extrahera till mapp</MW_ExtractToDirectory>
|
||||
</sv>
|
||||
</Translations>
|
||||
Reference in New Issue
Block a user