From 4fbd74a14d14cc680a85d25b18a30cdc200229b1 Mon Sep 17 00:00:00 2001 From: NoPlagiarism <37241775+NoPlagiarism@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:07:57 +0500 Subject: [PATCH 01/53] [WebSearch] Add copy URL to menu --- .../Images/copylink.png | Bin 0 -> 3242 bytes .../Languages/en.xaml | 3 +- .../Languages/ru.xaml | 3 +- .../Flow.Launcher.Plugin.WebSearch/Main.cs | 26 ++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 Plugins/Flow.Launcher.Plugin.WebSearch/Images/copylink.png diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Images/copylink.png b/Plugins/Flow.Launcher.Plugin.WebSearch/Images/copylink.png new file mode 100644 index 0000000000000000000000000000000000000000..3218c94c9a0fb53f923197042c20cc994b22d5c9 GIT binary patch literal 3242 zcmbVPc{G%JAD=tJWGP5d`;006Mf z%F@({KOWq?MTPm#B1-Tue^6kXd9a=7eryh&Nd{m^bOISUU=w4IAs5Xjppw~m5SJQ6W1+c5;P1R>{(N&A3I=^QVFwz4 ze~9w1bpYY$OfpDc2M!^^U@(wAN{56e;E4o+HV6Sjz@acC6pnCc!_ndB>d=|~P&f*Og2E6`1OmdhfUv@7Y&;i2V=4b) zFeS5yObUZdq0>N{jCcY)glz=oOZ^c8m0@f97cq_XGgJJWLAiJa6s`kO^MILzqPVf%qx^0`rsi&yF??`D)PiObY*0@Ij_@VhEK?V_TUT zf%$KANE8y9Kt%ELNYI1m8o&tRCj^g|Fyzj*!*uMgKVI0Q2{ z)jObzfWysjSU3`8pnnJpGe3Ys=^irpg|(uw*mxR|{L43m@B1ef_m5aKj!DL|=}Z?o zJ?K{%I0VqybXEYJ0Yd2Nz(5-A6dH-nVQFrj(T|W#$xKQpnPkqSQ$gR8jHdjJfd4J{ zA9&LLn>;9A6m+vv{;P6+ZSl)-bNW{!@E3oz5}C&DA11$1xP|ym06?_e$`tFu9hmb9 z3{rHL|JrdSW9Z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launcher.Plugin.WebSearch/Languages/ru.xaml b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/ru.xaml index a2ec9405a..b8757f67b 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/ru.xaml +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/ru.xaml @@ -29,7 +29,8 @@ Thus, the generic formula for a search on Netflix is https://www.netflix.com/search?q={q} - + Скопировать URL-адрес + Скопировать URL поиска в буфер обмена Title diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 39aa1738f..9b3dd06f5 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -11,7 +11,7 @@ using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher.Plugin.WebSearch { - public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated + public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated, IContextMenu { private PluginInitContext _context; @@ -76,7 +76,8 @@ namespace Flow.Launcher.Plugin.WebSearch _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword))); return true; - } + }, + ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)), }; results.Add(result); @@ -139,11 +140,30 @@ namespace Flow.Launcher.Plugin.WebSearch _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); return true; - } + }, + ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)), }); return resultsFromSuggestion; } + public List LoadContextMenus(Result selected) + { + return new List() { + new Result + { + Title = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_title"), + SubTitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_subtitle"), + IcoPath = "Images/copylink.png", + Action = c => + { + _context.API.CopyToClipboard(selected.ContextData as string); + + return true; + } + }, + }; + } + public Task InitAsync(PluginInitContext context) { return Task.Run(Init); From 386ac9735f3a53f3fbd12a3a8c01523c49cae818 Mon Sep 17 00:00:00 2001 From: NoPlagiarism <37241775+NoPlagiarism@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:43:22 +0500 Subject: [PATCH 02/53] [WebSearch] sanitize ContextData --- Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 9b3dd06f5..bf5fadc54 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -148,6 +148,7 @@ namespace Flow.Launcher.Plugin.WebSearch public List LoadContextMenus(Result selected) { + if (selected?.ContextData == null || selected.ContextData is not string) return new List(); return new List() { new Result { From 3c3087793a354c3b2b687a9f5ba1b9e4e69bd40a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 21 Nov 2024 19:18:05 +0800 Subject: [PATCH 03/53] add new public api for chaning the query list back to query results list --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 6 ++++++ Flow.Launcher/PublicAPIInstance.cs | 2 ++ Flow.Launcher/ViewModel/MainViewModel.cs | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index c95a8ce7b..e5df91ae9 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -298,5 +298,11 @@ namespace Flow.Launcher.Plugin /// /// Choose the first result after reload if true; keep the last selected result if false. Default is true. public void ReQuery(bool reselect = true); + + /// + /// Back to the query results. + /// This method should run when selected item is from context menu or history. + /// + public void BackToQueryResults(); } } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 20b02ddee..8a07e7a5c 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -318,6 +318,8 @@ namespace Flow.Launcher public void ReQuery(bool reselect = true) => _mainVM.ReQuery(reselect); + public void BackToQueryResults() => _mainVM.BackToQueryResults(); + #endregion #region Private Methods diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 6c17e21f0..445484347 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -484,6 +484,14 @@ namespace Flow.Launcher.ViewModel } } + public void BackToQueryResults() + { + if (!SelectedIsFromQueryResults()) + { + SelectedResults = Results; + } + } + [RelayCommand] public void ToggleGameMode() { From 6df0837906b07e7c84084fa8ceb6e49ce7ce5529 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 21 Nov 2024 19:18:15 +0800 Subject: [PATCH 04/53] improve requery doc --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index e5df91ae9..f3d773122 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -294,7 +294,7 @@ namespace Flow.Launcher.Plugin /// /// Reloads the query. - /// This method should run + /// This method should run when selected item is from query results. /// /// Choose the first result after reload if true; keep the last selected result if false. Default is true. public void ReQuery(bool reselect = true); From 3ae960d275e82c88f5aabe57ad9405f028e8ceb4 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 24 Nov 2024 16:11:53 +0800 Subject: [PATCH 05/53] Replace System.Windows.Message with MessageBoxEx --- Flow.Launcher.Core/Configuration/Portable.cs | 13 +++++++------ .../MessageBoxEx.xaml | 4 ++-- .../MessageBoxEx.xaml.cs | 15 +-------------- .../Resource/Internationalization.cs | 3 ++- Flow.Launcher.Core/Resource/Theme.cs | 4 ++-- Flow.Launcher.Core/Updater.cs | 7 ++++--- Flow.Launcher/ActionKeywords.xaml.cs | 3 ++- Flow.Launcher/CustomQueryHotkeySetting.xaml.cs | 4 ++-- Flow.Launcher/CustomShortcutSetting.xaml.cs | 5 +++-- Flow.Launcher/Helper/HotKeyMapper.cs | 4 ++-- Flow.Launcher/PriorityChangeWindow.xaml.cs | 5 +++-- .../ViewModels/SettingsPaneAboutViewModel.cs | 2 +- .../ViewModels/SettingsPaneHotkeyViewModel.cs | 18 ++++++++++-------- .../ViewModels/SettingsPaneProxyViewModel.cs | 3 +-- .../ViewModels/SettingsPaneThemeViewModel.cs | 4 ++-- 15 files changed, 44 insertions(+), 50 deletions(-) rename {Flow.Launcher => Flow.Launcher.Core}/MessageBoxEx.xaml (98%) rename {Flow.Launcher => Flow.Launcher.Core}/MessageBoxEx.xaml.cs (93%) diff --git a/Flow.Launcher.Core/Configuration/Portable.cs b/Flow.Launcher.Core/Configuration/Portable.cs index b58154dcb..544cf2509 100644 --- a/Flow.Launcher.Core/Configuration/Portable.cs +++ b/Flow.Launcher.Core/Configuration/Portable.cs @@ -9,6 +9,7 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin.SharedCommands; using System.Linq; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core.Configuration { @@ -40,7 +41,7 @@ namespace Flow.Launcher.Core.Configuration #endif IndicateDeletion(DataLocation.PortableDataPath); - MessageBox.Show("Flow Launcher needs to restart to finish disabling portable mode, " + + MessageBoxEx.Show("Flow Launcher needs to restart to finish disabling portable mode, " + "after the restart your portable data profile will be deleted and roaming data profile kept"); UpdateManager.RestartApp(Constant.ApplicationFileName); @@ -64,7 +65,7 @@ namespace Flow.Launcher.Core.Configuration #endif IndicateDeletion(DataLocation.RoamingDataPath); - MessageBox.Show("Flow Launcher needs to restart to finish enabling portable mode, " + + MessageBoxEx.Show("Flow Launcher needs to restart to finish enabling portable mode, " + "after the restart your roaming data profile will be deleted and portable data profile kept"); UpdateManager.RestartApp(Constant.ApplicationFileName); @@ -159,9 +160,9 @@ namespace Flow.Launcher.Core.Configuration { FilesFolders.RemoveFolderIfExists(roamingDataDir); - if (MessageBox.Show("Flow Launcher has detected you enabled portable mode, " + + if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " + "would you like to move it to a different location?", string.Empty, - MessageBoxButton.YesNo) == MessageBoxResult.Yes) + MessageBoxType.YesNo) == MessageBoxResult.Yes) { FilesFolders.OpenPath(Constant.RootDirectory); @@ -174,7 +175,7 @@ namespace Flow.Launcher.Core.Configuration { FilesFolders.RemoveFolderIfExists(portableDataDir); - MessageBox.Show("Flow Launcher has detected you disabled portable mode, " + + MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " + "the relevant shortcuts and uninstaller entry have been created"); } } @@ -186,7 +187,7 @@ namespace Flow.Launcher.Core.Configuration if (roamingLocationExists && portableLocationExists) { - MessageBox.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " + + MessageBoxEx.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " + "{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.", DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine)); diff --git a/Flow.Launcher/MessageBoxEx.xaml b/Flow.Launcher.Core/MessageBoxEx.xaml similarity index 98% rename from Flow.Launcher/MessageBoxEx.xaml rename to Flow.Launcher.Core/MessageBoxEx.xaml index f466a640e..ca543271b 100644 --- a/Flow.Launcher/MessageBoxEx.xaml +++ b/Flow.Launcher.Core/MessageBoxEx.xaml @@ -1,9 +1,9 @@  path can't be found"); if (theme != defaultTheme) { - MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme)); + MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme)); ChangeTheme(defaultTheme); } return false; @@ -120,7 +120,7 @@ namespace Flow.Launcher.Core.Resource Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse"); if (theme != defaultTheme) { - MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme)); + MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme)); ChangeTheme(defaultTheme); } return false; diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 3f64b273e..34545c771 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -17,6 +17,7 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using System.Text.Json.Serialization; using System.Threading; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core { @@ -53,7 +54,7 @@ namespace Flow.Launcher.Core if (newReleaseVersion <= currentVersion) { if (!silentUpdate) - MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest")); + MessageBoxEx.Show(api.GetTranslation("update_flowlauncher_already_on_latest")); return; } @@ -70,7 +71,7 @@ namespace Flow.Launcher.Core var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}"; FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination); if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination)) - MessageBox.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"), + MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"), DataLocation.PortableDataPath, targetDestination)); } @@ -83,7 +84,7 @@ namespace Flow.Launcher.Core Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}"); - if (MessageBox.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) + if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxType.YesNo) == MessageBoxResult.Yes) { UpdateManager.RestartApp(Constant.ApplicationFileName); } diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs index 371b2dd07..ba47a4ded 100644 --- a/Flow.Launcher/ActionKeywords.xaml.cs +++ b/Flow.Launcher/ActionKeywords.xaml.cs @@ -2,6 +2,7 @@ using Flow.Launcher.Core.Resource; using Flow.Launcher.Plugin; using Flow.Launcher.ViewModel; +using Flow.Launcher.Core; namespace Flow.Launcher { @@ -43,7 +44,7 @@ namespace Flow.Launcher else { string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned"); - MessageBox.Show(msg); + MessageBoxEx.Show(msg); } } } diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index 5db6115ad..81e7600b8 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Windows; using System.Windows.Input; using System.Windows.Controls; -using Flow.Launcher.ViewModel; +using Flow.Launcher.Core; namespace Flow.Launcher { @@ -63,7 +63,7 @@ namespace Flow.Launcher o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); if (updateCustomHotkey == null) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey")); Close(); return; } diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index 531b29d50..dec3506eb 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -3,6 +3,7 @@ using System; using System.Windows; using System.Windows.Input; using Flow.Launcher.SettingPages.ViewModels; +using Flow.Launcher.Core; namespace Flow.Launcher { @@ -42,13 +43,13 @@ namespace Flow.Launcher { if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value)) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut")); return; } // Check if key is modified or adding a new one if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key)) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut")); return; } DialogResult = !update || originalKey != Key || originalValue != Value; diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 21ddf276a..8b30b8be1 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -4,8 +4,8 @@ using System; using NHotkey; using NHotkey.Wpf; using Flow.Launcher.Core.Resource; -using System.Windows; using Flow.Launcher.ViewModel; +using Flow.Launcher.Core; namespace Flow.Launcher.Helper; @@ -46,7 +46,7 @@ internal static class HotKeyMapper { string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle"); - MessageBox.Show(errorMsg,errorMsgTitle); + MessageBoxEx.Show(errorMsg, errorMsgTitle); } } diff --git a/Flow.Launcher/PriorityChangeWindow.xaml.cs b/Flow.Launcher/PriorityChangeWindow.xaml.cs index 2d0966de4..2154b058d 100644 --- a/Flow.Launcher/PriorityChangeWindow.xaml.cs +++ b/Flow.Launcher/PriorityChangeWindow.xaml.cs @@ -5,6 +5,7 @@ using Flow.Launcher.ViewModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using Flow.Launcher.Core; namespace Flow.Launcher { @@ -23,7 +24,7 @@ namespace Flow.Launcher this.pluginViewModel = pluginViewModel; if (plugin == null) { - MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin")); + MessageBoxEx.Show(translater.GetTranslation("cannotFindSpecifiedPlugin")); Close(); } } @@ -43,7 +44,7 @@ namespace Flow.Launcher else { string msg = translater.GetTranslation("invalidPriority"); - MessageBox.Show(msg); + MessageBoxEx.Show(msg); } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs index c314b42ee..6e6cbce4d 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs @@ -11,7 +11,7 @@ using Flow.Launcher.Core.Resource; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; -using static Flow.Launcher.MessageBoxEx; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.SettingPages.ViewModels; diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs index a4488a037..669cd0784 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs @@ -7,6 +7,8 @@ using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; +using Flow.Launcher.Core; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.SettingPages.ViewModels; @@ -41,16 +43,16 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomPluginHotkey; if (item is null) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); return; } - var result = MessageBox.Show( + var result = MessageBoxEx.Show( string.Format( InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey ), InternationalizationManager.Instance.GetTranslation("delete"), - MessageBoxButton.YesNo + MessageBoxType.YesNo ); if (result is MessageBoxResult.Yes) @@ -66,7 +68,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomPluginHotkey; if (item is null) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); return; } @@ -87,16 +89,16 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomShortcut; if (item is null) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); return; } - var result = MessageBox.Show( + var result = MessageBoxEx.Show( string.Format( InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value ), InternationalizationManager.Instance.GetTranslation("delete"), - MessageBoxButton.YesNo + MessageBoxType.YesNo ); if (result is MessageBoxResult.Yes) @@ -111,7 +113,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomShortcut; if (item is null) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); return; } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs index 2dd57809d..1c840fb27 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs @@ -1,5 +1,4 @@ using System.Net; -using System.Windows; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core; using Flow.Launcher.Core.Resource; @@ -23,7 +22,7 @@ public partial class SettingsPaneProxyViewModel : BaseModel private void OnTestProxyClicked() { var message = TestProxy(); - MessageBox.Show(InternationalizationManager.Instance.GetTranslation(message)); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation(message)); } private string TestProxy() diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index f2e52dbae..8a835ba7c 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Windows; -using System.Windows.Controls; using System.Globalization; using System.IO; using System.Linq; @@ -15,6 +14,7 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.ViewModel; using ModernWpf; +using Flow.Launcher.Core; using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager; using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager; @@ -49,7 +49,7 @@ public partial class SettingsPaneThemeViewModel : BaseModel { if (ThemeManager.Instance.BlurEnabled && value) { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed")); + MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed")); return; } From 6feca10bdbc3dbce3f4b8cc48fe9f3aebe23b3ad Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 24 Nov 2024 16:30:35 +0800 Subject: [PATCH 06/53] Improve MessageBoxEx paramters as System.Windows.MessageBox for readability --- Flow.Launcher.Core/MessageBoxEx.xaml.cs | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml.cs b/Flow.Launcher.Core/MessageBoxEx.xaml.cs index 18b1ae07f..3e04657dc 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml.cs +++ b/Flow.Launcher.Core/MessageBoxEx.xaml.cs @@ -37,39 +37,39 @@ namespace Flow.Launcher.Core /// 1 parameter - public static MessageBoxResult Show(string msg) + public static MessageBoxResult Show(string messageBoxText) { - return Show(string.Empty, msg, MessageBoxButton.OK, MessageBoxImage.None); + return Show(string.Empty, messageBoxText, MessageBoxButton.OK, MessageBoxImage.None); } // 2 parameter - public static MessageBoxResult Show(string caption, string text) + public static MessageBoxResult Show(string messageBoxText, string title) { - return Show(caption, text, MessageBoxButton.OK, MessageBoxImage.None); + return Show(messageBoxText, title, MessageBoxButton.OK, MessageBoxImage.None); } /// 3 parameter - public static MessageBoxResult Show(string caption, string msg, MessageBoxType type) + public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxType type) { switch (type) { case MessageBoxType.ConfirmationWithYesNo: - return Show(caption, msg, MessageBoxButton.YesNo, + return Show(messageBoxText, title, MessageBoxButton.YesNo, MessageBoxImage.Question); case MessageBoxType.YesNo: - return Show(caption, msg, MessageBoxButton.YesNo, + return Show(messageBoxText, title, MessageBoxButton.YesNo, MessageBoxImage.Question); case MessageBoxType.ConfirmationWithYesNoCancel: - return Show(caption, msg, MessageBoxButton.YesNoCancel, + return Show(messageBoxText, title, MessageBoxButton.YesNoCancel, MessageBoxImage.Question); case MessageBoxType.Information: - return Show(caption, msg, MessageBoxButton.OK, + return Show(messageBoxText, title, MessageBoxButton.OK, MessageBoxImage.Information); case MessageBoxType.Error: - return Show(caption, msg, MessageBoxButton.OK, + return Show(messageBoxText, title, MessageBoxButton.OK, MessageBoxImage.Error); case MessageBoxType.Warning: - return Show(caption, msg, MessageBoxButton.OK, + return Show(messageBoxText, title, MessageBoxButton.OK, MessageBoxImage.Warning); default: return MessageBoxResult.No; @@ -77,12 +77,12 @@ namespace Flow.Launcher.Core } // 4 parameter, Final Display Message. - public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image) + public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxButton button, MessageBoxImage image) { msgBox = new MessageBoxEx(); - msgBox.TitleTextBlock.Text = text; - msgBox.DescTextBlock.Text = caption; - msgBox.Title = text; + msgBox.TitleTextBlock.Text = title; + msgBox.DescTextBlock.Text = messageBoxText; + msgBox.Title = title; SetVisibilityOfButtons(button); SetImageOfMessageBox(image); msgBox.ShowDialog(); From ab087bd927c8e4c75db90115151ce1b11cefe6c7 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 24 Nov 2024 22:08:50 +0800 Subject: [PATCH 07/53] Remove useless columns --- Flow.Launcher.Core/MessageBoxEx.xaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml b/Flow.Launcher.Core/MessageBoxEx.xaml index ca543271b..2788a7648 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml +++ b/Flow.Launcher.Core/MessageBoxEx.xaml @@ -33,14 +33,11 @@ - - -