From 6a6c411efb4e8a1585c6567761de66670e412d24 Mon Sep 17 00:00:00 2001 From: ema Date: Fri, 10 Oct 2025 17:39:32 +0800 Subject: [PATCH] Refactor icon usage to use FontSymbols constants Replaced hardcoded icon strings with FontSymbols constants in MoreMenu and converter classes for consistency and maintainability. Removed duplicate FontSymbols class from MidiPlayer and updated usages to reference QuickLook.Common.Controls. --- QuickLook.Common | 2 +- .../QuickLook.Plugin.HtmlViewer/Plugin.MoreMenu.cs | 3 ++- .../QuickLook.Plugin.ImageViewer/Plugin.MoreMenu.cs | 3 ++- .../Plugin.MoreMenu.cs | 3 ++- .../QuickLook.Plugin.TextViewer/Plugin.MoreMenu.cs | 5 +++-- .../AudioTrack/MidiPlayer.cs | 11 +---------- .../QuickLook.Plugin.VideoViewer/Converters.cs | 3 ++- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/QuickLook.Common b/QuickLook.Common index 2dc2616..ffda897 160000 --- a/QuickLook.Common +++ b/QuickLook.Common @@ -1 +1 @@ -Subproject commit 2dc2616aebfd79c428e5a4e94a40368df5bbe3d4 +Subproject commit ffda8978fad9525e18f5d0c3e74d482cc764d48c diff --git a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.MoreMenu.cs b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.MoreMenu.cs index 33d6686..9b6bf10 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.MoreMenu.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.MoreMenu.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using QuickLook.Common.Commands; +using QuickLook.Common.Controls; using QuickLook.Common.Helpers; using QuickLook.Common.Plugin.MoreMenu; using System.Collections.Generic; @@ -33,7 +34,7 @@ public partial class Plugin // HTML <=> HTML TEXT yield return new MoreMenuItem() { - Icon = "\uE943", + Icon = FontSymbols.Code, Header = TranslationHelper.Get("MW_ReopenAsSourceCode", translationFile), Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath)), }; diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.MoreMenu.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.MoreMenu.cs index 2cd525d..f30854a 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.MoreMenu.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.MoreMenu.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using QuickLook.Common.Commands; +using QuickLook.Common.Controls; using QuickLook.Common.Helpers; using QuickLook.Common.Plugin.MoreMenu; using System.Collections.Generic; @@ -36,7 +37,7 @@ public partial class Plugin // SVG IMAGE <=> XML TEXT ".svg" => new MoreMenuItem() { - Icon = "\uE943", + Icon = FontSymbols.Code, Header = TranslationHelper.Get("MW_ReopenAsSourceCode", translationFile), Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath)), }, diff --git a/QuickLook.Plugin/QuickLook.Plugin.MediaInfoViewer/Plugin.MoreMenu.cs b/QuickLook.Plugin/QuickLook.Plugin.MediaInfoViewer/Plugin.MoreMenu.cs index 0045d4d..5a7cb9f 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.MediaInfoViewer/Plugin.MoreMenu.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.MediaInfoViewer/Plugin.MoreMenu.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using QuickLook.Common.Commands; +using QuickLook.Common.Controls; using QuickLook.Common.Helpers; using QuickLook.Common.Plugin.MoreMenu; using System.Collections.Generic; @@ -40,7 +41,7 @@ public partial class Plugin yield return new MoreMenuItem() { - Icon = "\xea69", + Icon = FontSymbols.Media, Header = TranslationHelper.Get("MW_ShowMediaInfo", translationFile), MenuItems = null, Command = ShowWithMediaInfoCommand, diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.MoreMenu.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.MoreMenu.cs index b7b7f9c..90bc8bd 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.MoreMenu.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.MoreMenu.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using QuickLook.Common.Commands; +using QuickLook.Common.Controls; using QuickLook.Common.Helpers; using QuickLook.Common.Plugin.MoreMenu; using System.Collections.Generic; @@ -38,7 +39,7 @@ public partial class Plugin // .html;.htm;.xhtml;.shtml;.shtm;.xht;.hta ".html" or ".htm" or ".xhtml" or ".shtml" or ".shtm" or ".xht" or ".hta" => new MoreMenuItem() { - Icon = "\uE774", + Icon = FontSymbols.Globe, Header = TranslationHelper.Get("MW_ReopenAsHtmlPreview", translationFile), Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.HtmlViewer", _currentPath)), }, @@ -46,7 +47,7 @@ public partial class Plugin // SVG IMAGE <=> XML TEXT ".svg" => new MoreMenuItem() { - Icon = "\uE774", + Icon = FontSymbols.Picture, Header = TranslationHelper.Get("MW_ReopenAsImagePreview", translationFile), Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.ImageViewer", _currentPath)), }, diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs index c072716..f97b335 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs @@ -19,6 +19,7 @@ using Melanchall.DryWetMidi.Core; using Melanchall.DryWetMidi.Interaction; using Melanchall.DryWetMidi.Multimedia; using QuickLook.Common.Annotations; +using QuickLook.Common.Controls; using QuickLook.Common.Plugin; using System; using System.ComponentModel; @@ -208,14 +209,4 @@ internal class MidiPlayer : IDisposable, INotifyPropertyChanged { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - - /// - /// Segoe Fluent Icons - /// https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font - /// - private sealed class FontSymbols - { - public const string Play = "\xe768"; - public const string Pause = "\xe769"; - } } diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs index bab2ba9..e736010 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Converters.cs @@ -15,6 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +using QuickLook.Common.Controls; using System; using System.Globalization; using System.Windows; @@ -49,7 +50,7 @@ public sealed class TimeTickToShortStringConverter : DependencyObject, IValueCon public sealed class VolumeToIconConverter : DependencyObject, IValueConverter { - private static readonly string[] Volumes = ["\xE74F", "\xE993", "\xE994", "\xE995"]; + private static readonly string[] Volumes = [FontSymbols.Mute, FontSymbols.Volume1, FontSymbols.Volume2, FontSymbols.Volume3]; public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {