Skip to content

Commit e7559f3

Browse files
committed
Add CFB extract to directory menu
1 parent 36d2d44 commit e7559f3

File tree

5 files changed

+210
-2
lines changed

5 files changed

+210
-2
lines changed

QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/CompoundFileBinary/CompoundInfoPanel.xaml.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// Copyright © 2017-2025 QL-Win Contributors
2+
//
3+
// This file is part of QuickLook program.
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
118
using QuickLook.Common.ExtensionMethods;
219
using QuickLook.Common.Helpers;
320
using QuickLook.Plugin.ArchiveViewer.ArchiveFile;
@@ -6,7 +23,6 @@
623
using System.ComponentModel;
724
using System.IO;
825
using System.Runtime.CompilerServices;
9-
using System.Runtime.InteropServices.ComTypes;
1026
using System.Threading.Tasks;
1127
using System.Windows.Controls;
1228

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright © 2017-2025 QL-Win Contributors
2+
//
3+
// This file is part of QuickLook program.
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
using QuickLook.Common.Commands;
19+
using QuickLook.Common.Controls;
20+
using QuickLook.Common.Helpers;
21+
using QuickLook.Common.Plugin.MoreMenu;
22+
using QuickLook.Plugin.ArchiveViewer.CompoundFileBinary;
23+
using System;
24+
using System.Collections.Generic;
25+
using System.IO;
26+
using System.Reflection;
27+
using System.Threading.Tasks;
28+
using System.Windows.Input;
29+
using WindowsAPICodePack.Dialogs;
30+
31+
namespace QuickLook.Plugin.ArchiveViewer;
32+
33+
public partial class Plugin
34+
{
35+
public ICommand ExtractToDirectoryCommand { get; }
36+
37+
public Plugin()
38+
{
39+
ExtractToDirectoryCommand = new AsyncRelayCommand(ExtractToDirectoryAsync);
40+
}
41+
42+
public IEnumerable<IMenuItem> GetMenuItems()
43+
{
44+
if (_path.EndsWith(".eif", StringComparison.OrdinalIgnoreCase))
45+
{
46+
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
47+
48+
yield return new MoreMenuItem()
49+
{
50+
Icon = FontSymbols.MoveToFolder,
51+
Header = TranslationHelper.Get("MW_ExtractToDirectory", translationFile),
52+
MenuItems = null,
53+
Command = ExtractToDirectoryCommand,
54+
};
55+
}
56+
}
57+
58+
public async Task ExtractToDirectoryAsync()
59+
{
60+
using CommonOpenFileDialog dialog = new()
61+
{
62+
IsFolderPicker = true,
63+
};
64+
65+
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
66+
{
67+
await Task.Run(() =>
68+
{
69+
if (_path.EndsWith(".cfb", StringComparison.OrdinalIgnoreCase))
70+
{
71+
CompoundFileExtractor.ExtractToDirectory(_path, dialog.FileName);
72+
}
73+
else if (_path.EndsWith(".eif", StringComparison.OrdinalIgnoreCase))
74+
{
75+
CompoundFileExtractor.ExtractToDirectory(_path, dialog.FileName);
76+
77+
string faceDatPath = Path.Combine(dialog.FileName, "face.dat");
78+
79+
if (File.Exists(faceDatPath))
80+
{
81+
Dictionary<string, Dictionary<string, int>> faceDat = FaceDatDecoder.Decode(File.ReadAllBytes(faceDatPath));
82+
_ = faceDat;
83+
}
84+
}
85+
});
86+
}
87+
}
88+
}

QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/Plugin.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
using QuickLook.Common.Plugin;
19+
using QuickLook.Common.Plugin.MoreMenu;
1920
using QuickLook.Plugin.ArchiveViewer.ArchiveFile;
2021
using QuickLook.Plugin.ArchiveViewer.CompoundFileBinary;
2122
using System;
23+
using System.Collections.Generic;
2224
using System.IO;
2325
using System.Linq;
2426
using System.Windows;
2527

2628
namespace QuickLook.Plugin.ArchiveViewer;
2729

