Save relative path to settings (#11543)

This commit is contained in:
Mykhailo Pylyp 2021-06-01 10:57:53 +03:00 committed by GitHub
parent 3807673574
commit cecf6fb089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -193,6 +193,12 @@ namespace PowerLauncher
return results.Values.ToList(); 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<PowerLauncherPluginSettings> GetDefaultPluginsSettings() private static IEnumerable<PowerLauncherPluginSettings> GetDefaultPluginsSettings()
{ {
return PluginManager.AllPlugins.Select(x => new PowerLauncherPluginSettings() return PluginManager.AllPlugins.Select(x => new PowerLauncherPluginSettings()
@ -204,8 +210,8 @@ namespace PowerLauncher
Disabled = x.Metadata.Disabled, Disabled = x.Metadata.Disabled,
IsGlobal = x.Metadata.IsGlobal, IsGlobal = x.Metadata.IsGlobal,
ActionKeyword = x.Metadata.ActionKeyword, ActionKeyword = x.Metadata.ActionKeyword,
IconPathDark = x.Metadata.IcoPathDark, IconPathDark = GetIcon(x.Metadata, x.Metadata.IcoPathDark),
IconPathLight = x.Metadata.IcoPathLight, IconPathLight = GetIcon(x.Metadata, x.Metadata.IcoPathLight),
AdditionalOptions = x.Plugin is ISettingProvider ? (x.Plugin as ISettingProvider).AdditionalOptions : new List<PluginAdditionalOption>(), AdditionalOptions = x.Plugin is ISettingProvider ? (x.Plugin as ISettingProvider).AdditionalOptions : new List<PluginAdditionalOption>(),
}); });
} }

View File

@ -51,8 +51,6 @@ namespace Wox.Plugin
{ {
_pluginDirectory = value; _pluginDirectory = value;
ExecuteFilePath = Path.Combine(value, ExecuteFileName); ExecuteFilePath = Path.Combine(value, ExecuteFileName);
IcoPathDark = Path.Combine(value, IcoPathDark);
IcoPathLight = Path.Combine(value, IcoPathLight);
} }
} }

View File

@ -5,6 +5,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -128,7 +129,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
return $"{Name}. {Description}"; 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; private bool _showAdditionalInfoPanel;