From 3bd1239457dac130ea0dea12866a8e36206ec542 Mon Sep 17 00:00:00 2001 From: ema Date: Wed, 4 Jun 2025 15:13:43 +0800 Subject: [PATCH] Restruct AppViewer codes --- .../{ => InfoPanels}/ApkInfoPanel.xaml | 2 +- .../{ => InfoPanels}/ApkInfoPanel.xaml.cs | 6 +- .../{ => InfoPanels}/AppxInfoPanel.xaml | 2 +- .../{ => InfoPanels}/AppxInfoPanel.xaml.cs | 6 +- .../InfoPanels/DebInfoPanel.xaml | 183 ++++++++++++++++++ .../InfoPanels/DebInfoPanel.xaml.cs | 78 ++++++++ .../{ => InfoPanels}/GroupBox.xaml | 4 +- .../{ => InfoPanels}/HapInfoPanel.xaml | 2 +- .../{ => InfoPanels}/HapInfoPanel.xaml.cs | 6 +- .../{ => InfoPanels}/IAppInfoPanel.cs | 2 +- .../{ => InfoPanels}/IpaInfoPanel.xaml | 2 +- .../{ => InfoPanels}/IpaInfoPanel.xaml.cs | 6 +- .../{ => InfoPanels}/MsiInfoPanel.xaml | 2 +- .../{ => InfoPanels}/MsiInfoPanel.xaml.cs | 6 +- .../{ => InfoPanels}/WgtInfoPanel.xaml | 2 +- .../{ => InfoPanels}/WgtInfoPanel.xaml.cs | 6 +- .../Apk}/ApkInfo.cs | 21 +- .../Apk}/ApkParser.cs | 2 +- .../Appx}/AppxBundleReader.cs | 6 +- .../Appx}/AppxInfo.cs | 2 +- .../Appx}/AppxParser.cs | 2 +- .../Appx}/AppxReader.cs | 2 +- .../PackageParsers/Deb/ArReader.cs | 65 +++++++ .../PackageParsers/Deb/DebInfo.cs | 22 +++ .../PackageParsers/Deb/DebParser.cs | 27 +++ .../Hap}/HapInfo.cs | 2 +- .../Hap}/HapParser.cs | 2 +- .../Ipa}/IpaInfo.cs | 2 +- .../Ipa}/IpaParser.cs | 2 +- .../Ipa}/IpaReader.cs | 2 +- .../Ipa}/Plist.cs | 12 +- .../Msi}/MsiInfo.cs | 2 +- .../Msi}/MsiParser.cs | 2 +- .../Wgt}/WgtInfo.cs | 2 +- .../Wgt}/WgtParser.cs | 2 +- .../QuickLook.Plugin.AppViewer/Plugin.cs | 6 + .../Resources/debian.png | Bin 0 -> 12619 bytes 37 files changed, 448 insertions(+), 52 deletions(-) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/ApkInfoPanel.xaml (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/ApkInfoPanel.xaml.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/AppxInfoPanel.xaml (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/AppxInfoPanel.xaml.cs (95%) create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/DebInfoPanel.xaml create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/DebInfoPanel.xaml.cs rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/GroupBox.xaml (92%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/HapInfoPanel.xaml (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/HapInfoPanel.xaml.cs (97%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/IAppInfoPanel.cs (94%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/IpaInfoPanel.xaml (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/IpaInfoPanel.xaml.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/MsiInfoPanel.xaml (98%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/MsiInfoPanel.xaml.cs (95%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/WgtInfoPanel.xaml (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ => InfoPanels}/WgtInfoPanel.xaml.cs (95%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ApkPackageParser => PackageParsers/Apk}/ApkInfo.cs (52%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{ApkPackageParser => PackageParsers/Apk}/ApkParser.cs (97%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{AppxPackageParser => PackageParsers/Appx}/AppxBundleReader.cs (95%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{AppxPackageParser => PackageParsers/Appx}/AppxInfo.cs (94%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{AppxPackageParser => PackageParsers/Appx}/AppxParser.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{AppxPackageParser => PackageParsers/Appx}/AppxReader.cs (98%) create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Deb/ArReader.cs create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Deb/DebInfo.cs create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Deb/DebParser.cs rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{HapPackageParser => PackageParsers/Hap}/HapInfo.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{HapPackageParser => PackageParsers/Hap}/HapParser.cs (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{IpaPackageParser => PackageParsers/Ipa}/IpaInfo.cs (95%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{IpaPackageParser => PackageParsers/Ipa}/IpaParser.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{IpaPackageParser => PackageParsers/Ipa}/IpaReader.cs (99%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{IpaPackageParser => PackageParsers/Ipa}/Plist.cs (98%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{MsiPackageParser => PackageParsers/Msi}/MsiInfo.cs (94%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{MsiPackageParser => PackageParsers/Msi}/MsiParser.cs (96%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{WgtPackageParser => PackageParsers/Wgt}/WgtInfo.cs (98%) rename QuickLook.Plugin/QuickLook.Plugin.AppViewer/{WgtPackageParser => PackageParsers/Wgt}/WgtParser.cs (98%) create mode 100644 QuickLook.Plugin/QuickLook.Plugin.AppViewer/Resources/debian.png diff --git a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/ApkInfoPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/ApkInfoPanel.xaml similarity index 99% rename from QuickLook.Plugin/QuickLook.Plugin.AppViewer/ApkInfoPanel.xaml rename to QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/ApkInfoPanel.xaml index c56c8c8..a916084 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/ApkInfoPanel.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/ApkInfoPanel.xaml @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/DebInfoPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/DebInfoPanel.xaml.cs new file mode 100644 index 0000000..98dfee1 --- /dev/null +++ b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/DebInfoPanel.xaml.cs @@ -0,0 +1,78 @@ +// 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 . + +using QuickLook.Common.ExtensionMethods; +using QuickLook.Common.Helpers; +using QuickLook.Common.Plugin; +using QuickLook.Plugin.AppViewer.PackageParsers.Deb; +using QuickLook.Plugin.AppViewer.PackageParsers.Wgt; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace QuickLook.Plugin.AppViewer.InfoPanels; + +public partial class DebInfoPanel : UserControl, IAppInfoPanel +{ + private readonly ContextObject _context; + + public DebInfoPanel(ContextObject context) + { + _context = context; + + DataContext = this; + InitializeComponent(); + + string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config"); + applicationNameTitle.Text = TranslationHelper.Get("APP_NAME", translationFile); + versionNameTitle.Text = TranslationHelper.Get("APP_VERSION_NAME", translationFile); + versionCodeTitle.Text = TranslationHelper.Get("APP_VERSION_CODE", translationFile); + totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile); + modDateTitle.Text = TranslationHelper.Get("LAST_MODIFIED", translationFile); + permissionsGroupBox.Header = TranslationHelper.Get("PERMISSIONS", translationFile); + } + + public void DisplayInfo(string path) + { + var name = Path.GetFileName(path); + filename.Text = string.IsNullOrEmpty(name) ? path : name; + + _ = Task.Run(() => + { + if (File.Exists(path)) + { + var size = new FileInfo(path).Length; + DebInfo wgtInfo = DebParser.Parse(path); + var last = File.GetLastWriteTime(path); + + Dispatcher.Invoke(() => + { + //applicationName.Text = wgtInfo.AppNameLocale ?? wgtInfo.AppName; + //versionName.Text = wgtInfo.AppVersionName; + //versionCode.Text = wgtInfo.AppVersionCode; + //totalSize.Text = size.ToPrettySize(2); + //modDate.Text = last.ToString(CultureInfo.CurrentCulture); + //permissions.ItemsSource = wgtInfo.Permissions; + + _context.IsBusy = false; + }); + } + }); + } +} diff --git a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/GroupBox.xaml b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/GroupBox.xaml similarity index 92% rename from QuickLook.Plugin/QuickLook.Plugin.AppViewer/GroupBox.xaml rename to QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/GroupBox.xaml index 8e6133e..104cdf5 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/GroupBox.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/InfoPanels/GroupBox.xaml @@ -1,6 +1,4 @@ - +