28-
public class Plugin : IViewer
30+
public partial class Plugin : IViewer, IMoreMenu
2931
{
3032
private static readonly string[] _extensions =
3133
[
@@ -56,9 +58,12 @@ public class Plugin : IViewer
5658
];
5759

5860
private IDisposable _panel;
61+
private string _path;
5962

6063
public int Priority => -5;
6164

65+
public IEnumerable<IMenuItem> MenuItems => GetMenuItems();
66+
6267
public void Init()
6368
{
6469
}
@@ -70,6 +75,7 @@ public bool CanHandle(string path)
7075

7176
public void Prepare(string path, ContextObject context)
7277
{
78+
_path = path;
7379
context.PreferredSize = new Size { Width = 800, Height = 400 };
7480
}
7581

QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/QuickLook.Plugin.ArchiveViewer.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<ItemGroup>
5555
<PackageReference Include="PureSharpCompress" Version="0.40.0" />
5656
<PackageReference Include="UTF.Unknown" Version="2.6.0" />
57+
<PackageReference Include="WindowsAPICodePack.Shell.CommonFileDialogs" Version="1.1.5" />
5758
</ItemGroup>
5859

5960
<ItemGroup>
@@ -70,4 +71,10 @@
7071
</Compile>
7172
</ItemGroup>
7273

74+
<ItemGroup>
75+
<None Update="Translations.config">
76+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
77+
</None>
78+
</ItemGroup>
79+
7380
</Project>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<Translations>
4+
<ar>
5+
<MW_ExtractToDirectory>استخراج إلى المجلد</MW_ExtractToDirectory>
6+
</ar>
7+
<ca>
8+
<MW_ExtractToDirectory>Extreu a la carpeta</MW_ExtractToDirectory>
9+
</ca>
10+
<he>
11+
<MW_ExtractToDirectory>חלץ לתיקייה</MW_ExtractToDirectory>
12+
</he>
13+
<hi>
14+
<MW_ExtractToDirectory>डायरेक्टरी में निकालें</MW_ExtractToDirectory>
15+
</hi>
16+
<mr>
17+
<MW_ExtractToDirectory>डायरेक्टरीमध्ये काढा</MW_ExtractToDirectory>
18+
</mr>
19+
<hu-HU>
20+
<MW_ExtractToDirectory>Kibontás mappába</MW_ExtractToDirectory>
21+
</hu-HU>
22+
<nb-NO>
23+
<MW_ExtractToDirectory>Pakk ut til mappe</MW_ExtractToDirectory>
24+
</nb-NO>
25+
<nl-NL>
26+
<MW_ExtractToDirectory>Uitpakken naar map</MW_ExtractToDirectory>
27+
</nl-NL>
28+
<sk>
29+
<MW_ExtractToDirectory>Extrahovať do priečinka</MW_ExtractToDirectory>
30+
</sk>
31+
<id-ID>
32+
<MW_ExtractToDirectory>Ekstrak ke folder</MW_ExtractToDirectory>
33+
</id-ID>
34+
<en>
35+
<MW_ExtractToDirectory>Extract to directory</MW_ExtractToDirectory>
36+
</en>
37+
<ko>
38+
<MW_ExtractToDirectory>폴더로 추출</MW_ExtractToDirectory>
39+
</ko>
40+
<pt-BR>
41+
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
42+
</pt-BR>
43+
<pt-PT>
44+
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
45+
</pt-PT>
46+
<ru-RU>
47+
<MW_ExtractToDirectory>Извлечь в папку</MW_ExtractToDirectory>
48+
</ru-RU>
49+
<tr-TR>
50+
<MW_ExtractToDirectory>Klasöre çıkar</MW_ExtractToDirectory>
51+
</tr-TR>
52+
<vi>
53+
<MW_ExtractToDirectory>Trích xuất vào thư mục</MW_ExtractToDirectory>
54+
</vi>
55+
<pt-PT>
56+
<MW_ExtractToDirectory>Extrair para a pasta</MW_ExtractToDirectory>
57+
</pt-PT>
58+
<fr>
59+
<MW_ExtractToDirectory>Extraire vers le dossier</MW_ExtractToDirectory>
60+
</fr>
61+
<es>
62+
<MW_ExtractToDirectory>Extraer a la carpeta</MW_ExtractToDirectory>
63+
</es>
64+
<it>
65+
<MW_ExtractToDirectory>Estrai nella cartella</MW_ExtractToDirectory>
66+
</it>
67+
<pl>
68+
<MW_ExtractToDirectory>Wyodrębnij do folderu</MW_ExtractToDirectory>
69+
</pl>
70+
<el>
71+
<MW_ExtractToDirectory>Εξαγωγή σε φάκελο</MW_ExtractToDirectory>
72+
</el>
73+
<uk-UA>
74+
<MW_ExtractToDirectory>Розпакувати до папки</MW_ExtractToDirectory>
75+
</uk-UA>
76+
<zh-CN>
77+
<MW_ExtractToDirectory>提取到目录</MW_ExtractToDirectory>
78+
</zh-CN>
79+
<zh-TW>
80+
<MW_ExtractToDirectory>提取到資料夾</MW_ExtractToDirectory>
81+
</zh-TW>
82+
<ja>
83+
<MW_ExtractToDirectory>フォルダに抽出</MW_ExtractToDirectory>
84+
</ja>
85+
<de>
86+
<MW_ExtractToDirectory>In Ordner extrahieren</MW_ExtractToDirectory>
87+
</de>
88+
<sv>
89+
<MW_ExtractToDirectory>Extrahera till mapp</MW_ExtractToDirectory>
90+
</sv>
91+
</Translations>

0 commit comments

Comments
 (0)