diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 9cafad6ea0..36913517f0 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -106,7 +106,6 @@ namespace PowerLauncher InternationalizationManager.Instance.ChangeLanguage(_settings.Language); // main windows needs initialized before theme change because of blur settings - Http.Proxy = _settings.Proxy; RegisterExitEvents(); @@ -203,7 +202,6 @@ namespace PowerLauncher // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Dispose(disposing: false); // } - public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method diff --git a/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs b/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs index c0a5837c09..b1b32f411c 100644 --- a/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs +++ b/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs @@ -34,6 +34,7 @@ namespace PowerLauncher.Helper { // handle ui thread exceptions Report(e?.Exception); + // prevent application exist, so the user can copy prompted error info e.Handled = true; } diff --git a/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs b/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs index 210c53993a..b24e1b4bed 100644 --- a/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs +++ b/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs @@ -17,21 +17,25 @@ namespace PowerLauncher.Helper { state.ShiftPressed = true; } + if ((Keyboard.GetKeyStates(Key.LWin) & KeyStates.Down) > 0 || (Keyboard.GetKeyStates(Key.RWin) & KeyStates.Down) > 0) { state.WinPressed = true; } + if ((Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) > 0 || (Keyboard.GetKeyStates(Key.RightCtrl) & KeyStates.Down) > 0) { state.CtrlPressed = true; } + if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 || (Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0) { state.AltPressed = true; } + return state; } } diff --git a/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs b/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs index 86a8bfef3d..83a80f1385 100644 --- a/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs +++ b/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs @@ -44,6 +44,5 @@ namespace PowerLauncher.Helper { CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } - } } diff --git a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs index 937d9e704f..52f12b3990 100644 --- a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs +++ b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs @@ -188,6 +188,7 @@ namespace PowerLauncher.Helper { throw new Win32Exception(); } + var result = new string[numArgs]; for (int i = 0; i < numArgs; i++) @@ -201,11 +202,11 @@ namespace PowerLauncher.Helper finally { IntPtr p = _LocalFree(argv); + // Otherwise LocalFree failed. // Assert.AreEqual(IntPtr.Zero, p); } } - } public interface ISingleInstanceApp @@ -359,6 +360,7 @@ namespace PowerLauncher.Helper // Do an asynchronous call to ActivateFirstInstance function Application.Current.Dispatcher.Invoke(ActivateFirstInstance); } + // Disconnect client pipeServer.Disconnect(); } diff --git a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs index 94bbacf607..cecce02573 100644 --- a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs +++ b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs @@ -186,6 +186,7 @@ namespace PowerLauncher.Helper matrix = src.CompositionTarget.TransformFromDevice; } } + return new Point((int)(matrix.M11 * unitX), (int)(matrix.M22 * unitY)); } diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index aacd6d3476..aee1c9e398 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -40,7 +40,6 @@ namespace PowerLauncher _firstDeleteTimer.Elapsed += CheckForFirstDelete; _firstDeleteTimer.Interval = 1000; - } private void CheckForFirstDelete(object sender, ElapsedEventArgs e) @@ -53,7 +52,6 @@ namespace PowerLauncher PowerToysTelemetry.Log.WriteEvent(new LauncherFirstDeleteEvent()); } } - } public MainWindow() @@ -251,7 +249,7 @@ namespace PowerLauncher } else if (e.Key == Key.Right) { - if(SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length) + if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length) { _viewModel.SelectNextContextMenuItemCommand.Execute(null); e.Handled = true; @@ -261,7 +259,7 @@ namespace PowerLauncher { if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length) { - if(_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected()) + if (_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected()) { _viewModel.SelectPreviousContextMenuItemCommand.Execute(null); e.Handled = true; @@ -334,6 +332,7 @@ namespace PowerLauncher { SearchBox.AutoCompleteTextBlock.Text = string.Empty; } + _viewModel.QueryText = text; _viewModel.Query(); } @@ -356,8 +355,8 @@ namespace PowerLauncher { _firstDeleteTimer.Start(); } - // (this.FindResource("IntroStoryboard") as Storyboard).Begin(); + // (this.FindResource("IntroStoryboard") as Storyboard).Begin(); SearchBox.QueryTextBox.Focus(); Keyboard.Focus(SearchBox.QueryTextBox); @@ -429,7 +428,6 @@ namespace PowerLauncher // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Dispose(disposing: false); // } - public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method diff --git a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs b/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs index bf778bcfa0..5adb0297af 100644 --- a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs @@ -25,10 +25,11 @@ namespace PowerLauncher { InitializeComponent(); BitmapImage image = GetImageFromPath(ImageLoader.ErrorIconPath); - if(image != null) + if (image != null) { this.Icon = image; } + ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); SetException(exception); } diff --git a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs index 32c76708d4..5b4220e46c 100644 --- a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs +++ b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs @@ -26,6 +26,7 @@ namespace PowerLauncher public SettingsWatcher(Settings settings) { _settings = settings; + // Set up watcher _watcher = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); @@ -38,7 +39,7 @@ namespace PowerLauncher Monitor.Enter(_watcherSyncObject); var retry = true; var retryCount = 0; - while(retry) + while (retry) { try { @@ -90,6 +91,7 @@ namespace PowerLauncher retry = false; } + // the settings application can hold a lock on the settings.json file which will result in a IOException. // This should be changed to properly synch with the settings app instead of retrying. catch (IOException e) @@ -98,10 +100,12 @@ namespace PowerLauncher { retry = false; } + Thread.Sleep(1000); Debug.WriteLine(e.Message); } } + Monitor.Exit(_watcherSyncObject); } @@ -111,6 +115,5 @@ namespace PowerLauncher HotkeyModel model = new HotkeyModel(hotkey.Alt, hotkey.Shift, hotkey.Win, hotkey.Ctrl, key); return model.ToString(); } - } } diff --git a/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs b/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs index 0b61499456..72c5af98bc 100644 --- a/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs +++ b/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs @@ -27,6 +27,7 @@ namespace PowerLauncher.Storage years += 1; return $"about {years} {(years == 1 ? "year" : "years")} ago"; } + if (span.Days > 30) { int months = (span.Days / 30); @@ -34,6 +35,7 @@ namespace PowerLauncher.Storage months += 1; return $"about {months} {(months == 1 ? "month" : "months")} ago"; } + if (span.Days > 0) return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago"; if (span.Hours > 0) diff --git a/src/modules/launcher/PowerLauncher/Storage/TopMostRecord.cs b/src/modules/launcher/PowerLauncher/Storage/TopMostRecord.cs index 017c964090..9989cb027e 100644 --- a/src/modules/launcher/PowerLauncher/Storage/TopMostRecord.cs +++ b/src/modules/launcher/PowerLauncher/Storage/TopMostRecord.cs @@ -43,7 +43,6 @@ namespace PowerLauncher.Storage SubTitle = result.SubTitle }; records[result.OriginQuery.RawQuery] = record; - } public void Load(Dictionary dictionary) diff --git a/src/modules/launcher/PowerLauncher/Storage/UserSelectedRecord.cs b/src/modules/launcher/PowerLauncher/Storage/UserSelectedRecord.cs index 889b303260..daed2e9b96 100644 --- a/src/modules/launcher/PowerLauncher/Storage/UserSelectedRecord.cs +++ b/src/modules/launcher/PowerLauncher/Storage/UserSelectedRecord.cs @@ -43,6 +43,7 @@ namespace PowerLauncher.Storage { return value; } + return 0; } } diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs index 93dbe28e1d..85e55c6cd8 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs @@ -52,7 +52,6 @@ namespace PowerLauncher.ViewModel PluginName = PluginName, Trigger = triggerType.ToString(), ActionName = Title - }; PowerToysTelemetry.Log.WriteEvent(eventData); } diff --git a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs index 448aa75244..1b2f70f3e8 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs @@ -260,6 +260,7 @@ namespace PowerLauncher.ViewModel if (!string.IsNullOrEmpty(QueryText)) { ChangeQueryText(string.Empty, true); + // Push Event to UI SystemQuery has changed OnPropertyChanged(nameof(SystemQueryText)); } @@ -337,6 +338,7 @@ namespace PowerLauncher.ViewModel QueryText = string.Empty; } } + _selectedResults.Visibility = Visibility.Visible; } } @@ -360,7 +362,6 @@ namespace PowerLauncher.ViewModel { PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent()); } - } } @@ -535,7 +536,6 @@ namespace PowerLauncher.ViewModel QueryLength = query.RawQuery.Length }; PowerToysTelemetry.Log.WriteEvent(queryEvent); - }, currentCancellationToken); } } @@ -660,6 +660,7 @@ namespace PowerLauncher.ViewModel { StartHotkeyTimer(); } + if (_settings.LastQueryMode == LastQueryMode.Empty) { ChangeQueryText(string.Empty); @@ -772,7 +773,9 @@ namespace PowerLauncher.ViewModel { var _ = PluginManager.QueryForPlugin(plugin, query); } - }; + } + +; } public void HandleContextMenu(Key AcceleratorKey, ModifierKeys AcceleratorModifiers) @@ -819,6 +822,7 @@ namespace PowerLauncher.ViewModel return query + input.Substring(query.Length); } } + return input; } @@ -849,6 +853,7 @@ namespace PowerLauncher.ViewModel { _hotkeyManager?.UnregisterHotkey(_hotkeyHandle); } + _hotkeyManager?.Dispose(); _updateSource?.Dispose(); _disposed = true; diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs index 23cdfbc279..29cafec614 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs @@ -20,7 +20,7 @@ namespace PowerLauncher.ViewModel { Selection, Hover - }; + } public ObservableCollection ContextMenuItems { get; } = new ObservableCollection(); diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs index 5cd32717ec..578e5cda84 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs @@ -23,8 +23,8 @@ namespace PowerLauncher.ViewModel private readonly object _collectionLock = new object(); private readonly Settings _settings; - // private int MaxResults => _settings?.MaxResultsToShow ?? 6; + // private int MaxResults => _settings?.MaxResultsToShow ?? 6; public ResultsViewModel() { Results = new ResultCollection(); @@ -105,6 +105,7 @@ namespace PowerLauncher.ViewModel break; } } + return index; } @@ -189,9 +190,9 @@ namespace PowerLauncher.ViewModel public void SelectNextContextMenuItem() { - if(SelectedItem != null) + if (SelectedItem != null) { - if(!SelectedItem.SelectNextContextButton()) + if (!SelectedItem.SelectNextContextButton()) { SelectedItem.SelectLastContextButton(); } @@ -229,7 +230,7 @@ namespace PowerLauncher.ViewModel } List newResults = new List(newRawResults.Count); - foreach(Result r in newRawResults) + foreach (Result r in newRawResults) { newResults.Add(new ResultViewModel(r)); ct.ThrowIfCancellationRequested();