diff --git a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs index a9585f6a4..fab1b3e8f 100644 --- a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs +++ b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs @@ -2,6 +2,8 @@ using Flow.Launcher.Infrastructure.Logger; using System; using System.Collections.Generic; +using System.Net; +using System.Net.Http; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -10,43 +12,43 @@ namespace Flow.Launcher.Core.ExternalPlugins { public static class PluginsManifest { - static PluginsManifest() - { - UpdateTask = UpdateManifestAsync(); - } - - public static List UserPlugins { get; private set; } = new List(); - - public static Task UpdateTask { get; private set; } + private const string manifestFileUrl = "https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json"; private static readonly SemaphoreSlim manifestUpdateLock = new(1); - public static Task UpdateManifestAsync() - { - if (manifestUpdateLock.CurrentCount == 0) - { - return UpdateTask; - } + private static string latestEtag = ""; - return UpdateTask = DownloadManifestAsync(); - } + public static List UserPlugins { get; private set; } = new List(); - private static async Task DownloadManifestAsync() + public static async Task UpdateManifestAsync(CancellationToken token = default) { try { - await manifestUpdateLock.WaitAsync().ConfigureAwait(false); + await manifestUpdateLock.WaitAsync(token).ConfigureAwait(false); - await using var jsonStream = await Http.GetStreamAsync("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json") - .ConfigureAwait(false); + var request = new HttpRequestMessage(HttpMethod.Get, manifestFileUrl); + request.Headers.Add("If-None-Match", latestEtag); - UserPlugins = await JsonSerializer.DeserializeAsync>(jsonStream).ConfigureAwait(false); + var response = await Http.SendAsync(request, token).ConfigureAwait(false); + + if (response.StatusCode == HttpStatusCode.OK) + { + Log.Info($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Fetched plugins from manifest repo"); + + var json = await response.Content.ReadAsStreamAsync(token).ConfigureAwait(false); + + UserPlugins = await JsonSerializer.DeserializeAsync>(json, cancellationToken: token).ConfigureAwait(false); + + latestEtag = response.Headers.ETag.Tag; + } + else if (response.StatusCode != HttpStatusCode.NotModified) + { + Log.Warn($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Http response for manifest file was {response.StatusCode}"); + } } catch (Exception e) { - Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e); - - UserPlugins = new List(); + Log.Exception($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Http request failed", e); } finally { diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index b45b6adcd..9f4146b7b 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -153,5 +153,13 @@ namespace Flow.Launcher.Infrastructure.Http var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token); return await response.Content.ReadAsStreamAsync(); } + + /// + /// Asynchrously send an HTTP request. + /// + public static async Task SendAsync(HttpRequestMessage request, CancellationToken token = default) + { + return await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token); + } } } diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index fe80292be..4a5eb39af 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -29,6 +29,13 @@ namespace Flow.Launcher.Plugin /// public string ActionKeywordAssigned { get; set; } + /// + /// This holds the text which can be provided by plugin to be copied to the + /// user's clipboard when Ctrl + C is pressed on a result. If the text is a file/directory path + /// flow will copy the actual file/folder instead of just the path text. + /// + public string CopyText { get; set; } = string.Empty; + /// /// This holds the text which can be provided by plugin to help Flow autocomplete text /// for user on the plugin result. If autocomplete action for example is tab, pressing tab will have diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index ea4b25f5e..4ebff16a9 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -153,7 +153,6 @@ namespace Flow.Launcher DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; } - /// /// let exception throw as normal is better for Debug /// @@ -179,4 +178,4 @@ namespace Flow.Launcher Current.MainWindow.Show(); } } -} \ No newline at end of file +} diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index f431504c2..35a6389ca 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -88,6 +88,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Flow.Launcher/Images/Browser.png b/Flow.Launcher/Images/Browser.png index 619d1ad6a..5d475f82e 100644 Binary files a/Flow.Launcher/Images/Browser.png and b/Flow.Launcher/Images/Browser.png differ diff --git a/Flow.Launcher/Images/EXE.png b/Flow.Launcher/Images/EXE.png index e4c789689..ecc91bdb3 100644 Binary files a/Flow.Launcher/Images/EXE.png and b/Flow.Launcher/Images/EXE.png differ diff --git a/Flow.Launcher/Images/Link.png b/Flow.Launcher/Images/Link.png index c0c3607bd..3218c94c9 100644 Binary files a/Flow.Launcher/Images/Link.png and b/Flow.Launcher/Images/Link.png differ diff --git a/Flow.Launcher/Images/New Message.png b/Flow.Launcher/Images/New Message.png index 2dd2c45f2..fec9a7182 100644 Binary files a/Flow.Launcher/Images/New Message.png and b/Flow.Launcher/Images/New Message.png differ diff --git a/Flow.Launcher/Images/app_missing_img.png b/Flow.Launcher/Images/app_missing_img.png index 11d5466f0..b86c29ac9 100644 Binary files a/Flow.Launcher/Images/app_missing_img.png and b/Flow.Launcher/Images/app_missing_img.png differ diff --git a/Flow.Launcher/Images/calculator.png b/Flow.Launcher/Images/calculator.png index 102a86bde..4bdade8b7 100644 Binary files a/Flow.Launcher/Images/calculator.png and b/Flow.Launcher/Images/calculator.png differ diff --git a/Flow.Launcher/Images/cancel.png b/Flow.Launcher/Images/cancel.png index 022fbc197..69ec5a969 100644 Binary files a/Flow.Launcher/Images/cancel.png and b/Flow.Launcher/Images/cancel.png differ diff --git a/Flow.Launcher/Images/close.png b/Flow.Launcher/Images/close.png index 17c4363ad..2fb501a40 100644 Binary files a/Flow.Launcher/Images/close.png and b/Flow.Launcher/Images/close.png differ diff --git a/Flow.Launcher/Images/cmd.png b/Flow.Launcher/Images/cmd.png index 686583653..0ec0122d4 100644 Binary files a/Flow.Launcher/Images/cmd.png and b/Flow.Launcher/Images/cmd.png differ diff --git a/Flow.Launcher/Images/color.png b/Flow.Launcher/Images/color.png index da28583b1..a4301c9af 100644 Binary files a/Flow.Launcher/Images/color.png and b/Flow.Launcher/Images/color.png differ diff --git a/Flow.Launcher/Images/copy.png b/Flow.Launcher/Images/copy.png index 8f1fca752..bf12c186e 100644 Binary files a/Flow.Launcher/Images/copy.png and b/Flow.Launcher/Images/copy.png differ diff --git a/Flow.Launcher/Images/down.png b/Flow.Launcher/Images/down.png index 2349d8917..59d8ac7f3 100644 Binary files a/Flow.Launcher/Images/down.png and b/Flow.Launcher/Images/down.png differ diff --git a/Flow.Launcher/Images/file.png b/Flow.Launcher/Images/file.png index 36156767a..63058fd8e 100644 Binary files a/Flow.Launcher/Images/file.png and b/Flow.Launcher/Images/file.png differ diff --git a/Flow.Launcher/Images/find.png b/Flow.Launcher/Images/find.png index a3f0be1f5..017ebf5f2 100644 Binary files a/Flow.Launcher/Images/find.png and b/Flow.Launcher/Images/find.png differ diff --git a/Flow.Launcher/Images/folder.png b/Flow.Launcher/Images/folder.png index 569fa7049..2ae7250a2 100644 Binary files a/Flow.Launcher/Images/folder.png and b/Flow.Launcher/Images/folder.png differ diff --git a/Flow.Launcher/Images/history.png b/Flow.Launcher/Images/history.png index 2a3b72dc4..b298f8c82 100644 Binary files a/Flow.Launcher/Images/history.png and b/Flow.Launcher/Images/history.png differ diff --git a/Flow.Launcher/Images/image.png b/Flow.Launcher/Images/image.png index 7fc14c38e..9f26517e8 100644 Binary files a/Flow.Launcher/Images/image.png and b/Flow.Launcher/Images/image.png differ diff --git a/Flow.Launcher/Images/lock.png b/Flow.Launcher/Images/lock.png index 4aef7007b..daefde98e 100644 Binary files a/Flow.Launcher/Images/lock.png and b/Flow.Launcher/Images/lock.png differ diff --git a/Flow.Launcher/Images/logoff.png b/Flow.Launcher/Images/logoff.png index 0d1378830..4973b66d8 100644 Binary files a/Flow.Launcher/Images/logoff.png and b/Flow.Launcher/Images/logoff.png differ diff --git a/Flow.Launcher/Images/ok.png b/Flow.Launcher/Images/ok.png index f2dde98ef..945cceed3 100644 Binary files a/Flow.Launcher/Images/ok.png and b/Flow.Launcher/Images/ok.png differ diff --git a/Flow.Launcher/Images/open.png b/Flow.Launcher/Images/open.png index b5c7a0e19..817eb9269 100644 Binary files a/Flow.Launcher/Images/open.png and b/Flow.Launcher/Images/open.png differ diff --git a/Flow.Launcher/Images/plugin.png b/Flow.Launcher/Images/plugin.png index 6ff9b8b15..b213f0b04 100644 Binary files a/Flow.Launcher/Images/plugin.png and b/Flow.Launcher/Images/plugin.png differ diff --git a/Flow.Launcher/Images/recyclebin.png b/Flow.Launcher/Images/recyclebin.png index 2cc3b0116..878a02189 100644 Binary files a/Flow.Launcher/Images/recyclebin.png and b/Flow.Launcher/Images/recyclebin.png differ diff --git a/Flow.Launcher/Images/restart.png b/Flow.Launcher/Images/restart.png index aaa2ee711..ffdb6745e 100644 Binary files a/Flow.Launcher/Images/restart.png and b/Flow.Launcher/Images/restart.png differ diff --git a/Flow.Launcher/Images/search.png b/Flow.Launcher/Images/search.png index a3f0be1f5..017ebf5f2 100644 Binary files a/Flow.Launcher/Images/search.png and b/Flow.Launcher/Images/search.png differ diff --git a/Flow.Launcher/Images/settings.png b/Flow.Launcher/Images/settings.png index c61729fe0..79691ed95 100644 Binary files a/Flow.Launcher/Images/settings.png and b/Flow.Launcher/Images/settings.png differ diff --git a/Flow.Launcher/Images/shutdown.png b/Flow.Launcher/Images/shutdown.png index 7da7a528d..50d157efd 100644 Binary files a/Flow.Launcher/Images/shutdown.png and b/Flow.Launcher/Images/shutdown.png differ diff --git a/Flow.Launcher/Images/sleep.png b/Flow.Launcher/Images/sleep.png index 42426286d..3ca80f9fa 100644 Binary files a/Flow.Launcher/Images/sleep.png and b/Flow.Launcher/Images/sleep.png differ diff --git a/Flow.Launcher/Images/up.png b/Flow.Launcher/Images/up.png index e68def0b5..6940d80ad 100644 Binary files a/Flow.Launcher/Images/up.png and b/Flow.Launcher/Images/up.png differ diff --git a/Flow.Launcher/Images/update.png b/Flow.Launcher/Images/update.png index 6fe579091..3f0b6aa9b 100644 Binary files a/Flow.Launcher/Images/update.png and b/Flow.Launcher/Images/update.png differ diff --git a/Flow.Launcher/Languages/da.xaml b/Flow.Launcher/Languages/da.xaml index 19e1951d8..9a6e6ebf4 100644 --- a/Flow.Launcher/Languages/da.xaml +++ b/Flow.Launcher/Languages/da.xaml @@ -126,8 +126,8 @@ Opdater Annuler Denne opdatering vil genstarte Flow Launcher - Følgende filer bliver opdateret + Følgende filer bliver opdateret Opdatereringsfiler - Opdateringsbeskrivelse + Opdateringsbeskrivelse diff --git a/Flow.Launcher/Languages/de.xaml b/Flow.Launcher/Languages/de.xaml index 39dc9b377..9572db8cb 100644 --- a/Flow.Launcher/Languages/de.xaml +++ b/Flow.Launcher/Languages/de.xaml @@ -126,8 +126,8 @@ Aktualisieren Abbrechen Diese Aktualisierung wird Flow Launcher neu starten - Folgende Dateien werden aktualisiert + Folgende Dateien werden aktualisiert Aktualisiere Dateien - Aktualisierungbeschreibung + Aktualisierungbeschreibung \ No newline at end of file diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 06e765777..25de530bc 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -18,6 +18,9 @@ Copy Cut Paste + File + Folder + Text Game Mode Suspend the use of Hotkeys. @@ -244,9 +247,9 @@ Update Failed Check your connection and try updating proxy settings to github-cloud.s3.amazonaws.com. This upgrade will restart Flow Launcher - Following files will be updated + Following files will be updated Update files - Update description + Update description Skip @@ -281,7 +284,7 @@ > ping 8.8.8.8 Shell Command Bluetooth - Bluetooth in Windows Setting + Bluetooth in Windows Settings sn Sticky Notes diff --git a/Flow.Launcher/Languages/fr.xaml b/Flow.Launcher/Languages/fr.xaml index a8f280bd1..d9c46e6b9 100644 --- a/Flow.Launcher/Languages/fr.xaml +++ b/Flow.Launcher/Languages/fr.xaml @@ -132,8 +132,8 @@ Mettre à jour Annuler Flow Launcher doit redémarrer pour installer cette mise à jour - Les fichiers suivants seront mis à jour + Les fichiers suivants seront mis à jour Fichiers mis à jour - Description de la mise à jour + Description de la mise à jour diff --git a/Flow.Launcher/Languages/it.xaml b/Flow.Launcher/Languages/it.xaml index e85e49933..0302a1531 100644 --- a/Flow.Launcher/Languages/it.xaml +++ b/Flow.Launcher/Languages/it.xaml @@ -135,8 +135,8 @@ Aggiorna Annulla Questo aggiornamento riavvierà Flow Launcher - I seguenti file saranno aggiornati + I seguenti file saranno aggiornati File aggiornati - Descrizione aggiornamento + Descrizione aggiornamento \ No newline at end of file diff --git a/Flow.Launcher/Languages/ja.xaml b/Flow.Launcher/Languages/ja.xaml index 937a1e504..3fc6296c1 100644 --- a/Flow.Launcher/Languages/ja.xaml +++ b/Flow.Launcher/Languages/ja.xaml @@ -138,8 +138,8 @@ アップデート キャンセル このアップデートでは、Flow Launcherの再起動が必要です - 次のファイルがアップデートされます + 次のファイルがアップデートされます 更新ファイル一覧 - アップデートの詳細 + アップデートの詳細 \ No newline at end of file diff --git a/Flow.Launcher/Languages/ko.xaml b/Flow.Launcher/Languages/ko.xaml index c5bd082f5..7184bef34 100644 --- a/Flow.Launcher/Languages/ko.xaml +++ b/Flow.Launcher/Languages/ko.xaml @@ -241,9 +241,9 @@ 업데이트 실패 Check your connection and try updating proxy settings to github-cloud.s3.amazonaws.com. 업데이트를 위해 Flow Launcher를 재시작합니다. - 아래 파일들이 업데이트됩니다. + 아래 파일들이 업데이트됩니다. 업데이트 파일 - 업데이트 설명 + 업데이트 설명 diff --git a/Flow.Launcher/Languages/nb-NO.xaml b/Flow.Launcher/Languages/nb-NO.xaml index 19f6cc36b..859ec20a0 100644 --- a/Flow.Launcher/Languages/nb-NO.xaml +++ b/Flow.Launcher/Languages/nb-NO.xaml @@ -135,8 +135,8 @@ Oppdater Avbryt Denne opgraderingen vil starte Flow Launcher på nytt - Følgende filer vil bli oppdatert + Følgende filer vil bli oppdatert Oppdateringsfiler - Oppdateringsbeskrivelse + Oppdateringsbeskrivelse diff --git a/Flow.Launcher/Languages/nl.xaml b/Flow.Launcher/Languages/nl.xaml index ca7fed180..822af21bf 100644 --- a/Flow.Launcher/Languages/nl.xaml +++ b/Flow.Launcher/Languages/nl.xaml @@ -126,8 +126,8 @@ Update Annuleer Deze upgrade zal Flow Launcher opnieuw opstarten - Volgende bestanden zullen worden geüpdatet + Volgende bestanden zullen worden geüpdatet Update bestanden - Update beschrijving + Update beschrijving diff --git a/Flow.Launcher/Languages/pl.xaml b/Flow.Launcher/Languages/pl.xaml index 4f3042be3..a8c423de1 100644 --- a/Flow.Launcher/Languages/pl.xaml +++ b/Flow.Launcher/Languages/pl.xaml @@ -126,8 +126,8 @@ Aktualizuj Anuluj Aby dokończyć proces aktualizacji Flow Launcher musi zostać zresetowany - Następujące pliki zostaną zaktualizowane + Następujące pliki zostaną zaktualizowane Aktualizuj pliki - Opis aktualizacji + Opis aktualizacji \ No newline at end of file diff --git a/Flow.Launcher/Languages/pt-br.xaml b/Flow.Launcher/Languages/pt-br.xaml index dce921ff7..a4dfe446c 100644 --- a/Flow.Launcher/Languages/pt-br.xaml +++ b/Flow.Launcher/Languages/pt-br.xaml @@ -135,8 +135,8 @@ Atualizar Cancelar Essa atualização reiniciará o Flow Launcher - Os seguintes arquivos serão atualizados + Os seguintes arquivos serão atualizados Atualizar arquivos - Atualizar descrição + Atualizar descrição \ No newline at end of file diff --git a/Flow.Launcher/Languages/pt-pt.xaml b/Flow.Launcher/Languages/pt-pt.xaml index 6f6f1b03e..764ba542b 100644 --- a/Flow.Launcher/Languages/pt-pt.xaml +++ b/Flow.Launcher/Languages/pt-pt.xaml @@ -244,9 +244,9 @@ Falha ao atualizar Verifique a sua ligação e as definições do proxy estabelecidas para github-cloud.s3.amazonaws.com Esta atualização irá reiniciar o Flow Launcher - Os seguintes ficheiros serão atualizados + Os seguintes ficheiros serão atualizados Atualizar ficheiros - Atualizar descrição + Atualizar descrição Ignorar diff --git a/Flow.Launcher/Languages/ru.xaml b/Flow.Launcher/Languages/ru.xaml index d0d6ff0e5..63c8d46ee 100644 --- a/Flow.Launcher/Languages/ru.xaml +++ b/Flow.Launcher/Languages/ru.xaml @@ -126,8 +126,8 @@ Обновить Отмена Это обновление перезапустит Flow Launcher - Следующие файлы будут обновлены + Следующие файлы будут обновлены Обновить файлы - Описание обновления + Описание обновления \ No newline at end of file diff --git a/Flow.Launcher/Languages/sk.xaml b/Flow.Launcher/Languages/sk.xaml index 9fbf240bd..dac746d0f 100644 --- a/Flow.Launcher/Languages/sk.xaml +++ b/Flow.Launcher/Languages/sk.xaml @@ -242,9 +242,9 @@ Aktualizácia zlyhala Skontrolujte pripojenie a skúste aktualizovať nastavenia servera proxy k github-cloud.s3.amazonaws.com. Tento upgrade reštartuje Flow Launcher - Nasledujúce súbory budú aktualizované + Nasledujúce súbory budú aktualizované Aktualizovať súbory - Aktualizovať popis + Aktualizovať popis Preskočiť diff --git a/Flow.Launcher/Languages/sr.xaml b/Flow.Launcher/Languages/sr.xaml index 0394b398d..3efe27a47 100644 --- a/Flow.Launcher/Languages/sr.xaml +++ b/Flow.Launcher/Languages/sr.xaml @@ -135,8 +135,8 @@ Ažuriraj Otkaži Ova nadogradnja će ponovo pokrenuti Flow Launcher - Sledeće datoteke će biti ažurirane + Sledeće datoteke će biti ažurirane Ažuriraj datoteke - Opis ažuriranja + Opis ažuriranja \ No newline at end of file diff --git a/Flow.Launcher/Languages/tr.xaml b/Flow.Launcher/Languages/tr.xaml index 421375df9..a39b55b23 100644 --- a/Flow.Launcher/Languages/tr.xaml +++ b/Flow.Launcher/Languages/tr.xaml @@ -139,8 +139,8 @@ Güncelle İptal Bu güncelleme Flow Launcher'u yeniden başlatacaktır - Aşağıdaki dosyalar güncelleştirilecektir + Aşağıdaki dosyalar güncelleştirilecektir Güncellenecek dosyalar - Güncelleme açıklaması + Güncelleme açıklaması \ No newline at end of file diff --git a/Flow.Launcher/Languages/uk-UA.xaml b/Flow.Launcher/Languages/uk-UA.xaml index b57676f8d..790314d0f 100644 --- a/Flow.Launcher/Languages/uk-UA.xaml +++ b/Flow.Launcher/Languages/uk-UA.xaml @@ -126,8 +126,8 @@ Оновити Скасувати Це оновлення перезавантажить Flow Launcher - Ці файли будуть оновлені + Ці файли будуть оновлені Оновити файли - Опис оновлення + Опис оновлення \ No newline at end of file diff --git a/Flow.Launcher/Languages/zh-cn.xaml b/Flow.Launcher/Languages/zh-cn.xaml index 01cd97467..e404c4deb 100644 --- a/Flow.Launcher/Languages/zh-cn.xaml +++ b/Flow.Launcher/Languages/zh-cn.xaml @@ -226,9 +226,9 @@ 更新失败 检查网络是否可以连接至github-cloud.s3.amazonaws.com. 此次更新需要重启Flow Launcher - 下列文件会被更新 + 下列文件会被更新 更新文件 - 更新日志 + 更新日志 跳过 diff --git a/Flow.Launcher/Languages/zh-tw.xaml b/Flow.Launcher/Languages/zh-tw.xaml index 294add207..cba62ead4 100644 --- a/Flow.Launcher/Languages/zh-tw.xaml +++ b/Flow.Launcher/Languages/zh-tw.xaml @@ -126,8 +126,8 @@ 更新 取消 此更新需要重新啟動 Flow Launcher - 下列檔案會被更新 + 下列檔案會被更新 更新檔案 - 更新日誌 + 更新日誌 diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 5d26433b5..714fcc53f 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -175,6 +175,9 @@ Style="{DynamicResource QueryBoxStyle}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="Visible"> + + + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index c1d170f9a..366407182 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -18,6 +18,8 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs; using NotifyIcon = System.Windows.Forms.NotifyIcon; using Flow.Launcher.Infrastructure; using System.Windows.Media; +using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher { @@ -50,7 +52,18 @@ namespace Flow.Launcher { InitializeComponent(); } + private void OnCopy(object sender, ExecutedRoutedEventArgs e) + { + if (QueryTextBox.SelectionLength == 0) + { + _viewModel.ResultCopy(string.Empty); + } + else if (!string.IsNullOrEmpty(QueryTextBox.Text)) + { + _viewModel.ResultCopy(QueryTextBox.SelectedText); + } + } private async void OnClosing(object sender, CancelEventArgs e) { _settings.WindowTop = Top; @@ -59,6 +72,7 @@ namespace Flow.Launcher _viewModel.Save(); e.Cancel = true; await PluginManager.DisposePluginsAsync(); + Notification.Uninstall(); Environment.Exit(0); } @@ -498,6 +512,24 @@ namespace Flow.Launcher e.Handled = true; } break; + case Key.Back: + var specialKeyState = GlobalHotkey.CheckModifiers(); + if (specialKeyState.CtrlPressed) + { + if (_viewModel.SelectedIsFromQueryResults() + && QueryTextBox.CaretIndex == QueryTextBox.Text.Length) + { + var queryWithoutActionKeyword = + QueryBuilder.Build(QueryTextBox.Text.Trim(), PluginManager.NonGlobalPlugins).Search; + + if (FilesFolders.IsLocationPathString(queryWithoutActionKeyword)) + { + _viewModel.BackspaceCommand.Execute(null); + e.Handled = true; + } + } + } + break; default: break; diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs index d8f9fd45e..3f5565eeb 100644 --- a/Flow.Launcher/Notification.cs +++ b/Flow.Launcher/Notification.cs @@ -1,4 +1,5 @@ using Flow.Launcher.Infrastructure; +using Microsoft.Toolkit.Uwp.Notifications; using System; using System.IO; using Windows.Data.Xml.Dom; @@ -8,10 +9,17 @@ namespace Flow.Launcher { internal static class Notification { + internal static bool legacy = Environment.OSVersion.Version.Build < 19041; + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] + internal static void Uninstall() + { + if (!legacy) + ToastNotificationManagerCompat.Uninstall(); + } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] public static void Show(string title, string subTitle, string iconPath) { - var legacy = Environment.OSVersion.Version.Build < 19041; // Handle notification for win7/8/early win10 if (legacy) { @@ -24,13 +32,11 @@ namespace Flow.Launcher ? Path.Combine(Constant.ProgramDirectory, "Images\\app.png") : iconPath; - var xml = $"\"meziantou\"/{title}" + - $"{subTitle}"; - var toastXml = new XmlDocument(); - toastXml.LoadXml(xml); - var toast = new ToastNotification(toastXml); - ToastNotificationManager.CreateToastNotifier("Flow Launcher").Show(toast); - + new ToastContentBuilder() + .AddText(title, hintMaxLines: 1) + .AddText(subTitle) + .AddAppLogoOverride(new Uri(Icon)) + .Show(); } private static void LegacyShow(string title, string subTitle, string iconPath) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 214c410be..967e4d52b 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2514,6 +2514,18 @@ Margin="14,14,0,0" HorizontalAlignment="Center" VerticalAlignment="Bottom" + FontSize="12" + Foreground="{DynamicResource Color15B}" + TextWrapping="WrapWithOverflow"> + + + + + + { var result = SelectedResults.SelectedItem?.Result; - if (result != null) // SelectedItem returns null if selection is empty. + if (result != null && SelectedIsFromQueryResults()) // SelectedItem returns null if selection is empty. { var autoCompleteText = result.Title; @@ -252,6 +254,18 @@ namespace Flow.Launcher.ViewModel } }); + BackspaceCommand = new RelayCommand(index => + { + var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins); + + // GetPreviousExistingDirectory does not require trailing '\', otherwise will return empty string + var path = FilesFolders.GetPreviousExistingDirectory((_) => true, query.Search.TrimEnd('\\')); + + var actionKeyword = string.IsNullOrEmpty(query.ActionKeyword) ? string.Empty : $"{query.ActionKeyword} "; + + ChangeQueryText($"{actionKeyword}{path}"); + }); + LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) @@ -398,6 +412,7 @@ namespace Flow.Launcher.ViewModel public string PluginIconPath { get; set; } = null; public ICommand EscCommand { get; set; } + public ICommand BackspaceCommand { get; set; } public ICommand SelectNextItemCommand { get; set; } public ICommand SelectPrevItemCommand { get; set; } public ICommand SelectNextPageCommand { get; set; } @@ -410,6 +425,9 @@ namespace Flow.Launcher.ViewModel public ICommand OpenSettingCommand { get; set; } public ICommand ReloadPluginDataCommand { get; set; } public ICommand ClearQueryCommand { get; private set; } + + public ICommand CopyToClipboard { get; set; } + public ICommand AutocompleteQueryCommand { get; set; } public string OpenResultCommandModifiers { get; private set; } @@ -662,7 +680,7 @@ namespace Flow.Launcher.ViewModel Action = _ => { _topMostRecord.Remove(result); - App.API.ShowMsg("Success"); + App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success")); return false; } }; @@ -706,7 +724,11 @@ namespace Flow.Launcher.ViewModel IcoPath = icon, SubTitle = subtitle, PluginDirectory = metadata.PluginDirectory, - Action = _ => false + Action = _ => + { + App.API.OpenUrl(metadata.Website); + return true; + } }; return menu; } @@ -853,6 +875,52 @@ namespace Flow.Launcher.ViewModel Results.AddResults(resultsForUpdates, token); } + /// + /// This is the global copy method for an individual result. If no text is passed, + /// the method will work out what is to be copied based on the result, so plugin can offer the text + /// to be copied via the result model. If the text is a directory/file path, + /// then actual file/folder will be copied instead. + /// The result's subtitle text is the default text to be copied + /// + public void ResultCopy(string stringToCopy) + { + if (string.IsNullOrEmpty(stringToCopy)) + { + var result = Results.SelectedItem?.Result; + if (result != null) + { + string copyText = string.IsNullOrEmpty(result.CopyText) ? result.SubTitle : result.CopyText; + var isFile = File.Exists(copyText); + var isFolder = Directory.Exists(copyText); + if (isFile || isFolder) + { + var paths = new StringCollection(); + paths.Add(copyText); + + Clipboard.SetFileDropList(paths); + App.API.ShowMsg( + App.API.GetTranslation("copy") + +" " + + (isFile? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")), + App.API.GetTranslation("completedSuccessfully")); + } + else + { + Clipboard.SetDataObject(copyText.ToString()); + App.API.ShowMsg( + App.API.GetTranslation("copy") + + " " + + App.API.GetTranslation("textTitle"), + App.API.GetTranslation("completedSuccessfully")); + } + } + + return; + } + + Clipboard.SetDataObject(stringToCopy); + } + #endregion } } \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 908de0c09..4d32d792d 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -7,11 +7,16 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using System.IO; +using System.Drawing.Text; +using System.Collections.Generic; namespace Flow.Launcher.ViewModel { public class ResultViewModel : BaseModel { + private static PrivateFontCollection fontCollection = new(); + private static Dictionary fonts = new(); + public ResultViewModel(Result result, Settings settings) { if (result != null) @@ -23,13 +28,29 @@ namespace Flow.Launcher.ViewModel // Checks if it's a system installed font, which does not require path to be provided. if (glyph.FontFamily.EndsWith(".ttf") || glyph.FontFamily.EndsWith(".otf")) { - var fontPath = Result.Glyph.FontFamily; - Glyph = Path.IsPathRooted(fontPath) - ? Result.Glyph - : Result.Glyph with + string fontFamilyPath = glyph.FontFamily; + + if (!Path.IsPathRooted(fontFamilyPath)) + { + fontFamilyPath = Path.Combine(Result.PluginDirectory, fontFamilyPath); + } + + if (fonts.ContainsKey(fontFamilyPath)) + { + Glyph = glyph with { - FontFamily = Path.Combine(Result.PluginDirectory, fontPath) + FontFamily = fonts[fontFamilyPath] }; + } + else + { + fontCollection.AddFontFile(fontFamilyPath); + fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{fontCollection.Families[^1].Name}"; + Glyph = glyph with + { + FontFamily = fonts[fontFamilyPath] + }; + } } else { diff --git a/Flow.Launcher/ViewModel/ResultsViewModel.cs b/Flow.Launcher/ViewModel/ResultsViewModel.cs index 01a19d871..db24825d0 100644 --- a/Flow.Launcher/ViewModel/ResultsViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultsViewModel.cs @@ -310,4 +310,4 @@ namespace Flow.Launcher.ViewModel } } } -} \ No newline at end of file +} diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/bookmark.png b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/bookmark.png index b8aee3564..d68cecea1 100644 Binary files a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/bookmark.png and b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/bookmark.png differ diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/copylink.png b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/copylink.png index 0dee870b6..3218c94c9 100644 Binary files a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/copylink.png and b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Images/copylink.png differ diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json index 3dfa418c7..afc4f9855 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json @@ -4,7 +4,7 @@ "Name": "Browser Bookmarks", "Description": "Search your browser bookmarks", "Author": "qianlifeng, Ioannis G.", - "Version": "1.6.2", + "Version": "1.6.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.BrowserBookmark.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Images/calculator.png b/Plugins/Flow.Launcher.Plugin.Calculator/Images/calculator.png index 102a86bde..4bdade8b7 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Calculator/Images/calculator.png and b/Plugins/Flow.Launcher.Plugin.Calculator/Images/calculator.png differ diff --git a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/ko.xaml b/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/ko.xaml deleted file mode 100644 index bcfdd3fc9..000000000 --- a/Plugins/Flow.Launcher.Plugin.ControlPanel/Languages/ko.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - - 제어판 - 제어판 항목을 검색합니다. - - diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/copy.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/copy.png index 8f1fca752..26786b11e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/copy.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/copy.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/deletefilefolder.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/deletefilefolder.png index 024cc9291..a8e27d342 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/deletefilefolder.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/deletefilefolder.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/excludeindexpath.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/excludeindexpath.png index 8578ac7fb..19b7025a5 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/excludeindexpath.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/excludeindexpath.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/file.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/file.png index 36156767a..bf12c186e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/file.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/file.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/folder.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/folder.png index 569fa7049..2ae7250a2 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/folder.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/folder.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/index.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/index.png index c63fc8069..a671dac21 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/index.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/index.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/quickaccess.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/quickaccess.png index 470a6782f..e3fdeb4f7 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/quickaccess.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/quickaccess.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/removequickaccess.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/removequickaccess.png index fbfb0b960..0ca287ea3 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/removequickaccess.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/removequickaccess.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/user.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/user.png index 2d45c1ee9..03402d8e8 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Explorer/Images/user.png and b/Plugins/Flow.Launcher.Plugin.Explorer/Images/user.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index a54606182..10be3381d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -10,7 +10,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.11.1", + "Version": "1.11.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", diff --git a/Plugins/Flow.Launcher.Plugin.PluginIndicator/Images/work.png b/Plugins/Flow.Launcher.Plugin.PluginIndicator/Images/work.png index 6ff9b8b15..b213f0b04 100644 Binary files a/Plugins/Flow.Launcher.Plugin.PluginIndicator/Images/work.png and b/Plugins/Flow.Launcher.Plugin.PluginIndicator/Images/work.png differ diff --git a/Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs index b046b2beb..ec33a64e7 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs @@ -25,6 +25,7 @@ namespace Flow.Launcher.Plugin.PluginIndicator SubTitle = $"Activate {metadata.Name} plugin", Score = 100, IcoPath = metadata.IcoPath, + AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}", Action = c => { context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}"); diff --git a/Plugins/Flow.Launcher.Plugin.PluginIndicator/plugin.json b/Plugins/Flow.Launcher.Plugin.PluginIndicator/plugin.json index d2197d700..b19e3c99c 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginIndicator/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.PluginIndicator/plugin.json @@ -4,7 +4,7 @@ "Name": "Plugin Indicator", "Description": "Provide plugin actionword suggestion", "Author": "qianlifeng", - "Version": "1.1.3", + "Version": "1.1.4", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginIndicator.dll", diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs index a20e5a267..37f0a126e 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs @@ -2,7 +2,7 @@ using Flow.Launcher.Infrastructure.UserSettings; using System; using System.Collections.Generic; -using System.Text; +using System.Text.RegularExpressions; namespace Flow.Launcher.Plugin.PluginsManager { @@ -53,8 +53,8 @@ namespace Flow.Launcher.Plugin.PluginsManager { // standard UrlSourceCode format in PluginsManifest's plugins.json file: https://github.com/jjw24/Flow.Launcher.Plugin.Putty/tree/master var link = pluginManifestInfo.UrlSourceCode.StartsWith("https://github.com") - ? pluginManifestInfo.UrlSourceCode.Replace("/tree/master", "/issues/new/choose") - : pluginManifestInfo.UrlSourceCode; + ? Regex.Replace(pluginManifestInfo.UrlSourceCode, @"\/tree\/\w+$", "") + "/issues/new/choose" + : pluginManifestInfo.UrlSourceCode; Context.API.OpenUrl(link); return true; diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/manifestsite.png b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/manifestsite.png index f96ba15b2..54f3f62fc 100644 Binary files a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/manifestsite.png and b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/manifestsite.png differ diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/pluginsmanager.png b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/pluginsmanager.png index 65f0e41dc..91b3148c5 100644 Binary files a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/pluginsmanager.png and b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/pluginsmanager.png differ diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/request.png b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/request.png index a9126cb9b..a43b87d85 100644 Binary files a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/request.png and b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/request.png differ diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/sourcecode.png b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/sourcecode.png index 8efbdaa48..77afc44f9 100644 Binary files a/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/sourcecode.png and b/Plugins/Flow.Launcher.Plugin.PluginsManager/Images/sourcecode.png differ diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs index 8aaae95d6..57c857403 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs @@ -12,7 +12,7 @@ using System.Windows; namespace Flow.Launcher.Plugin.PluginsManager { - public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n, IAsyncReloadable + public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n { internal PluginInitContext Context { get; set; } @@ -24,28 +24,20 @@ namespace Flow.Launcher.Plugin.PluginsManager internal PluginsManager pluginManager; - private DateTime lastUpdateTime = DateTime.MinValue; - public Control CreateSettingPanel() { return new PluginsManagerSettings(viewModel); } - public Task InitAsync(PluginInitContext context) + public async Task InitAsync(PluginInitContext context) { Context = context; Settings = context.API.LoadSettingJsonStorage(); viewModel = new SettingsViewModel(context, Settings); contextMenu = new ContextMenu(Context); pluginManager = new PluginsManager(Context, Settings); - _manifestUpdateTask = pluginManager - .UpdateManifestAsync(true) - .ContinueWith(_ => - { - lastUpdateTime = DateTime.Now; - }, TaskContinuationOptions.OnlyOnRanToCompletion); - return Task.CompletedTask; + await pluginManager.UpdateManifestAsync(); } public List LoadContextMenus(Result selectedResult) @@ -53,35 +45,20 @@ namespace Flow.Launcher.Plugin.PluginsManager return contextMenu.LoadContextMenus(selectedResult); } - private Task _manifestUpdateTask = Task.CompletedTask; - public async Task> QueryAsync(Query query, CancellationToken token) { - var search = query.Search; - - if (string.IsNullOrWhiteSpace(search)) + if (string.IsNullOrWhiteSpace(query.Search)) return pluginManager.GetDefaultHotKeys(); - if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours - { - _manifestUpdateTask = pluginManager.UpdateManifestAsync().ContinueWith(t => - { - lastUpdateTime = DateTime.Now; - }, TaskContinuationOptions.OnlyOnRanToCompletion); - } - - return search switch + return query.FirstSearch.ToLower() switch { //search could be url, no need ToLower() when passed in - var s when s.StartsWith(Settings.HotKeyInstall, StringComparison.OrdinalIgnoreCase) - => await pluginManager.RequestInstallOrUpdate(search, token), - var s when s.StartsWith(Settings.HotkeyUninstall, StringComparison.OrdinalIgnoreCase) - => pluginManager.RequestUninstall(search), - var s when s.StartsWith(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase) - => await pluginManager.RequestUpdate(search, token), + Settings.InstallCommand => await pluginManager.RequestInstallOrUpdate(query.SecondToEndSearch, token), + Settings.UninstallCommand => pluginManager.RequestUninstall(query.SecondToEndSearch), + Settings.UpdateCommand => await pluginManager.RequestUpdate(query.SecondToEndSearch, token), _ => pluginManager.GetDefaultHotKeys().Where(hotkey => { - hotkey.Score = StringMatcher.FuzzySearch(search, hotkey.Title).Score; + hotkey.Score = StringMatcher.FuzzySearch(query.Search, hotkey.Title).Score; return hotkey.Score > 0; }).ToList() }; @@ -96,11 +73,5 @@ namespace Flow.Launcher.Plugin.PluginsManager { return Context.API.GetTranslation("plugin_pluginsmanager_plugin_description"); } - - public async Task ReloadDataAsync() - { - await pluginManager.UpdateManifestAsync(); - lastUpdateTime = DateTime.Now; - } } } \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index 53e994d34..bbf155e23 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -51,7 +51,7 @@ namespace Flow.Launcher.Plugin.PluginsManager private Task _downloadManifestTask = Task.CompletedTask; - internal Task UpdateManifestAsync(bool silent = false) + internal Task UpdateManifestAsync(CancellationToken token = default, bool silent = false) { if (_downloadManifestTask.Status == TaskStatus.Running) { @@ -59,7 +59,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } else { - _downloadManifestTask = PluginsManifest.UpdateTask; + _downloadManifestTask = PluginsManifest.UpdateManifestAsync(token); if (!silent) _downloadManifestTask.ContinueWith(_ => Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"), @@ -75,31 +75,34 @@ namespace Flow.Launcher.Plugin.PluginsManager { new Result() { - Title = Settings.HotKeyInstall, + Title = Settings.InstallCommand, IcoPath = icoPath, + AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.InstallCommand} ", Action = _ => { - Context.API.ChangeQuery("pm install "); + Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.InstallCommand} "); return false; } }, new Result() { - Title = Settings.HotkeyUninstall, + Title = Settings.UninstallCommand, IcoPath = icoPath, + AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UninstallCommand} ", Action = _ => { - Context.API.ChangeQuery("pm uninstall "); + Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UninstallCommand} "); return false; } }, new Result() { - Title = Settings.HotkeyUpdate, + Title = Settings.UpdateCommand, IcoPath = icoPath, + AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UpdateCommand} ", Action = _ => { - Context.API.ChangeQuery("pm update "); + Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UpdateCommand} "); return false; } } @@ -119,7 +122,7 @@ namespace Flow.Launcher.Plugin.PluginsManager Context .API .ChangeQuery( - $"{Context.CurrentPluginMetadata.ActionKeywords.FirstOrDefault()} {Settings.HotkeyUpdate} {plugin.Name}"); + $"{Context.CurrentPluginMetadata.ActionKeywords.FirstOrDefault()} {Settings.UpdateCommand} {plugin.Name}"); var mainWindow = Application.Current.MainWindow; mainWindow.Show(); @@ -181,22 +184,7 @@ namespace Flow.Launcher.Plugin.PluginsManager internal async ValueTask> RequestUpdate(string search, CancellationToken token) { - if (!PluginsManifest.UserPlugins.Any()) - { - await UpdateManifestAsync(); - } - - token.ThrowIfCancellationRequested(); - - var autocompletedResults = AutoCompleteReturnAllResults(search, - Settings.HotkeyUpdate, - "Update", - "Select a plugin to update"); - - if (autocompletedResults.Any()) - return autocompletedResults; - - var uninstallSearch = search.Replace(Settings.HotkeyUpdate, string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart(); + await UpdateManifestAsync(token); var resultsForUpdate = from existingPlugin in Context.API.GetAllPlugins() @@ -285,7 +273,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } }); - return Search(results, uninstallSearch); + return Search(results, search); } internal bool PluginExists(string id) @@ -369,20 +357,13 @@ namespace Flow.Launcher.Plugin.PluginsManager return url.StartsWith(acceptedSource) && Context.API.GetAllPlugins().Any(x => x.Metadata.Website.StartsWith(contructedUrlPart)); } - internal async ValueTask> RequestInstallOrUpdate(string searchName, CancellationToken token) + internal async ValueTask> RequestInstallOrUpdate(string search, CancellationToken token) { - if (!PluginsManifest.UserPlugins.Any()) - { - await UpdateManifestAsync(); - } + await UpdateManifestAsync(token); - token.ThrowIfCancellationRequested(); - - var searchNameWithoutKeyword = searchName.Replace(Settings.HotKeyInstall, string.Empty, StringComparison.OrdinalIgnoreCase).Trim(); - - if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute) - && searchNameWithoutKeyword.Split('.').Last() == zip) - return InstallFromWeb(searchNameWithoutKeyword); + if (Uri.IsWellFormedUriString(search, UriKind.Absolute) + && search.Split('.').Last() == zip) + return InstallFromWeb(search); var results = PluginsManifest @@ -408,7 +389,7 @@ namespace Flow.Launcher.Plugin.PluginsManager ContextData = x }); - return Search(results, searchNameWithoutKeyword); + return Search(results, search); } private void Install(UserPlugin plugin, string downloadedFilePath) @@ -468,16 +449,6 @@ namespace Flow.Launcher.Plugin.PluginsManager internal List RequestUninstall(string search) { - var autocompletedResults = AutoCompleteReturnAllResults(search, - Settings.HotkeyUninstall, - "Uninstall", - "Select a plugin to uninstall"); - - if (autocompletedResults.Any()) - return autocompletedResults; - - var uninstallSearch = search.Replace(Settings.HotkeyUninstall, string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart(); - var results = Context.API .GetAllPlugins() .Select(x => @@ -508,7 +479,7 @@ namespace Flow.Launcher.Plugin.PluginsManager } }); - return Search(results, uninstallSearch); + return Search(results, search); } private void Uninstall(PluginMetadata plugin, bool removedSetting = true) @@ -523,36 +494,6 @@ namespace Flow.Launcher.Plugin.PluginsManager using var _ = File.CreateText(Path.Combine(plugin.PluginDirectory, "NeedDelete.txt")); } - private List AutoCompleteReturnAllResults(string search, string hotkey, string title, string subtitle) - { - if (!string.IsNullOrEmpty(search) - && hotkey.StartsWith(search) - && (hotkey != search || !search.StartsWith(hotkey))) - { - return - new List - { - new Result - { - Title = title, - IcoPath = icoPath, - SubTitle = subtitle, - Action = e => - { - Context - .API - .ChangeQuery( - $"{Context.CurrentPluginMetadata.ActionKeywords.FirstOrDefault()} {hotkey} "); - - return false; - } - } - }; - } - - return new List(); - } - private bool SameOrLesserPluginVersionExists(string metadataPath) { var newMetadata = JsonSerializer.Deserialize(File.ReadAllText(metadataPath)); diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Settings.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Settings.cs index a951010c0..6fd4e51ac 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Settings.cs @@ -6,11 +6,11 @@ namespace Flow.Launcher.Plugin.PluginsManager { internal class Settings { - internal string HotKeyInstall { get; set; } = "install"; + internal const string InstallCommand = "install"; - internal string HotkeyUninstall { get; set; } = "uninstall"; + internal const string UninstallCommand = "uninstall"; - internal string HotkeyUpdate { get; set; } = "update"; + internal const string UpdateCommand = "update"; public bool WarnFromUnknownSource { get; set; } = true; } diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json index 0900ddb6c..6e74fa9e4 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json @@ -6,7 +6,7 @@ "Name": "Plugins Manager", "Description": "Management of installing, uninstalling or updating Flow Launcher plugins", "Author": "Jeremy Wu", - "Version": "1.11.2", + "Version": "1.12.1", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll", diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png index fa76a5d29..418086275 100644 Binary files a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png and b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Images/app.png differ diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs index 31b4a67ed..19f96aea1 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs @@ -88,6 +88,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData, Score = pr.Score, ContextData = p.ProcessName, + AutoCompleteText = $"{_context.CurrentPluginMetadata.ActionKeyword}{Plugin.Query.TermSeparator}{p.ProcessName}", Action = (c) => { processHelper.TryKill(p); diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json b/Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json index 96565e14c..8e3eb87fe 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/plugin.json @@ -4,7 +4,7 @@ "Name":"Process Killer", "Description":"Kill running processes from Flow", "Author":"Flow-Launcher", - "Version":"1.2.4", + "Version":"1.2.6", "Language":"csharp", "Website":"https://github.com/Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller", "IcoPath":"Images\\app.png", diff --git a/Plugins/Flow.Launcher.Plugin.Program/Images/cmd.png b/Plugins/Flow.Launcher.Plugin.Program/Images/cmd.png index 686583653..284e1d371 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Program/Images/cmd.png and b/Plugins/Flow.Launcher.Plugin.Program/Images/cmd.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Program/Images/disable.png b/Plugins/Flow.Launcher.Plugin.Program/Images/disable.png index e9d4976bc..61bcc97fb 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Program/Images/disable.png and b/Plugins/Flow.Launcher.Plugin.Program/Images/disable.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Program/Images/folder.png b/Plugins/Flow.Launcher.Plugin.Program/Images/folder.png index 569fa7049..2ae7250a2 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Program/Images/folder.png and b/Plugins/Flow.Launcher.Plugin.Program/Images/folder.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Program/Images/program.png b/Plugins/Flow.Launcher.Plugin.Program/Images/program.png index e4c789689..ecc91bdb3 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Program/Images/program.png and b/Plugins/Flow.Launcher.Plugin.Program/Images/program.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Program/Images/user.png b/Plugins/Flow.Launcher.Plugin.Program/Images/user.png index 2d45c1ee9..03402d8e8 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Program/Images/user.png and b/Plugins/Flow.Launcher.Plugin.Program/Images/user.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Program/plugin.json b/Plugins/Flow.Launcher.Plugin.Program/plugin.json index 29bdcd90d..993b2adba 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Program/plugin.json @@ -4,7 +4,7 @@ "Name": "Program", "Description": "Search programs in Flow.Launcher", "Author": "qianlifeng", - "Version": "1.8.1", + "Version": "1.8.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Program.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Images/admin.png b/Plugins/Flow.Launcher.Plugin.Shell/Images/admin.png index bc3fe8778..284e1d371 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Shell/Images/admin.png and b/Plugins/Flow.Launcher.Plugin.Shell/Images/admin.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Images/copy.png b/Plugins/Flow.Launcher.Plugin.Shell/Images/copy.png index cc3bf4ea8..bf12c186e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Shell/Images/copy.png and b/Plugins/Flow.Launcher.Plugin.Shell/Images/copy.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Images/shell.png b/Plugins/Flow.Launcher.Plugin.Shell/Images/shell.png index 686583653..0ec0122d4 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Shell/Images/shell.png and b/Plugins/Flow.Launcher.Plugin.Shell/Images/shell.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Images/user.png b/Plugins/Flow.Launcher.Plugin.Shell/Images/user.png index 2d45c1ee9..03402d8e8 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Shell/Images/user.png and b/Plugins/Flow.Launcher.Plugin.Shell/Images/user.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 0c539015e..bed46425d 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -317,7 +317,7 @@ namespace Flow.Launcher.Plugin.Shell bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state) { - if (_settings.ReplaceWinR) + if (!context.CurrentPluginMetadata.Disabled && _settings.ReplaceWinR) { if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) { diff --git a/Plugins/Flow.Launcher.Plugin.Shell/plugin.json b/Plugins/Flow.Launcher.Plugin.Shell/plugin.json index d04a919e4..5871432c9 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Shell/plugin.json @@ -4,7 +4,7 @@ "Name": "Shell", "Description": "Provide executing commands from Flow Launcher", "Author": "qianlifeng", - "Version": "1.4.8", + "Version": "1.4.10", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Shell.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/checkupdate.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/checkupdate.png index 955f6fdbb..0eb06af18 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/checkupdate.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/checkupdate.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/close.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/close.png index 17c4363ad..2fb501a40 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/close.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/close.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/hibernate.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/hibernate.png index 703204fa7..668048e19 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/hibernate.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/hibernate.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/lock.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/lock.png index 4aef7007b..daefde98e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/lock.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/lock.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/logoff.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/logoff.png index 0d1378830..4973b66d8 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/logoff.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/logoff.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/recyclebin.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/recyclebin.png index 2cc3b0116..878a02189 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/recyclebin.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/recyclebin.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/restart.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/restart.png index aaa2ee711..ffdb6745e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/restart.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/restart.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/restart_advanced.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/restart_advanced.png index feabbefa1..09257d2c0 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/restart_advanced.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/restart_advanced.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/shutdown.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/shutdown.png index 7da7a528d..50d157efd 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/shutdown.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/shutdown.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Images/sleep.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/sleep.png index 42426286d..3ca80f9fa 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Sys/Images/sleep.png and b/Plugins/Flow.Launcher.Plugin.Sys/Images/sleep.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Sys/plugin.json b/Plugins/Flow.Launcher.Plugin.Sys/plugin.json index 9c2dcbfff..c9e9c1272 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Sys/plugin.json @@ -4,7 +4,7 @@ "Name": "System Commands", "Description": "Provide System related commands. e.g. shutdown,lock, setting etc.", "Author": "qianlifeng", - "Version": "1.6.1", + "Version": "1.6.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Sys.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Url/Images/url.png b/Plugins/Flow.Launcher.Plugin.Url/Images/url.png index 619d1ad6a..5d475f82e 100644 Binary files a/Plugins/Flow.Launcher.Plugin.Url/Images/url.png and b/Plugins/Flow.Launcher.Plugin.Url/Images/url.png differ diff --git a/Plugins/Flow.Launcher.Plugin.Url/plugin.json b/Plugins/Flow.Launcher.Plugin.Url/plugin.json index e128ceafb..0d71232d8e 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Url/plugin.json @@ -4,7 +4,7 @@ "Name": "URL", "Description": "Open the typed URL from Flow Launcher", "Author": "qianlifeng", - "Version": "1.2.1", + "Version": "1.2.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Url.dll", diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Images/web_search.png b/Plugins/Flow.Launcher.Plugin.WebSearch/Images/web_search.png index a3f0be1f5..017ebf5f2 100644 Binary files a/Plugins/Flow.Launcher.Plugin.WebSearch/Images/web_search.png and b/Plugins/Flow.Launcher.Plugin.WebSearch/Images/web_search.png differ diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 31d56c108..2ed412130 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -41,8 +41,8 @@ namespace Flow.Launcher.Plugin.WebSearch var results = new List(); foreach (SearchSource searchSource in _settings.SearchSources.Where(o => (o.ActionKeyword == query.ActionKeyword || - o.ActionKeyword == SearchSourceGlobalPluginWildCardSign) - && o.Enabled)) + o.ActionKeyword == SearchSourceGlobalPluginWildCardSign) + && o.Enabled)) { string keyword = string.Empty; keyword = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? query.ToString() : query.Search; @@ -105,11 +105,11 @@ namespace Flow.Launcher.Plugin.WebSearch if (_settings.EnableSuggestion) { var suggestions = await SuggestionsAsync(keyword, subtitle, searchSource, token).ConfigureAwait(false); - if (token.IsCancellationRequested || !suggestions.Any()) + var enumerable = suggestions?.ToList(); + if (token.IsCancellationRequested || enumerable is not { Count: > 0 }) return; - - - results.AddRange(suggestions); + + results.AddRange(enumerable); token.ThrowIfCancellationRequested(); } @@ -118,32 +118,32 @@ namespace Flow.Launcher.Plugin.WebSearch private async Task> SuggestionsAsync(string keyword, string subtitle, SearchSource searchSource, CancellationToken token) { var source = _settings.SelectedSuggestion; - if (source != null) + if (source == null) { - //Suggestions appear below actual result, and appear above global action keyword match if non-global; - var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1; - - var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false); - - token.ThrowIfCancellationRequested(); - - var resultsFromSuggestion = suggestions?.Select(o => new Result - { - Title = o, - SubTitle = subtitle, - Score = score, - IcoPath = searchSource.IconPath, - ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword, - Action = c => - { - _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); - - return true; - } - }); - return resultsFromSuggestion; + return new List(); } - return new List(); + //Suggestions appear below actual result, and appear above global action keyword match if non-global; + var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1; + + var suggestions = await source.SuggestionsAsync(keyword, token).ConfigureAwait(false); + + token.ThrowIfCancellationRequested(); + + var resultsFromSuggestion = suggestions?.Select(o => new Result + { + Title = o, + SubTitle = subtitle, + Score = score, + IcoPath = searchSource.IconPath, + ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword, + Action = c => + { + _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); + + return true; + } + }); + return resultsFromSuggestion; } public Task InitAsync(PluginInitContext context) @@ -191,4 +191,4 @@ namespace Flow.Launcher.Plugin.WebSearch public event ResultUpdatedEventHandler ResultsUpdated; } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs index 33c304375..19e996b84 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs @@ -84,7 +84,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Duckduckgo", + Title = "DuckDuckGo", ActionKeyword = "duckduckgo", Icon = "duckduckgo.png", Url = "https://duckduckgo.com/?q={q}", @@ -92,7 +92,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Github", + Title = "GitHub", ActionKeyword = "github", Icon = "github.png", Url = "https://github.com/search?q={q}", @@ -100,7 +100,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Github Gist", + Title = "GitHub Gist", ActionKeyword = "gist", Icon = "gist.png", Url = "https://gist.github.com/search?q={q}", @@ -124,7 +124,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Wolframalpha", + Title = "WolframAlpha", ActionKeyword = "wolframalpha", Icon = "wolframalpha.png", Url = "https://www.wolframalpha.com/input/?i={q}", @@ -132,7 +132,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Stackoverflow", + Title = "Stack Overflow", ActionKeyword = "stackoverflow", Icon = "stackoverflow.png", Url = "https://stackoverflow.com/search?q={q}", @@ -148,7 +148,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Google Image", + Title = "Google Images", ActionKeyword = "image", Icon = "google.png", Url = "https://www.google.com/search?q={q}&tbm=isch", @@ -156,7 +156,7 @@ namespace Flow.Launcher.Plugin.WebSearch }, new SearchSource { - Title = "Youtube", + Title = "YouTube", ActionKeyword = "youtube", Icon = "youtube.png", Url = "https://www.youtube.com/results?search_query={q}", diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs index ccb5b20d7..d1fbd4ac5 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs @@ -16,7 +16,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources { private readonly Regex _reg = new Regex("window.baidu.sug\\((.*)\\)"); - public override async Task> Suggestions(string query, CancellationToken token) + public override async Task> SuggestionsAsync(string query, CancellationToken token) { string result; @@ -25,7 +25,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources const string api = "http://suggestion.baidu.com/su?json=1&wd="; result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false); } - catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException) + catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException}) { Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e); return null; diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs index 38c5fb4a0..971fc079c 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs @@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources { class Bing : SuggestionSource { - public override async Task> Suggestions(string query, CancellationToken token) + public override async Task> SuggestionsAsync(string query, CancellationToken token) { try @@ -40,7 +40,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources } - catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException) + catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException}) { Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e); return null; diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs index c5f43d081..a6c18b1ef 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs @@ -14,7 +14,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources { public class Google : SuggestionSource { - public override async Task> Suggestions(string query, CancellationToken token) + public override async Task> SuggestionsAsync(string query, CancellationToken token) { try { @@ -32,7 +32,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources return results.EnumerateArray().Select(o => o.GetString()).ToList(); } - catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException) + catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException}) { Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e); return null; diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/SuggestionSource.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/SuggestionSource.cs index c58e61141..e89addee9 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/SuggestionSource.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/SuggestionSource.cs @@ -6,6 +6,6 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources { public abstract class SuggestionSource { - public abstract Task> Suggestions(string query, CancellationToken token); + public abstract Task> SuggestionsAsync(string query, CancellationToken token); } } diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json index d9bc47f3b..9239e082c 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json @@ -26,7 +26,7 @@ "Name": "Web Searches", "Description": "Provide the web search ability", "Author": "qianlifeng", - "Version": "1.5.1", + "Version": "1.5.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll", diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/setting.json b/Plugins/Flow.Launcher.Plugin.WebSearch/setting.json index c8f521653..533b894b8 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/setting.json +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/setting.json @@ -8,7 +8,7 @@ "Enabled": true }, { - "Title": "Youtube", + "Title": "YouTube", "ActionKeyword": "youtube", "IconPath": "Images\\youtube.png", "Url": "http://www.youtube.com/results?search_query={q}", @@ -43,7 +43,7 @@ "Enabled": true }, { - "Title": "Youtube Music", + "Title": "YouTube Music", "ActionKeyword": "ytmusic", "IconPath": "Images\\youtubemusic.png", "Url": "https://music.youtube.com/search?q={q}", @@ -78,35 +78,35 @@ "Enabled": true }, { - "Title": "Duckduckgo", + "Title": "DuckDuckGo", "ActionKeyword": "duckduckgo", "IconPath": "Images\\duckduckgo.png", "Url": "https://duckduckgo.com/?q={q}", "Enabled": true }, { - "Title": "Github", + "Title": "GitHub", "ActionKeyword": "github", "IconPath": "Images\\github.png", "Url": "https://github.com/search?q={q}", "Enabled": true }, { - "Title": "Github Gist", + "Title": "GitHub Gist", "ActionKeyword": "gist", "IconPath": "Images\\gist.png", "Url": "https://gist.github.com/search?q={q}", "Enabled": true }, { - "Title": "Wolframalpha", + "Title": "WolframAlpha", "ActionKeyword": "wolframalpha", "IconPath": "Images\\wolframalpha.png", "Url": "http://www.wolframalpha.com/input/?i={q}", "Enabled": true }, { - "Title": "Stackoverflow", + "Title": "Stack Overflow", "ActionKeyword": "stackoverflow", "IconPath": "Images\\stackoverflow.png", "Url": "http://stackoverflow.com/search?q={q}", @@ -120,7 +120,7 @@ "Enabled": true }, { - "Title": "Google Image", + "Title": "Google Images", "ActionKeyword": "image", "IconPath": "Images\\google.png", "Url": "https://www.google.com/search?q={q}&tbm=isch", diff --git a/README.md b/README.md index 5e824077a..0066fc6af 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ Dedicated to making your workflow flow more seamless. Search everything from app ### Installation -| [Windows 7+ installer](https://github.com/Flow-Launcher/Flow.Launcher/releases/latest/download/Flow-Launcher-Setup.exe) | [Portable](https://github.com/Flow-Launcher/Flow.Launcher/releases/latest/download/Flow-Launcher-Portable.zip) | `WinGet install "Flow Launcher"` | -| :----------------------------------------------------------: | :----------------------------------------------------------: | :------------------------------: | +| [Windows 7+ installer](https://github.com/Flow-Launcher/Flow.Launcher/releases/latest/download/Flow-Launcher-Setup.exe) | [Portable](https://github.com/Flow-Launcher/Flow.Launcher/releases/latest/download/Flow-Launcher-Portable.zip) | `winget install "Flow Launcher"` | `scoop install Flow-Launcher` | +| :----------------------------------------------------------: | :----------------------------------------------------------: | :------------------------------: | :------------------------------: | > Windows may complain about security due to code not being signed, this will be completed at a later stage. If you downloaded from this repo, you are good to continue the set up. @@ -215,17 +215,18 @@ And you can download