From cecf6fb089f2c338c0721426dcfbe1f6a01f5eb3 Mon Sep 17 00:00:00 2001 From: Mykhailo Pylyp Date: Tue, 1 Jun 2021 10:57:53 +0300 Subject: [PATCH] Save relative path to settings (#11543) --- src/modules/launcher/PowerLauncher/SettingsReader.cs | 10 ++++++++-- src/modules/launcher/Wox.Plugin/PluginMetadata.cs | 2 -- .../ViewModels/PowerLauncherPluginViewModel.cs | 11 ++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/modules/launcher/PowerLauncher/SettingsReader.cs b/src/modules/launcher/PowerLauncher/SettingsReader.cs index bf4b7bf98a..1d515a94e9 100644 --- a/src/modules/launcher/PowerLauncher/SettingsReader.cs +++ b/src/modules/launcher/PowerLauncher/SettingsReader.cs @@ -193,6 +193,12 @@ namespace PowerLauncher return results.Values.ToList(); } + private static string GetIcon(PluginMetadata metadata, string iconPath) + { + var pluginDirectory = Path.GetFileName(metadata.PluginDirectory); + return Path.Combine(pluginDirectory, iconPath); + } + private static IEnumerable GetDefaultPluginsSettings() { return PluginManager.AllPlugins.Select(x => new PowerLauncherPluginSettings() @@ -204,8 +210,8 @@ namespace PowerLauncher Disabled = x.Metadata.Disabled, IsGlobal = x.Metadata.IsGlobal, ActionKeyword = x.Metadata.ActionKeyword, - IconPathDark = x.Metadata.IcoPathDark, - IconPathLight = x.Metadata.IcoPathLight, + IconPathDark = GetIcon(x.Metadata, x.Metadata.IcoPathDark), + IconPathLight = GetIcon(x.Metadata, x.Metadata.IcoPathLight), AdditionalOptions = x.Plugin is ISettingProvider ? (x.Plugin as ISettingProvider).AdditionalOptions : new List(), }); } diff --git a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs index 5407459f3d..1ac2a61658 100644 --- a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs +++ b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs @@ -51,8 +51,6 @@ namespace Wox.Plugin { _pluginDirectory = value; ExecuteFilePath = Path.Combine(value, ExecuteFileName); - IcoPathDark = Path.Combine(value, IcoPathDark); - IcoPathLight = Path.Combine(value, IcoPathLight); } } diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherPluginViewModel.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherPluginViewModel.cs index feb1bf9b68..cde36c964d 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherPluginViewModel.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/PowerLauncherPluginViewModel.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.IO; using System.Linq; using System.Runtime.CompilerServices; @@ -128,7 +129,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels return $"{Name}. {Description}"; } - public string IconPath { get => isDark() ? settings.IconPathDark : settings.IconPathLight; } + public string IconPath + { + get + { + var path = isDark() ? settings.IconPathDark : settings.IconPathLight; + path = Path.Combine(Directory.GetCurrentDirectory(), @"modules\launcher\Plugins", path); + return path; + } + } private bool _showAdditionalInfoPanel;