|
| 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.Helpers; |
| 20 | +using QuickLook.Common.Plugin.MoreMenu; |
| 21 | +using System.Collections.Generic; |
| 22 | +using System.IO; |
| 23 | +using System.Reflection; |
| 24 | + |
| 25 | +namespace QuickLook.Plugin.ImageViewer; |
| 26 | + |
| 27 | +public partial class Plugin |
| 28 | +{ |
| 29 | + public IEnumerable<IMenuItem> GetMenuItems() |
| 30 | + { |
| 31 | + string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config"); |
| 32 | + string extension = Path.GetExtension(_currentPath).ToLower(); |
| 33 | + |
| 34 | + var reopen = extension switch |
| 35 | + { |
| 36 | + // SVG IMAGE <=> XML TEXT |
| 37 | + ".svg" => new MoreMenuItem() |
| 38 | + { |
| 39 | + Icon = "\uE943", |
| 40 | + Header = TranslationHelper.Get("MW_ReopenAsSourceCode", translationFile), |
| 41 | + Command = new RelayCommand(() => PluginHelper.InvokePluginPreview("QuickLook.Plugin.TextViewer", _currentPath)), |
| 42 | + }, |
| 43 | + _ => null, |
| 44 | + }; |
| 45 | + |
| 46 | + if (reopen is not null) |
| 47 | + yield return reopen; |
| 48 | + } |
| 49 | +} |
0 commit comments