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();
}
private static string GetIcon(PluginMetadata metadata, string iconPath)
{
var pluginDirectory = Path.GetFileName(metadata.PluginDirectory);
return Path.Combine(pluginDirectory, iconPath);
}
private static IEnumerable<PowerLauncherPluginSettings> 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<PluginAdditionalOption>(),
});
}

View file

@ -51,8 +51,6 @@ namespace Wox.Plugin
{
_pluginDirectory = value;
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.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;