diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 5eb6d6e335ab..49ebf8b5215e 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1067,6 +1067,7 @@ KBDLLHOOKSTRUCT kbm KERNELBASE KEYBDINPUT +keybindings keyboardeventhandlers keyboardmanager keyboardmanagercommon diff --git a/PowerToys.sln b/PowerToys.sln index 2688862f2769..4d0113baa7ad 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -370,7 +370,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-PdfThumbnailProvi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plugin.WindowsTerminal", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.WindowsTerminal\Microsoft.PowerToys.Run.Plugin.WindowsTerminal.csproj", "{A2D583F0-B70C-4462-B1F0-8E81AFB7BA85}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests\Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj", "{4ED320BC-BA04-4D42-8D15-CBE62151F08B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests\Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj", "{4ED320BC-BA04-4D42-8D15-CBE62151F08B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -610,9 +610,7 @@ Global {47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x86.ActiveCfg = Release|x64 {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x64.ActiveCfg = Debug|x64 {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x64.Build.0 = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x86.ActiveCfg = Debug|Win32 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x86.Build.0 = Debug|Win32 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x86.Deploy.0 = Debug|Win32 + {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x86.ActiveCfg = Debug|x64 {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x64.ActiveCfg = Release|x64 {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x64.Build.0 = Release|x64 {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.ActiveCfg = Release|Win32 @@ -976,12 +974,11 @@ Global {A2D583F0-B70C-4462-B1F0-8E81AFB7BA85}.Release|x64.ActiveCfg = Release|x64 {A2D583F0-B70C-4462-B1F0-8E81AFB7BA85}.Release|x64.Build.0 = Release|x64 {A2D583F0-B70C-4462-B1F0-8E81AFB7BA85}.Release|x86.ActiveCfg = Release|x64 - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x64.ActiveCfg = Debug|Any CPU - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x64.Build.0 = Debug|Any CPU - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x86.ActiveCfg = Debug|Any CPU - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x86.Build.0 = Debug|Any CPU - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x64.ActiveCfg = Release|Any CPU - {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x64.Build.0 = Release|Any CPU + {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x64.ActiveCfg = Debug|x64 + {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x64.Build.0 = Debug|x64 + {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Debug|x86.ActiveCfg = Debug|x64 + {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x64.ActiveCfg = Release|x64 + {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x64.Build.0 = Release|x64 {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x86.ActiveCfg = Release|Any CPU {4ED320BC-BA04-4D42-8D15-CBE62151F08B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj index 9911c503b9e1..8b0f150129cf 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests.csproj @@ -2,6 +2,7 @@ netcoreapp3.1 + x64 true false diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/TerminalHelperTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/TerminalHelperTests.cs index f745fd2542c4..f1badf08b77f 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/TerminalHelperTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal.UnitTests/TerminalHelperTests.cs @@ -25,7 +25,7 @@ public void ArgumentsTest(string profile, bool openNewTab, string expectedArgume [TestMethod] public void ParseSettingsTest() { - var terminal = new TerminalPackage(string.Empty, new Version(), string.Empty, string.Empty); + var terminal = new TerminalPackage(string.Empty, new Version(), string.Empty, string.Empty, string.Empty); var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); var settings = File.ReadAllText(settingsPath); @@ -48,7 +48,7 @@ public void ParseSettingsTest() public void ParseProfilesTest(string json, string identifier, string name, bool hidden) { var profileElement = JsonDocument.Parse(json).RootElement; - var terminal = new TerminalPackage(string.Empty, new Version(), string.Empty, string.Empty); + var terminal = new TerminalPackage(string.Empty, new Version(), string.Empty, string.Empty, string.Empty); var profile = TerminalHelper.ParseProfile(terminal, profileElement); var expectedIdentifier = identifier != null ? new Guid(identifier) : null as Guid?; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Helpers/TerminalQuery.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Helpers/TerminalQuery.cs index 04bcb252e3dc..5b567f8d216c 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Helpers/TerminalQuery.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Helpers/TerminalQuery.cs @@ -34,7 +34,7 @@ public TerminalQuery() var aumid = p.GetAppListEntries().Single().AppUserModelId; var version = new Version(p.Id.Version.Major, p.Id.Version.Minor, p.Id.Version.Build, p.Id.Version.Revision); var settingsPath = Path.Combine(localAppDataPath, "Packages", p.Id.FamilyName, "LocalState", "settings.json"); - return new TerminalPackage(aumid, version, p.DisplayName, settingsPath); + return new TerminalPackage(aumid, version, p.DisplayName, settingsPath, p.Logo.LocalPath); }); } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Main.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Main.cs index 279e7f460053..aabc4a2b0a0b 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Main.cs @@ -23,7 +23,6 @@ public class Main : IPlugin, IContextMenu, IPluginI18n, ISettingProvider private const string ShowHiddenProfiles = nameof(ShowHiddenProfiles); private readonly ITerminalQuery _terminalQuery = new TerminalQuery(); private PluginInitContext _context; - private string _icoPath; private bool _openNewTab; private bool _showHiddenProfiles; @@ -51,8 +50,6 @@ public class Main : IPlugin, IContextMenu, IPluginI18n, ISettingProvider public void Init(PluginInitContext context) { _context = context; - _context.API.ThemeChanged += OnThemeChanged; - UpdateIconPath(_context.API.GetCurrentTheme()); } public List Query(Query query) @@ -76,7 +73,7 @@ public List Query(Query query) { Title = profile.Name, SubTitle = profile.Terminal.DisplayName, - IcoPath = _icoPath, + Icon = profile.Terminal.Logo, Action = _ => { Launch(profile.Terminal.AppUserModelId, profile.Name); @@ -186,22 +183,5 @@ public void UpdateSettings(PowerLauncherPluginSettings settings) _openNewTab = openNewTab; _showHiddenProfiles = showHiddenProfiles; } - - private void UpdateIconPath(Theme theme) - { - if (theme == Theme.Light || theme == Theme.HighContrastWhite) - { - _icoPath = "Images/WindowsTerminal.light.png"; - } - else - { - _icoPath = "Images/WindowsTerminal.dark.png"; - } - } - - private void OnThemeChanged(Theme currentTheme, Theme newTheme) - { - UpdateIconPath(newTheme); - } } } diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/TerminalPackage.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/TerminalPackage.cs index b2c627441af7..e4e4f7ecfe60 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/TerminalPackage.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/TerminalPackage.cs @@ -3,6 +3,10 @@ // See the LICENSE file in the project root for more information. using System; +using System.IO; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Wox.Infrastructure.Image; namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal { @@ -16,12 +20,40 @@ public class TerminalPackage public string SettingsPath { get; } - public TerminalPackage(string appUserModelId, Version version, string displayName, string settingsPath) + public string LogoPath { get; } + + public ImageSource Logo() => ImageFromPath(); + + public TerminalPackage(string appUserModelId, Version version, string displayName, string settingsPath, string logoPath) { AppUserModelId = appUserModelId; Version = version; DisplayName = displayName; SettingsPath = settingsPath; + LogoPath = logoPath + "fds"; + } + + private BitmapImage ImageFromPath() + { + if (File.Exists(LogoPath)) + { + var memoryStream = new MemoryStream(); + using (var fileStream = File.OpenRead(LogoPath)) + { + fileStream.CopyTo(memoryStream); + memoryStream.Position = 0; + + var image = new BitmapImage(); + image.BeginInit(); + image.StreamSource = memoryStream; + image.EndInit(); + return image; + } + } + else + { + return new BitmapImage(new Uri(ImageLoader.ErrorIconPath)); + } } } }