From c505875fef8cee34fffe97bc2571dd67dec84389 Mon Sep 17 00:00:00 2001 From: Tomas Raies Date: Mon, 27 Apr 2020 22:05:20 -0700 Subject: [PATCH] Settings + PowerLauncher integration * Fix project references * Fix MaxResultsToShow * Fix Alt + Space display * Fix settings defaults --- PowerToys.sln | 35 ++- installer/PowerToysSetup/Product.wxs | 228 +++++++++--------- .../EnabledModules.cs | 2 +- .../HotkeySettings.cs | 4 +- .../PowerLauncherSettings.cs | 2 +- .../ViewModels/PowerLauncherViewModel.cs | 24 +- .../PowerLauncherViewModelTest.cs | 11 - .../Microsoft.Plugin.Indexer.csproj | 1 + .../Plugins/Wox.Plugin.Folder/Main.cs | 6 + .../Wox.Plugin.Folder.csproj | 1 + .../launcher/PowerLauncher/MainWindow.xaml.cs | 6 +- .../launcher/PowerLauncher/SettingsWatcher.cs | 7 +- .../UserSettings/Settings.cs | 18 +- .../Wox/ViewModel/ResultsViewModel.cs | 98 ++++---- 14 files changed, 244 insertions(+), 199 deletions(-) diff --git a/PowerToys.sln b/PowerToys.sln index 12a8e22aad..998382a7ae 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -20,6 +20,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "src\runner\runner {E364F67B-BB12-4E91-B639-355866EBCD8B} = {E364F67B-BB12-4E91-B639-355866EBCD8B} {DA425894-6E13-404F-8DCB-78584EC0557A} = {DA425894-6E13-404F-8DCB-78584EC0557A} {2BE46397-4DFA-414C-9BD4-41E4BBF8CB34} = {2BE46397-4DFA-414C-9BD4-41E4BBF8CB34} + {A7D5099E-F0FD-4BF3-8522-5A682759F915} = {A7D5099E-F0FD-4BF3-8522-5A682759F915} {0B43679E-EDFA-4DA0-AD30-F4628B308B1B} = {0B43679E-EDFA-4DA0-AD30-F4628B308B1B} {B25AC7A5-FB9F-4789-B392-D5C85E948670} = {B25AC7A5-FB9F-4789-B392-D5C85E948670} {E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F} = {E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F} @@ -30,7 +31,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "src\runner\runner {F9C68EDF-AC74-4B77-9AF1-005D9C9F6A99} = {F9C68EDF-AC74-4B77-9AF1-005D9C9F6A99} {07C389E3-6BC8-41CF-923E-307B1265FA2D} = {07C389E3-6BC8-41CF-923E-307B1265FA2D} {89F34AF7-1C34-4A72-AA6E-534BCF972BD9} = {89F34AF7-1C34-4A72-AA6E-534BCF972BD9} - {A7D5099E-F0FD-4BF3-8522-5A682759F915} = {A7D5099E-F0FD-4BF3-8522-5A682759F915} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "src\common\common.vcxproj", "{74485049-C722-400F-ABE5-86AC52D929B3}" @@ -171,9 +171,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wox", "src\modules\launcher ProjectSection(ProjectDependencies) = postProject {FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4} {59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E} - {74F1B9ED-F59C-4FE7-B473-7B453E30837E} = {74F1B9ED-F59C-4FE7-B473-7B453E30837E} {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} {F8B870EB-D5F5-45BA-9CF7-A5C459818820} = {F8B870EB-D5F5-45BA-9CF7-A5C459818820} + {74F1B9ED-F59C-4FE7-B473-7B453E30837E} = {74F1B9ED-F59C-4FE7-B473-7B453E30837E} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wox.Core", "src\modules\launcher\Wox.Core\Wox.Core.csproj", "{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}" @@ -252,6 +253,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common-md-flag", "src\commo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "interop-tests", "src\common\interop-tests\interop-tests.csproj", "{437AD818-3F1F-4CA5-A79B-25233A157026}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wox.Plugin.Folder", "src\modules\launcher\Plugins\Wox.Plugin.Folder\Wox.Plugin.Folder.csproj", "{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -817,6 +820,13 @@ Global {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|ARM64.ActiveCfg = Release|Win32 {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|x64 + {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.Build.0 = Release|x64 + {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.Deploy.0 = Release|x64 + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM.Build.0 = Debug|Any CPU + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM64.Build.0 = Debug|Any CPU {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.ActiveCfg = Debug|x64 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.Build.0 = Debug|x64 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -827,8 +837,8 @@ Global {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|ARM64.Build.0 = Release|Any CPU {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.ActiveCfg = Release|x64 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|x64 - {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x86.ActiveCfg = Release|Any CPU - {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x86.Build.0 = Release|Any CPU + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x86.ActiveCfg = Release|x64 + {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x86.Build.0 = Release|x64 {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|ARM.ActiveCfg = Debug|ARM {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|ARM.Build.0 = Debug|ARM {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|ARM.Deploy.0 = Debug|ARM @@ -848,9 +858,9 @@ Global {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|ARM64.Deploy.0 = Release|ARM64 {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.ActiveCfg = Release|x64 {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.Build.0 = Release|x64 - {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.ActiveCfg = Release|x86 - {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.Build.0 = Release|x86 - {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.Deploy.0 = Release|x86 + {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.ActiveCfg = Release|x64 + {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.Build.0 = Release|x64 + {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x86.Deploy.0 = Release|x64 {F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM.ActiveCfg = Debug|x64 {F055103B-F80B-4D0C-BF48-057C55620033}.Debug|ARM64.ActiveCfg = Debug|x64 {F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.ActiveCfg = Debug|x64 @@ -881,6 +891,16 @@ Global {437AD818-3F1F-4CA5-A79B-25233A157026}.Release|x64.ActiveCfg = Release|x64 {437AD818-3F1F-4CA5-A79B-25233A157026}.Release|x64.Build.0 = Release|x64 {437AD818-3F1F-4CA5-A79B-25233A157026}.Release|x86.ActiveCfg = Release|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|ARM.ActiveCfg = Debug|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|ARM64.ActiveCfg = Debug|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|x64.ActiveCfg = Debug|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|x64.Build.0 = Debug|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Debug|x86.ActiveCfg = Debug|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|ARM.ActiveCfg = Release|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|ARM64.ActiveCfg = Release|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x64.ActiveCfg = Release|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x64.Build.0 = Release|x64 + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x86.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -950,6 +970,7 @@ Global {F055103B-F80B-4D0C-BF48-057C55620033} = {1AFB6476-670D-4E80-A464-657E01DFF482} {985B3F2F-CEED-4C0A-A249-69257E719145} = {1AFB6476-670D-4E80-A464-657E01DFF482} {437AD818-3F1F-4CA5-A79B-25233A157026} = {1AFB6476-670D-4E80-A464-657E01DFF482} + {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index cf8ae43973..0a2397117a 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -32,7 +32,7 @@ = 17134)]]> - + @@ -328,48 +328,48 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + @@ -381,33 +381,33 @@ - - - - + + + + - + - + - + - - - - + + + + - - + + @@ -476,15 +476,15 @@ - + - + - + - - - + + + @@ -550,73 +550,77 @@ - + - - + + - + - - + + - + - + - - + + - + - - + + - + - - + + + - + - + - + - + - + - + - + - + - + - + @@ -705,7 +709,7 @@ - + @@ -715,43 +719,45 @@ - + + + - + - + - + - + - + - + - + - + - + @@ -763,25 +769,25 @@ - + - + - + - + @@ -794,25 +800,25 @@ - + - + - + - + @@ -825,25 +831,25 @@ - + - + - + - - + + @@ -855,46 +861,46 @@ - + - + - + - + - + - + - + - + - + diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs index ba9164028e..2333ba38d1 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs @@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib this.FileExplorerPreview = false; this.PowerRename = false; this.ShortcutGuide = false; - this.PowerLauncher = false; + this.PowerLauncher = true; } [JsonPropertyName("FancyZones")] diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs index eaf45f6feb..bfd4bb6dcc 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.PowerToys.Settings.UI.Lib.Utilities; using System.Text; using System.Text.Json.Serialization; @@ -61,7 +62,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib output.Append("Shift + "); } - output.Append(Key); + var localKey = Helper.GetKeyName((uint) Code); + output.Append(localKey); return output.ToString(); } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerLauncherSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerLauncherSettings.cs index 6934f79ee7..fc841e928b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerLauncherSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerLauncherSettings.cs @@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { properties = new PowerLauncherProperties(); version = "1"; - name = "_unset_"; + name = POWERTOYNAME; } public virtual void Save() diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs index 67a28781de..fe218ef302 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs @@ -20,7 +20,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private readonly SendCallback callback; public PowerLauncherViewModel() - { + { + callback = (PowerLauncherSettings settings) => + { + // Propagate changes to Power Launcher through IPC + ShellPage.DefaultSndMSGCallback( + string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.POWERTOYNAME, JsonSerializer.Serialize(settings))); + }; if (SettingsUtils.SettingsExists(PowerLauncherSettings.POWERTOYNAME)) { settings = SettingsUtils.GetSettings(PowerLauncherSettings.POWERTOYNAME); @@ -28,24 +34,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels else { settings = new PowerLauncherSettings(); + settings.properties.open_powerlauncher.Alt = true; + settings.properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space; + settings.properties.maximum_number_of_results = 4; + callback(settings); } if (SettingsUtils.SettingsExists()) { - generalSettings = SettingsUtils.GetSettings(string.Empty); + generalSettings = SettingsUtils.GetSettings(); } else { generalSettings = new GeneralSettings(); - SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); } - callback = (PowerLauncherSettings settings) => - { - // Propagate changes to Power Launcher through IPC - var propertiesJson = JsonSerializer.Serialize(settings.properties); - ShellPage.DefaultSndMSGCallback( - string.Format("{{ \"{0}\": {1} }}", PowerLauncherSettings.POWERTOYNAME, JsonSerializer.Serialize(settings.properties))); - }; } public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback) @@ -59,7 +61,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels // Notify UI of property change OnPropertyChanged(propertyName); - settings.Save(); callback(settings); } @@ -76,7 +77,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels { generalSettings.Enabled.PowerLauncher = value; OnPropertyChanged(nameof(EnablePowerLauncher)); - SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings); ShellPage.DefaultSndMSGCallback(outgoing.ToString()); } diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/PowerLauncherViewModelTest.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/PowerLauncherViewModelTest.cs index 4a7c46330d..c6e7ec9f45 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/PowerLauncherViewModelTest.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/PowerLauncherViewModelTest.cs @@ -47,17 +47,6 @@ namespace ViewModelTests ); } - [TestMethod] - public void IsEnabled_ShouldEnableModule() - { - viewModel.EnablePowerLauncher = true; - - Assert.AreEqual(sendCallbackMock.TimesSent, 1); - Assert.AreEqual(mockSettings.TimesSaved, 1); - - Assert.IsTrue(mockSettings.properties.enable_powerlauncher == true); - } - [TestMethod] public void SearchPreference_ShouldUpdatePreferences() { diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj index af55922653..ceaf8cc904 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj @@ -43,6 +43,7 @@ + diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Folder/Main.cs b/src/modules/launcher/Plugins/Wox.Plugin.Folder/Main.cs index 9734d356a2..3b0d010e3f 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Folder/Main.cs +++ b/src/modules/launcher/Plugins/Wox.Plugin.Folder/Main.cs @@ -1,3 +1,4 @@ +using Microsoft.PowerToys.Settings.UI.Lib; using System; using System.Collections.Generic; using System.Diagnostics; @@ -283,5 +284,10 @@ namespace Wox.Plugin.Folder { return _contextMenuLoader.LoadContextMenus(selectedResult); } + + public void UpdateSettings(PowerLauncherSettings settings) + { + + } } } \ No newline at end of file diff --git a/src/modules/launcher/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj b/src/modules/launcher/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj index 095b4e5fa4..b015529232 100644 --- a/src/modules/launcher/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj +++ b/src/modules/launcher/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj @@ -93,6 +93,7 @@ + diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index f264514e12..4e2b94d670 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -35,9 +35,7 @@ namespace PowerLauncher private Settings _settings; private MainViewModel _viewModel; private bool _isTextSetProgramatically; - const int ROW_COUNT = 4; const int ROW_HEIGHT = 75; - const int MAX_LIST_HEIGHT = 300; #endregion public MainWindow(Settings settings, MainViewModel mainVM) @@ -304,8 +302,8 @@ namespace PowerLauncher private void SuggestionList_UpdateListSize(object sender, ContainerContentChangingEventArgs e) { int count = _viewModel?.Results?.Results.Count ?? 0; - int maxHeight = count < ROW_COUNT ? count * ROW_HEIGHT : MAX_LIST_HEIGHT; - _resultList.Height = maxHeight; + int displayCount = Math.Min(count, _settings.MaxResultsToShow); + _resultList.Height = displayCount * ROW_HEIGHT; } private void SuggestionsList_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) diff --git a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs index 57e63292c6..11f1c8a5c5 100644 --- a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs +++ b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs @@ -62,13 +62,10 @@ namespace PowerLauncher shellSettings.UpdateSettings(overloadSettings); } - var indexer = PluginManager.AllPlugins.Find(pp => pp.Metadata.Name == "Windows Indexer Plugin"); - if (indexer != null) + if (_settings.MaxResultsToShow != overloadSettings.properties.maximum_number_of_results) { - var indexerSettings = indexer.Plugin as ISettingProvider; - indexerSettings.UpdateSettings(overloadSettings); + _settings.MaxResultsToShow = overloadSettings.properties.maximum_number_of_results; } - } catch (Exception e) { diff --git a/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs b/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs index c6c0f14385..63f1a6aa7b 100644 --- a/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs +++ b/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs @@ -82,7 +82,23 @@ namespace Wox.Infrastructure.UserSettings public double WindowLeft { get; set; } public double WindowTop { get; set; } - public int MaxResultsToShow { get; set; } = 6; + + private int _maxResultsToShow = 6; + public int MaxResultsToShow + { + get + { + return _maxResultsToShow; + } + set + { + if (_maxResultsToShow != value) + { + _maxResultsToShow = value; + OnPropertyChanged(); + } + } + } public int ActivateTimes { get; set; } // Order defaults to 0 or -1, so 1 will let this property appear last diff --git a/src/modules/launcher/Wox/ViewModel/ResultsViewModel.cs b/src/modules/launcher/Wox/ViewModel/ResultsViewModel.cs index 31ae50c545..a45752fb41 100644 --- a/src/modules/launcher/Wox/ViewModel/ResultsViewModel.cs +++ b/src/modules/launcher/Wox/ViewModel/ResultsViewModel.cs @@ -6,7 +6,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; -using System.Windows.Input; +using System.Windows.Input; using Wox.Infrastructure.UserSettings; using Wox.Plugin; @@ -21,7 +21,7 @@ namespace Wox.ViewModel private readonly object _addResultsLock = new object(); private readonly object _collectionLock = new object(); private readonly Settings _settings; - private int MaxResults => _settings?.MaxResultsToShow ?? 6; + // private int MaxResults => _settings?.MaxResultsToShow ?? 6; public ResultsViewModel() { @@ -35,7 +35,10 @@ namespace Wox.ViewModel { if (e.PropertyName == nameof(_settings.MaxResultsToShow)) { - OnPropertyChanged(nameof(MaxHeight)); + Application.Current.Dispatcher.Invoke(() => + { + OnPropertyChanged(nameof(MaxHeight)); + }); } }; } @@ -44,31 +47,36 @@ namespace Wox.ViewModel #region Properties - public int MaxHeight => MaxResults * 50; - + public int MaxHeight + { + get + { + return _settings.MaxResultsToShow * 75; + } + } public int SelectedIndex { get; set; } private ResultViewModel _selectedItem; - public ResultViewModel SelectedItem + public ResultViewModel SelectedItem { get { return _selectedItem; } - set - { - //value can be null when selecting an item in a virtualized list - if (value != null) - { - if (_selectedItem != null) - { - _selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection); - } - - _selectedItem = value; - _selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection); - } - else - { - _selectedItem = value; - } + set + { + //value can be null when selecting an item in a virtualized list + if (value != null) + { + if (_selectedItem != null) + { + _selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection); + } + + _selectedItem = value; + _selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection); + } + else + { + _selectedItem = value; + } } } @@ -127,12 +135,12 @@ namespace Wox.ViewModel public void SelectNextPage() { - SelectedIndex = NewIndex(SelectedIndex + MaxResults); + SelectedIndex = NewIndex(SelectedIndex + _settings.MaxResultsToShow); } public void SelectPrevPage() { - SelectedIndex = NewIndex(SelectedIndex - MaxResults); + SelectedIndex = NewIndex(SelectedIndex - _settings.MaxResultsToShow); } public void SelectFirstResult() @@ -153,26 +161,26 @@ namespace Wox.ViewModel public void RemoveResultsFor(PluginMetadata metadata) { Results.RemoveAll(r => r.Result.PluginID == metadata.ID); - } - - public void SelectNextTabItem() - { - if(!SelectedItem.SelectNextContextButton()) - { - SelectNextResult(); - } - } - - public void SelectPrevTabItem() - { - if (!SelectedItem.SelectPrevContextButton()) - { - //Tabbing backwards should highlight the last item of the previous row - SelectPrevResult(); - SelectedItem.SelectLastContextButton(); - } - } - + } + + public void SelectNextTabItem() + { + if(!SelectedItem.SelectNextContextButton()) + { + SelectNextResult(); + } + } + + public void SelectPrevTabItem() + { + if (!SelectedItem.SelectPrevContextButton()) + { + //Tabbing backwards should highlight the last item of the previous row + SelectPrevResult(); + SelectedItem.SelectLastContextButton(); + } + } + /// /// To avoid deadlock, this method should not called from main thread ///