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.
This commit is contained in:
ema
2025-10-10 17:39:32 +08:00
parent 39ee2f6b00
commit 6a6c411efb
7 changed files with 13 additions and 17 deletions

View File

@@ -16,6 +16,7 @@
// 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 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)),
};

View File

@@ -16,6 +16,7 @@
// 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 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)),
},

View File

@@ -16,6 +16,7 @@
// 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 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,

View File

@@ -16,6 +16,7 @@
// 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 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)),
},

View File

@@ -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));
}
/// <summary>
/// Segoe Fluent Icons
/// https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font
/// </summary>
private sealed class FontSymbols
{
public const string Play = "\xe768";
public const string Pause = "\xe769";
}
}

View File

@@ -15,6 +15,7 @@
// 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.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)
{