diff --git a/src/CurvaLauncher.Common/IAsyncQueryResult.cs b/src/CurvaLauncher.Common/IAsyncActionQueryResult.cs similarity index 63% rename from src/CurvaLauncher.Common/IAsyncQueryResult.cs rename to src/CurvaLauncher.Common/IAsyncActionQueryResult.cs index 0edb680..0676a60 100644 --- a/src/CurvaLauncher.Common/IAsyncQueryResult.cs +++ b/src/CurvaLauncher.Common/IAsyncActionQueryResult.cs @@ -1,6 +1,6 @@ namespace CurvaLauncher; -public interface IAsyncQueryResult : IQueryResult +public interface IAsyncActionQueryResult : IQueryResult { public Task InvokeAsync(CancellationToken cancellationToken); } diff --git a/src/CurvaLauncher.Common/IAsyncDocumentQueryResult.cs b/src/CurvaLauncher.Common/IAsyncDocumentQueryResult.cs new file mode 100644 index 0000000..9abb664 --- /dev/null +++ b/src/CurvaLauncher.Common/IAsyncDocumentQueryResult.cs @@ -0,0 +1,8 @@ +using System.Windows.Documents; + +namespace CurvaLauncher; + +public interface IAsyncDocumentQueryResult : IQueryResult +{ + public Task GenerateDocumentAsync(CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/src/CurvaLauncher.Common/ISyncQueryResult.cs b/src/CurvaLauncher.Common/ISyncActionQueryResult.cs similarity index 51% rename from src/CurvaLauncher.Common/ISyncQueryResult.cs rename to src/CurvaLauncher.Common/ISyncActionQueryResult.cs index 581f3a9..7df4ad8 100644 --- a/src/CurvaLauncher.Common/ISyncQueryResult.cs +++ b/src/CurvaLauncher.Common/ISyncActionQueryResult.cs @@ -1,6 +1,6 @@ namespace CurvaLauncher; -public interface ISyncQueryResult : IQueryResult +public interface ISyncActionQueryResult : IQueryResult { public void Invoke(); } diff --git a/src/CurvaLauncher.Common/ISyncDocumentQueryResult.cs b/src/CurvaLauncher.Common/ISyncDocumentQueryResult.cs new file mode 100644 index 0000000..dad23fb --- /dev/null +++ b/src/CurvaLauncher.Common/ISyncDocumentQueryResult.cs @@ -0,0 +1,8 @@ +using System.Windows.Documents; + +namespace CurvaLauncher; + +public interface ISyncDocumentQueryResult : IQueryResult +{ + public FlowDocument GenerateDocument(); +} \ No newline at end of file diff --git a/src/CurvaLauncher/CurvaLauncher.csproj b/src/CurvaLauncher/CurvaLauncher.csproj index 55d8279..cb1ae56 100644 --- a/src/CurvaLauncher/CurvaLauncher.csproj +++ b/src/CurvaLauncher/CurvaLauncher.csproj @@ -12,7 +12,7 @@ app.manifest Assets\Icon.ico - 0.6.1-beta + 0.7.1-beta true true @@ -26,7 +26,9 @@ - + + + diff --git a/src/CurvaLauncher/MainWindow.xaml b/src/CurvaLauncher/MainWindow.xaml index 3ed8000..45c9698 100644 --- a/src/CurvaLauncher/MainWindow.xaml +++ b/src/CurvaLauncher/MainWindow.xaml @@ -8,6 +8,7 @@ xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors" xmlns:utils="clr-namespace:CurvaLauncher.Utilities" xmlns:models="clr-namespace:CurvaLauncher.Models" + xmlns:models_imr="clr-namespace:CurvaLauncher.Models.ImmediateResults" xmlns:ws="https://schemas.elecho.dev/wpfsuite" xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" @@ -30,7 +31,7 @@ Deactivated="WindowDeactivated"> - + @@ -41,6 +42,10 @@ + + @@ -52,35 +57,52 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89,8 +111,8 @@ - - + + @@ -104,7 +126,8 @@ - + + - - - - + @@ -171,10 +183,24 @@ + + + + + + + + + + diff --git a/src/CurvaLauncher/MainWindow.xaml.cs b/src/CurvaLauncher/MainWindow.xaml.cs index 2e41ebb..9de56e2 100644 --- a/src/CurvaLauncher/MainWindow.xaml.cs +++ b/src/CurvaLauncher/MainWindow.xaml.cs @@ -1,8 +1,10 @@ using System; using System.Windows; +using System.Windows.Controls; using System.Windows.Input; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using CurvaLauncher.Models; using CurvaLauncher.Services; using CurvaLauncher.ViewModels; using Wpf.Ui.Appearance; @@ -47,6 +49,7 @@ private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs private void WindowActivated(object sender, EventArgs e) { FocusManager.SetFocusedElement(this, QueryBox); + ViewModel.QueryCommand.Execute(null); Focus(); } @@ -55,6 +58,11 @@ private void WindowDeactivated(object sender, EventArgs e) if (AppConfig.KeepLauncherWhenFocusLost) return; + ViewModel.QueryResults.Clear(); + ViewModel.SelectedQueryResult = null; + + resultBox.SelectedItem = null; + App.CloseLauncher(); } @@ -73,7 +81,17 @@ private void QueryBox_PreviewKeyDown(object sender, KeyEventArgs e) [RelayCommand] public void ScrollToSelectedQueryResult() { - resultBox.ScrollIntoView(resultBox.SelectedItem); + if (resultBox.SelectedItem is null || + resultBox.SelectedIndex < 0) + { + return; + } + + try + { + resultBox.ScrollIntoView(resultBox.SelectedItem); + } + catch { } } public void SetQueryText(string text) @@ -82,4 +100,15 @@ public void SetQueryText(string text) QueryBox.SelectionStart = text.Length; QueryBox.SelectionLength = 0; } + + private void ResultBoxItemMouseDown(object sender, MouseButtonEventArgs e) + { + if (sender is not ListBoxItem lbi || + lbi.Content is not QueryResultModel queryResult) + { + return; + } + + ViewModel.InvokeCommand.Execute(queryResult); + } } diff --git a/src/CurvaLauncher/Models/ImmediateResults/DocumentResult.cs b/src/CurvaLauncher/Models/ImmediateResults/DocumentResult.cs new file mode 100644 index 0000000..b20cd49 --- /dev/null +++ b/src/CurvaLauncher/Models/ImmediateResults/DocumentResult.cs @@ -0,0 +1,14 @@ +using System.Windows.Documents; + +namespace CurvaLauncher.Models.ImmediateResults +{ + public class DocumentResult : ImmediateResult + { + public FlowDocument Document { get; } + + public DocumentResult(FlowDocument document) + { + Document = document; + } + } +} diff --git a/src/CurvaLauncher/Models/ImmediateResults/ImmediateResult.cs b/src/CurvaLauncher/Models/ImmediateResults/ImmediateResult.cs new file mode 100644 index 0000000..6d18bd2 --- /dev/null +++ b/src/CurvaLauncher/Models/ImmediateResults/ImmediateResult.cs @@ -0,0 +1,12 @@ +using System; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CurvaLauncher.Models.ImmediateResults +{ + public abstract class ImmediateResult + { + + } +} diff --git a/src/CurvaLauncher/Models/ImmediateResults/SubResultListResult.cs b/src/CurvaLauncher/Models/ImmediateResults/SubResultListResult.cs new file mode 100644 index 0000000..ed23707 --- /dev/null +++ b/src/CurvaLauncher/Models/ImmediateResults/SubResultListResult.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace CurvaLauncher.Models.ImmediateResults +{ + public class SubResultListResult : ImmediateResult + { + public IReadOnlyList Results { get; } + + public SubResultListResult(IReadOnlyList results) + { + Results = results; + } + } +} diff --git a/src/CurvaLauncher/Models/QueryResultModel.cs b/src/CurvaLauncher/Models/QueryResultModel.cs index d4a449a..1d510f9 100644 --- a/src/CurvaLauncher/Models/QueryResultModel.cs +++ b/src/CurvaLauncher/Models/QueryResultModel.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; @@ -7,6 +8,7 @@ using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; using CurvaLauncher.Messages; +using CurvaLauncher.Models.ImmediateResults; using CurvaLauncher.Services; using Microsoft.Extensions.DependencyInjection; @@ -50,14 +52,13 @@ public void SetFallbackIcon(Func iconFactory) } } - [RelayCommand] - public async Task Invoke() + public async Task Invoke(CancellationToken cancellationToken) { App.ServiceProvider .GetRequiredService() .Send(SaveQueryMessage.Instance); - if (_rawQueryResult is ISyncQueryResult syncQueryResult) + if (_rawQueryResult is ISyncActionQueryResult syncQueryResult) { try { @@ -67,8 +68,10 @@ public async Task Invoke() { MessageBox.Show($"{ex.Message}", "CurvaLauncher Result Invoke failed", MessageBoxButton.OK, MessageBoxImage.Error); } + + return null; } - else if (_rawQueryResult is IAsyncQueryResult asyncQueryResult) + else if (_rawQueryResult is IAsyncActionQueryResult asyncQueryResult) { try { @@ -82,9 +85,39 @@ public async Task Invoke() { MessageBox.Show($"{ex.Message}", "CurvaLauncher Result Invoke failed", MessageBoxButton.OK, MessageBoxImage.Error); } + + return null; + } + else if (_rawQueryResult is ISyncDocumentQueryResult syncDocumentQueryResult) + { + try + { + return new DocumentResult(syncDocumentQueryResult.GenerateDocument()); + } + catch (Exception ex) + { + MessageBox.Show($"{ex.Message}", "CurvaLauncher Result Invoke failed", MessageBoxButton.OK, MessageBoxImage.Error); + } + + return null; + } + else if (_rawQueryResult is IAsyncDocumentQueryResult asyncDocumentQueryResult) + { + try + { + var document = await asyncDocumentQueryResult.GenerateDocumentAsync(cancellationToken); + return new DocumentResult(document); + } + catch (Exception ex) + { + MessageBox.Show($"{ex.Message}", "CurvaLauncher Result Invoke failed", MessageBoxButton.OK, MessageBoxImage.Error); + } + + return null; } App.CloseLauncher(); + return null; } public static QueryResultModel Create(CurvaLauncherPluginInstance pluginInstance, IQueryResult queryResult) diff --git a/src/CurvaLauncher/ViewModels/MainViewModel.cs b/src/CurvaLauncher/ViewModels/MainViewModel.cs index 2e624e4..6147bea 100644 --- a/src/CurvaLauncher/ViewModels/MainViewModel.cs +++ b/src/CurvaLauncher/ViewModels/MainViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Input; @@ -8,6 +9,7 @@ using CommunityToolkit.Mvvm.Messaging; using CurvaLauncher.Messages; using CurvaLauncher.Models; +using CurvaLauncher.Models.ImmediateResults; using CurvaLauncher.Services; using CurvaLauncher.Utilities; @@ -18,33 +20,36 @@ public partial class MainViewModel : ObservableObject, IRecipient queryResults = new(); - [ObservableProperty] private QueryResultModel? selectedQueryResult; [ObservableProperty] private int selectedQueryResultIndex = 0; - public bool HasQueryResult => QueryResults.Count > 0; + public ObservableCollection QueryResults { get; } = new(); + public ObservableCollection ImmediateResults { get; } = new(); + + public ImmediateResult? CurrentImmediateResult => ImmediateResults.LastOrDefault(); + + public bool ShowQueryResult => QueryResults.Count > 0 && ImmediateResults.Count == 0; + public bool ShowImmediateResults => ImmediateResults.Count > 0; + + public MainViewModel( + PluginService pluginService, + ConfigService configService, + IMessenger messenger) + { + _pluginService = pluginService; + _configService = configService; + + messenger.Register(this); + } [RelayCommand] public async Task QueryCore(CancellationToken cancellationToken) @@ -54,79 +59,78 @@ public async Task QueryCore(CancellationToken cancellationToken) var dispatcher = Dispatcher.CurrentDispatcher; var queryText = QueryText; - if (!string.IsNullOrWhiteSpace(queryText)) + SortedCollection queryResults = new() { - SortedCollection queryResults = new() - { - SortingRoot = m => m.Weight, - Descending = true, - }; + SortingRoot = m => m.Weight, + Descending = true, + }; - await Task.Run(async () => + await Task.Run(async () => + { + foreach (var pluginInstance in _pluginService.PluginInstances) { - foreach (var pluginInstance in _pluginService.PluginInstances) - { - if (cancellationToken.IsCancellationRequested) - return; - if (!pluginInstance.IsEnabled) - continue; + if (cancellationToken.IsCancellationRequested) + return; + if (!pluginInstance.IsEnabled) + continue; - await pluginInstance.InitTask; + await pluginInstance.InitTask; - try + try + { + await foreach (var result in pluginInstance.QueryAsync(queryText)) { - await foreach (var result in pluginInstance.QueryAsync(queryText)) - { - if (cancellationToken.IsCancellationRequested) - return; + if (cancellationToken.IsCancellationRequested) + return; - var model = QueryResultModel.Create(pluginInstance, result); - queryResults.Add(model); + var model = QueryResultModel.Create(pluginInstance, result); + queryResults.Add(model); - dispatcher.Invoke(() => + dispatcher.Invoke(() => + { + model.SetFallbackIcon(() => pluginInstance.Plugin.Icon); + + for (int i = 0; i < queryResults.Count; i++) { - model.SetFallbackIcon(() => pluginInstance.Plugin.Icon); - - for (int i = 0; i < queryResults.Count; i++) - { - if (QueryResults.Count > i) - QueryResults[i] = queryResults[i]; - else - QueryResults.Add(queryResults[i]); - } - - if (SelectedQueryResult == null) - SelectedQueryResultIndex = 0; - }); - - if (cancellationToken.IsCancellationRequested) - return; - } + if (QueryResults.Count > i) + QueryResults[i] = queryResults[i]; + else + QueryResults.Add(queryResults[i]); + } + + if (SelectedQueryResult == null) + SelectedQueryResultIndex = 0; + }); + + if (cancellationToken.IsCancellationRequested) + return; } - catch - { + } + catch + { - } } - }); + } + }); - if (cancellationToken.IsCancellationRequested) - return; + if (cancellationToken.IsCancellationRequested) + return; - while (QueryResults.Count > queryResults.Count) - QueryResults.RemoveAt(QueryResults.Count - 1); - } - else - { - QueryResults.Clear(); - } + while (QueryResults.Count > queryResults.Count) + QueryResults.RemoveAt(QueryResults.Count - 1); - OnPropertyChanged(nameof(HasQueryResult)); + OnPropertyChanged(nameof(ShowQueryResult)); } [RelayCommand] public void Query() { + ImmediateResults.Clear(); + + OnPropertyChanged(nameof(ShowQueryResult)); + OnPropertyChanged(nameof(ShowImmediateResults)); + OnPropertyChanged(nameof(CurrentImmediateResult)); + if (QueryCoreCommand.IsRunning) QueryCoreCommand.Cancel(); @@ -134,12 +138,27 @@ public void Query() } [RelayCommand] - public async Task InvokeSelected() + public async Task Invoke(QueryResultModel queryResult, CancellationToken cancellationToken) + { + var imResult = await queryResult.Invoke(cancellationToken); + + if (imResult is not null) + { + ImmediateResults.Add(imResult); + + OnPropertyChanged(nameof(ShowQueryResult)); + OnPropertyChanged(nameof(ShowImmediateResults)); + OnPropertyChanged(nameof(CurrentImmediateResult)); + } + } + + [RelayCommand] + public Task InvokeSelected(CancellationToken cancellationToken) { if (SelectedQueryResult == null) - return; + return Task.CompletedTask; - await SelectedQueryResult.InvokeCommand.ExecuteAsync(null); + return InvokeCommand.ExecuteAsync(SelectedQueryResult); } [RelayCommand] @@ -169,6 +188,23 @@ public void SelectPrev() SelectedQueryResultIndex = newIndex; } + [RelayCommand] + public void Escape() + { + if (ImmediateResults.Count == 0) + { + App.CloseLauncher(); + } + else + { + ImmediateResults.RemoveAt(ImmediateResults.Count - 1); + + OnPropertyChanged(nameof(ShowQueryResult)); + OnPropertyChanged(nameof(ShowImmediateResults)); + OnPropertyChanged(nameof(CurrentImmediateResult)); + } + } + void IRecipient.Receive(SaveQueryMessage message) { LastInvokedQueryText = QueryText; diff --git a/src/Plugins/CurvaLauncher.Plugins.Calculator/CalculatorQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Calculator/CalculatorQueryResult.cs index 5ba31b6..2ebca42 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Calculator/CalculatorQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Calculator/CalculatorQueryResult.cs @@ -3,7 +3,7 @@ namespace CurvaLauncher.Plugins.Calculator { - public class CalculatorQueryResult : ISyncQueryResult + public class CalculatorQueryResult : ISyncActionQueryResult { private readonly CurvaLauncherContext _hostContext; diff --git a/src/Plugins/CurvaLauncher.Plugins.Everything/EverythingQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Everything/EverythingQueryResult.cs index 7ef2980..e6e79f8 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Everything/EverythingQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Everything/EverythingQueryResult.cs @@ -2,7 +2,7 @@ namespace CurvaLauncher.Plugins.Everything { - public class EverythingQueryResult : ISyncQueryResult + public class EverythingQueryResult : ISyncActionQueryResult { private readonly EverythingPlugin _plugin; private readonly EverythingSearchClient.Result.Item _searchResult; diff --git a/src/Plugins/CurvaLauncher.Plugins.Hashing/HashingQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Hashing/HashingQueryResult.cs index 9aa16ac..f0e50bb 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Hashing/HashingQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Hashing/HashingQueryResult.cs @@ -6,7 +6,7 @@ namespace CurvaLauncher.Plugins.Hashing; -public class HashingQueryResult : IAsyncQueryResult +public class HashingQueryResult : IAsyncActionQueryResult { private readonly CurvaLauncherContext _hostContext; private readonly IEnumerable> _streamFactories; diff --git a/src/Plugins/CurvaLauncher.Plugins.OpenUrl/OpenUrlQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.OpenUrl/OpenUrlQueryResult.cs index 89a94cd..ae61698 100644 --- a/src/Plugins/CurvaLauncher.Plugins.OpenUrl/OpenUrlQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.OpenUrl/OpenUrlQueryResult.cs @@ -6,7 +6,7 @@ namespace CurvaLauncher.Plugins.OpenUrl { - public class OpenUrlQueryResult : ISyncQueryResult + public class OpenUrlQueryResult : ISyncActionQueryResult { public OpenUrlQueryResult(CurvaLauncherContext context, Uri url) { diff --git a/src/Plugins/CurvaLauncher.Plugins.QuickWebSearch/QuickWebSearchQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.QuickWebSearch/QuickWebSearchQueryResult.cs index 00b62cb..22ae78b 100644 --- a/src/Plugins/CurvaLauncher.Plugins.QuickWebSearch/QuickWebSearchQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.QuickWebSearch/QuickWebSearchQueryResult.cs @@ -3,7 +3,7 @@ namespace CurvaLauncher.Plugins.QuickWebSearch { - public class QuickWebSearchQueryResult : ISyncQueryResult + public class QuickWebSearchQueryResult : ISyncActionQueryResult { private readonly CurvaLauncherContext _context; private readonly ImageSource? _icon; diff --git a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunUwpApplicationQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunUwpApplicationQueryResult.cs index 933e397..441b855 100644 --- a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunUwpApplicationQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunUwpApplicationQueryResult.cs @@ -5,7 +5,7 @@ namespace CurvaLauncher.Plugins.RunApplication; -public class RunUwpApplicationQueryResult : ISyncQueryResult +public class RunUwpApplicationQueryResult : ISyncActionQueryResult { public UwpAppInfo AppInfo { get; } diff --git a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunWin32ApplicationQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunWin32ApplicationQueryResult.cs index 905e73e..731cc0b 100644 --- a/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunWin32ApplicationQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.RunApplication/RunWin32ApplicationQueryResult.cs @@ -7,7 +7,7 @@ namespace CurvaLauncher.Plugins.RunApplication; -public class RunWin32ApplicationQueryResult : IAsyncQueryResult +public class RunWin32ApplicationQueryResult : IAsyncActionQueryResult { private ImageSource? icon; diff --git a/src/Plugins/CurvaLauncher.Plugins.RunProgram/RunProgramQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.RunProgram/RunProgramQueryResult.cs index bd623ba..2aad544 100644 --- a/src/Plugins/CurvaLauncher.Plugins.RunProgram/RunProgramQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.RunProgram/RunProgramQueryResult.cs @@ -8,7 +8,7 @@ namespace CurvaLauncher.Plugins.RunProgram { - public class RunProgramQueryResult : ISyncQueryResult + public class RunProgramQueryResult : ISyncActionQueryResult { public RunProgramQueryResult(CurvaLauncherContext context, string filename, string arguments) { diff --git a/src/Plugins/CurvaLauncher.Plugins.Test/TestDocumentQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Test/TestDocumentQueryResult.cs new file mode 100644 index 0000000..76ad6b8 --- /dev/null +++ b/src/Plugins/CurvaLauncher.Plugins.Test/TestDocumentQueryResult.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Documents; +using System.Windows.Media; + +namespace CurvaLauncher.Plugins.Test +{ + public class TestDocumentQueryResult : ISyncDocumentQueryResult + { + public string Title => "Document Hello world"; + + public string Description => "QWQ"; + + public float Weight => 1; + + public ImageSource? Icon => null; + + public FlowDocument GenerateDocument() + { + return new FlowDocument() + { + Blocks = + { + new Paragraph(new Run("Hello world")) + { + FontSize = 24, + FontWeight = FontWeights.Bold, + } + } + }; + } + } +} \ No newline at end of file diff --git a/src/Plugins/CurvaLauncher.Plugins.Test/TestPlugin.cs b/src/Plugins/CurvaLauncher.Plugins.Test/TestPlugin.cs index 476c80d..cbe85db 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Test/TestPlugin.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Test/TestPlugin.cs @@ -41,13 +41,12 @@ public TestPlugin(CurvaLauncherContext context) : base(context) public override IEnumerable Query(string query) { - if (string.IsNullOrWhiteSpace(query)) - yield break; - - for (int i = 0; i < ResultCount; i++) + for (int i = 0; i < ResultCount - 1; i++) { yield return new TestQueryResult($"{Title} {i}", Description, (float)i / ResultCount); } + + yield return new TestDocumentQueryResult(); } public override void Initialize() diff --git a/src/Plugins/CurvaLauncher.Plugins.Test/TestQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Test/TestQueryResult.cs index 0fb3a1d..4bc908f 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Test/TestQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Test/TestQueryResult.cs @@ -3,7 +3,7 @@ namespace CurvaLauncher.Plugins.Test { - public class TestQueryResult : IAsyncQueryResult + public class TestQueryResult : IAsyncActionQueryResult { public TestQueryResult(string title, string description, float weight) { @@ -16,7 +16,7 @@ public TestQueryResult(string title, string description, float weight) public string Title { get; } - public string Description {get;} + public string Description { get; } public ImageSource? Icon => null; diff --git a/src/Plugins/CurvaLauncher.Plugins.Translator/MicrosoftEdge/EdgeTranslationQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Translator/MicrosoftEdge/EdgeTranslationQueryResult.cs index 5bc9420..b8d5993 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Translator/MicrosoftEdge/EdgeTranslationQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Translator/MicrosoftEdge/EdgeTranslationQueryResult.cs @@ -13,7 +13,7 @@ namespace CurvaLauncher.Plugins.Translator.MicrosoftEdge { - public class EdgeTranslationQueryResult : IAsyncQueryResult + public class EdgeTranslationQueryResult : IAsyncActionQueryResult { public string Title => "Translate text"; public string Description => "Translate specified text with 'MicrosoftEdge'"; diff --git a/src/Plugins/CurvaLauncher.Plugins.Translator/Youdao/YoudaoTranslationQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.Translator/Youdao/YoudaoTranslationQueryResult.cs index 2f535ca..b5331ca 100644 --- a/src/Plugins/CurvaLauncher.Plugins.Translator/Youdao/YoudaoTranslationQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.Translator/Youdao/YoudaoTranslationQueryResult.cs @@ -5,7 +5,7 @@ namespace CurvaLauncher.Plugins.Translator.Youdao { - public class YoudaoTranslationQueryResult : IAsyncQueryResult + public class YoudaoTranslationQueryResult : IAsyncActionQueryResult { private readonly TranslatorPlugin _plugin; private readonly HttpClient _httpClient; diff --git a/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingGenerateQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingGenerateQueryResult.cs index 4c38d59..ffc607f 100644 --- a/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingGenerateQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingGenerateQueryResult.cs @@ -7,7 +7,7 @@ namespace CurvaLauncher.Plugins.ZXing { - public class ZXingGenerateQueryResult : IAsyncQueryResult + public class ZXingGenerateQueryResult : IAsyncActionQueryResult { public string Title => $"Generate {CodeName}"; diff --git a/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingRecognizeQueryResult.cs b/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingRecognizeQueryResult.cs index b3b53dd..5fec8c5 100644 --- a/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingRecognizeQueryResult.cs +++ b/src/Plugins/CurvaLauncher.Plugins.ZXing/ZXingRecognizeQueryResult.cs @@ -5,7 +5,7 @@ namespace CurvaLauncher.Plugins.ZXing { - public class ZXingRecognizeQueryResult : IAsyncQueryResult + public class ZXingRecognizeQueryResult : IAsyncActionQueryResult { private readonly ZXingPlugin _plugin;