From efd34c980f7326ddc6b938a1f68d8bfea10fda79 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 Dec 2021 16:13:49 -0600 Subject: [PATCH 001/235] Draft Query Shortcut --- .../UserSettings/Settings.cs | 1 + .../UserSettings/ShortCutModel.cs | 12 +++++++++ Flow.Launcher/SettingWindow.xaml | 25 +++++++++++++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 12 ++++++++- .../ViewModel/SettingWindowViewModel.cs | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8ecd6dc4b..9d9a2e7a9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -205,6 +205,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); + internal List ShortCuts { get; set; } = new List(); } public enum LastQueryMode diff --git a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs new file mode 100644 index 000000000..5853dbbb4 --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Flow.Launcher.Infrastructure.UserSettings +{ + public record ShortCutModel(string Key, string Value) + { + } +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index e15d5285c..a90a3a006 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -873,6 +873,31 @@ SelectedValuePath="LanguageCode" /> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 95ef5d483..1ab7301a8 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -529,6 +529,16 @@ namespace Flow.Launcher.ViewModel return; } + string query = QueryText; + + foreach (var shortcut in _settings.ShortCuts) + { + if (QueryText == shortcut.Key) + { + query = shortcut.Value; + } + } + _updateSource?.Dispose(); var currentUpdateSource = new CancellationTokenSource(); @@ -545,7 +555,7 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins); + var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins); // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 342c85da2..720b0a00d 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -170,6 +170,8 @@ namespace Flow.Launcher.ViewModel public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); + public List ShortCuts => Settings.ShortCuts; + public string TestProxy() { var proxyServer = Settings.Proxy.Server; From 4340c0896c4272512e9f18d61d021962e09f3550 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 Dec 2021 16:13:49 -0600 Subject: [PATCH 002/235] Draft Query Shortcut --- .../UserSettings/Settings.cs | 1 + .../UserSettings/ShortCutModel.cs | 12 +++++++++ Flow.Launcher/SettingWindow.xaml | 25 +++++++++++++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 12 ++++++++- .../ViewModel/SettingWindowViewModel.cs | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8ecd6dc4b..9d9a2e7a9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -205,6 +205,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); + internal List ShortCuts { get; set; } = new List(); } public enum LastQueryMode diff --git a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs new file mode 100644 index 000000000..5853dbbb4 --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Flow.Launcher.Infrastructure.UserSettings +{ + public record ShortCutModel(string Key, string Value) + { + } +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index e15d5285c..a90a3a006 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -873,6 +873,31 @@ SelectedValuePath="LanguageCode" /> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 95ef5d483..1ab7301a8 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -529,6 +529,16 @@ namespace Flow.Launcher.ViewModel return; } + string query = QueryText; + + foreach (var shortcut in _settings.ShortCuts) + { + if (QueryText == shortcut.Key) + { + query = shortcut.Value; + } + } + _updateSource?.Dispose(); var currentUpdateSource = new CancellationTokenSource(); @@ -545,7 +555,7 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins); + var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins); // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 342c85da2..720b0a00d 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -170,6 +170,8 @@ namespace Flow.Launcher.ViewModel public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); + public List ShortCuts => Settings.ShortCuts; + public string TestProxy() { var proxyServer = Settings.Proxy.Server; From 0a8405f72ab2d37517251f7ae9b6ae8fcf8c138d Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 1 Mar 2022 13:29:21 -0600 Subject: [PATCH 003/235] Resolve issue and add partial replacement trick --- .../UserSettings/Settings.cs | 8 ++- .../UserSettings/ShortCutModel.cs | 12 ---- Flow.Launcher/ViewModel/MainViewModel.cs | 17 +++--- .../ViewModel/SettingWindowViewModel.cs | 55 ++++++++++++------- 4 files changed, 51 insertions(+), 41 deletions(-) delete mode 100644 Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 9d9a2e7a9..568e6c53c 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -120,8 +120,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings PrivateArg = "-private", EnablePrivate = false, Editable = false - } - , + }, new() { Name = "MS Edge", @@ -205,7 +204,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); - internal List ShortCuts { get; set; } = new List(); + internal ObservableCollection> ShortCuts { get; set; } = new() + { + new("spp", "sp play") + }; } public enum LastQueryMode diff --git a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs deleted file mode 100644 index 5853dbbb4..000000000 --- a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Flow.Launcher.Infrastructure.UserSettings -{ - public record ShortCutModel(string Key, string Value) - { - } -} diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 1ab7301a8..34c6b66b1 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -16,6 +16,7 @@ using Flow.Launcher.Plugin; using Flow.Launcher.Storage; using Flow.Launcher.Infrastructure.Logger; using Microsoft.VisualStudio.Threading; +using System.Text; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; @@ -303,9 +304,9 @@ namespace Flow.Launcher.ViewModel #region ViewModel Properties public ResultsViewModel Results { get; private set; } - + public ResultsViewModel ContextMenu { get; private set; } - + public ResultsViewModel History { get; private set; } public bool GameModeStatus { get; set; } @@ -529,14 +530,16 @@ namespace Flow.Launcher.ViewModel return; } - string query = QueryText; + StringBuilder queryBuilder = new(QueryText); foreach (var shortcut in _settings.ShortCuts) { - if (QueryText == shortcut.Key) + if (queryBuilder.Equals(shortcut.Key)) { - query = shortcut.Value; + queryBuilder.Replace(shortcut.Key, shortcut.Value); } + + queryBuilder.Replace('@' + shortcut.Key, shortcut.Value); } _updateSource?.Dispose(); @@ -554,8 +557,8 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - - var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins); + + var query = QueryBuilder.Build(queryBuilder.ToString().Trim(), PluginManager.NonGlobalPlugins); // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 720b0a00d..965d33b6e 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -19,6 +19,7 @@ using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; +using System.Collections.ObjectModel; namespace Flow.Launcher.ViewModel { @@ -117,7 +118,10 @@ namespace Flow.Launcher.ViewModel { var key = $"LastQuery{e}"; var display = _translater.GetTranslation(key); - var m = new LastQueryMode { Display = display, Value = e, }; + var m = new LastQueryMode + { + Display = display, Value = e, + }; modes.Add(m); } return modes; @@ -165,12 +169,17 @@ namespace Flow.Launcher.ViewModel } } - public List OpenResultModifiersList => new List { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" }; + public List OpenResultModifiersList => new List + { + KeyConstant.Alt, + KeyConstant.Ctrl, + $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" + }; private Internationalization _translater => InternationalizationManager.Instance; public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); - public List ShortCuts => Settings.ShortCuts; + public ObservableCollection> ShortCuts => Settings.ShortCuts; public string TestProxy() { @@ -230,7 +239,10 @@ namespace Flow.Launcher.ViewModel var metadatas = PluginManager.AllPlugins .OrderBy(x => x.Metadata.Disabled) .ThenBy(y => y.Metadata.Name) - .Select(p => new PluginViewModel { PluginPair = p }) + .Select(p => new PluginViewModel + { + PluginPair = p + }) .ToList(); return metadatas; } @@ -269,8 +281,6 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(ExternalPlugins)); } - - #endregion #region theme @@ -284,7 +294,7 @@ namespace Flow.Launcher.ViewModel { Settings.Theme = value; ThemeManager.Instance.ChangeTheme(value); - + if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect) DropShadowEffect = false; } @@ -333,7 +343,10 @@ namespace Flow.Launcher.ViewModel { var key = $"ColorScheme{e}"; var display = _translater.GetTranslation(key); - var m = new ColorScheme { Display = display, Value = e, }; + var m = new ColorScheme + { + Display = display, Value = e, + }; modes.Add(m); } return modes; @@ -376,7 +389,10 @@ namespace Flow.Launcher.ViewModel bitmap.BeginInit(); bitmap.StreamSource = memStream; bitmap.EndInit(); - var brush = new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill }; + var brush = new ImageBrush(bitmap) + { + Stretch = Stretch.UniformToFill + }; return brush; } else @@ -404,19 +420,19 @@ namespace Flow.Launcher.ViewModel { Title = "WebSearch", SubTitle = "Search the web with different search engine support", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.WebSearch\Images\web_search.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.WebSearch\Images\web_search.png") }, new Result { Title = "Program", SubTitle = "Launch programs as admin or a different user", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Program\Images\program.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Program\Images\program.png") }, new Result { Title = "ProcessKiller", SubTitle = "Terminate unwanted processes", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png") } }; var vm = new ResultsViewModel(Settings); @@ -430,8 +446,8 @@ namespace Flow.Launcher.ViewModel get { if (Fonts.SystemFontFamilies.Count(o => - o.FamilyNames.Values != null && - o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0) + o.FamilyNames.Values != null && + o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0) { var font = new FontFamily(Settings.QueryBoxFont); return font; @@ -458,7 +474,7 @@ namespace Flow.Launcher.ViewModel Settings.QueryBoxFontStyle, Settings.QueryBoxFontWeight, Settings.QueryBoxFontStretch - )); + )); return typeface; } set @@ -475,8 +491,8 @@ namespace Flow.Launcher.ViewModel get { if (Fonts.SystemFontFamilies.Count(o => - o.FamilyNames.Values != null && - o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0) + o.FamilyNames.Values != null && + o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0) { var font = new FontFamily(Settings.ResultFont); return font; @@ -503,7 +519,7 @@ namespace Flow.Launcher.ViewModel Settings.ResultFontStyle, Settings.ResultFontWeight, Settings.ResultFontStretch - )); + )); return typeface; } set @@ -534,6 +550,7 @@ namespace Flow.Launcher.ViewModel public string Github => Constant.GitHub; public static string Version => Constant.Version; public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); + #endregion } -} +} \ No newline at end of file From 0d355bdef80dab753c142ef4eeb682914d87050e Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 Dec 2021 16:13:49 -0600 Subject: [PATCH 004/235] Draft Query Shortcut --- .../UserSettings/Settings.cs | 1 + .../UserSettings/ShortCutModel.cs | 12 +++++++++ Flow.Launcher/SettingWindow.xaml | 25 +++++++++++++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 12 ++++++++- .../ViewModel/SettingWindowViewModel.cs | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8ecd6dc4b..9d9a2e7a9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -205,6 +205,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); + internal List ShortCuts { get; set; } = new List(); } public enum LastQueryMode diff --git a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs new file mode 100644 index 000000000..5853dbbb4 --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Flow.Launcher.Infrastructure.UserSettings +{ + public record ShortCutModel(string Key, string Value) + { + } +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 967e4d52b..0cb2343bc 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -875,6 +875,31 @@ SelectedValuePath="LanguageCode" /> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 0fe3bdf80..7706db614 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -553,6 +553,16 @@ namespace Flow.Launcher.ViewModel return; } + string query = QueryText; + + foreach (var shortcut in _settings.ShortCuts) + { + if (QueryText == shortcut.Key) + { + query = shortcut.Value; + } + } + _updateSource?.Dispose(); var currentUpdateSource = new CancellationTokenSource(); @@ -569,7 +579,7 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins); + var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins); // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 2fc6934d5..2096b43c6 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -170,6 +170,8 @@ namespace Flow.Launcher.ViewModel public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); + public List ShortCuts => Settings.ShortCuts; + public string TestProxy() { var proxyServer = Settings.Proxy.Server; From 2bb88124e62429e70d34d35fd2727809f1adbd89 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 1 Mar 2022 13:29:21 -0600 Subject: [PATCH 005/235] Resolve issue and add partial replacement trick --- .../UserSettings/Settings.cs | 8 ++- .../UserSettings/ShortCutModel.cs | 12 ---- Flow.Launcher/ViewModel/MainViewModel.cs | 17 +++--- .../ViewModel/SettingWindowViewModel.cs | 55 ++++++++++++------- 4 files changed, 51 insertions(+), 41 deletions(-) delete mode 100644 Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 9d9a2e7a9..568e6c53c 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -120,8 +120,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings PrivateArg = "-private", EnablePrivate = false, Editable = false - } - , + }, new() { Name = "MS Edge", @@ -205,7 +204,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings // This needs to be loaded last by staying at the bottom public PluginsSettings PluginSettings { get; set; } = new PluginsSettings(); - internal List ShortCuts { get; set; } = new List(); + internal ObservableCollection> ShortCuts { get; set; } = new() + { + new("spp", "sp play") + }; } public enum LastQueryMode diff --git a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs deleted file mode 100644 index 5853dbbb4..000000000 --- a/Flow.Launcher.Infrastructure/UserSettings/ShortCutModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Flow.Launcher.Infrastructure.UserSettings -{ - public record ShortCutModel(string Key, string Value) - { - } -} diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 7706db614..f6e76bb22 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -17,6 +17,7 @@ using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Storage; using Flow.Launcher.Infrastructure.Logger; using Microsoft.VisualStudio.Threading; +using System.Text; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; using System.IO; @@ -317,9 +318,9 @@ namespace Flow.Launcher.ViewModel #region ViewModel Properties public ResultsViewModel Results { get; private set; } - + public ResultsViewModel ContextMenu { get; private set; } - + public ResultsViewModel History { get; private set; } public bool GameModeStatus { get; set; } @@ -553,14 +554,16 @@ namespace Flow.Launcher.ViewModel return; } - string query = QueryText; + StringBuilder queryBuilder = new(QueryText); foreach (var shortcut in _settings.ShortCuts) { - if (QueryText == shortcut.Key) + if (queryBuilder.Equals(shortcut.Key)) { - query = shortcut.Value; + queryBuilder.Replace(shortcut.Key, shortcut.Value); } + + queryBuilder.Replace('@' + shortcut.Key, shortcut.Value); } _updateSource?.Dispose(); @@ -578,8 +581,8 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - - var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins); + + var query = QueryBuilder.Build(queryBuilder.ToString().Trim(), PluginManager.NonGlobalPlugins); // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 2096b43c6..70a11b2a6 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -19,6 +19,7 @@ using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; +using System.Collections.ObjectModel; namespace Flow.Launcher.ViewModel { @@ -117,7 +118,10 @@ namespace Flow.Launcher.ViewModel { var key = $"LastQuery{e}"; var display = _translater.GetTranslation(key); - var m = new LastQueryMode { Display = display, Value = e, }; + var m = new LastQueryMode + { + Display = display, Value = e, + }; modes.Add(m); } return modes; @@ -165,12 +169,17 @@ namespace Flow.Launcher.ViewModel } } - public List OpenResultModifiersList => new List { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" }; + public List OpenResultModifiersList => new List + { + KeyConstant.Alt, + KeyConstant.Ctrl, + $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" + }; private Internationalization _translater => InternationalizationManager.Instance; public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); - public List ShortCuts => Settings.ShortCuts; + public ObservableCollection> ShortCuts => Settings.ShortCuts; public string TestProxy() { @@ -230,7 +239,10 @@ namespace Flow.Launcher.ViewModel var metadatas = PluginManager.AllPlugins .OrderBy(x => x.Metadata.Disabled) .ThenBy(y => y.Metadata.Name) - .Select(p => new PluginViewModel { PluginPair = p }) + .Select(p => new PluginViewModel + { + PluginPair = p + }) .ToList(); return metadatas; } @@ -269,8 +281,6 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(ExternalPlugins)); } - - #endregion #region theme @@ -284,7 +294,7 @@ namespace Flow.Launcher.ViewModel { Settings.Theme = value; ThemeManager.Instance.ChangeTheme(value); - + if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect) DropShadowEffect = false; } @@ -333,7 +343,10 @@ namespace Flow.Launcher.ViewModel { var key = $"ColorScheme{e}"; var display = _translater.GetTranslation(key); - var m = new ColorScheme { Display = display, Value = e, }; + var m = new ColorScheme + { + Display = display, Value = e, + }; modes.Add(m); } return modes; @@ -376,7 +389,10 @@ namespace Flow.Launcher.ViewModel bitmap.BeginInit(); bitmap.StreamSource = memStream; bitmap.EndInit(); - var brush = new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill }; + var brush = new ImageBrush(bitmap) + { + Stretch = Stretch.UniformToFill + }; return brush; } else @@ -404,19 +420,19 @@ namespace Flow.Launcher.ViewModel { Title = "WebSearch", SubTitle = "Search the web with different search engine support", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.WebSearch\Images\web_search.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.WebSearch\Images\web_search.png") }, new Result { Title = "Program", SubTitle = "Launch programs as admin or a different user", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Program\Images\program.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Program\Images\program.png") }, new Result { Title = "ProcessKiller", SubTitle = "Terminate unwanted processes", - IcoPath =Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png") + IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png") } }; var vm = new ResultsViewModel(Settings); @@ -430,8 +446,8 @@ namespace Flow.Launcher.ViewModel get { if (Fonts.SystemFontFamilies.Count(o => - o.FamilyNames.Values != null && - o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0) + o.FamilyNames.Values != null && + o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0) { var font = new FontFamily(Settings.QueryBoxFont); return font; @@ -458,7 +474,7 @@ namespace Flow.Launcher.ViewModel Settings.QueryBoxFontStyle, Settings.QueryBoxFontWeight, Settings.QueryBoxFontStretch - )); + )); return typeface; } set @@ -475,8 +491,8 @@ namespace Flow.Launcher.ViewModel get { if (Fonts.SystemFontFamilies.Count(o => - o.FamilyNames.Values != null && - o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0) + o.FamilyNames.Values != null && + o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0) { var font = new FontFamily(Settings.ResultFont); return font; @@ -503,7 +519,7 @@ namespace Flow.Launcher.ViewModel Settings.ResultFontStyle, Settings.ResultFontWeight, Settings.ResultFontStretch - )); + )); return typeface; } set @@ -534,6 +550,7 @@ namespace Flow.Launcher.ViewModel public string Github => Constant.GitHub; public static string Version => Constant.Version; public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); + #endregion } -} +} \ No newline at end of file From 4d42e52dc1249a45d7e7b569e6a9036c1ed5fa74 Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 2 Mar 2022 06:49:54 +0900 Subject: [PATCH 006/235] - Move the 'Shorcut' to Hotkey tab from General - Adjust Layout --- Flow.Launcher/SettingWindow.xaml | 371 +++++++++++++++++-------------- 1 file changed, 207 insertions(+), 164 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 0cb2343bc..2fe5d2353 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -875,31 +875,6 @@ SelectedValuePath="LanguageCode" /> - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2026,11 +2001,8 @@ - - - - + - - - - - - - + + + + + + + + + + + +  + + + + + + + - -  - - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs new file mode 100644 index 000000000..feea064a4 --- /dev/null +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -0,0 +1,52 @@ +using Flow.Launcher.Core.Resource; +using Flow.Launcher.Helper; +using Flow.Launcher.Infrastructure.UserSettings; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using System.Windows.Controls; +using System.Collections.Generic; + +namespace Flow.Launcher +{ + public partial class CustomShortcutSetting : Window + { + private SettingWindow _settingWidow; + private bool update; + private CustomPluginHotkey updateCustomHotkey; + private Settings _settings; + + public string Key { get; set; } + public string Value { get; set; } + public ShortCutModel ShortCut => (Key, Value); + public CustomShortcutSetting() + { + InitializeComponent(); + } + + public CustomShortcutSetting((string, string) shortcut) + { + (Key, Value) = shortcut; + InitializeComponent(); + } + + private void BtnCancel_OnClick(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + + private void btnAdd_OnClick(object sender, RoutedEventArgs e) + { + DialogResult = true; + Close(); + } + + private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e) + { + DialogResult = false; + Close(); + } + } +} diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 35a6389ca..ef0bc4f14 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -12,6 +12,7 @@ false false en + false diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 25de530bc..401f532a2 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -115,6 +115,8 @@ Show result selection hotkey with results. Custom Query Hotkey Query + Shortcut + Expanded Delete Edit Add diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 2fe5d2353..47933f326 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2159,7 +2159,7 @@ diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index 25ce82424..292288473 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -34,9 +34,9 @@ namespace Flow.Launcher Close(); } - private void btnAdd_OnClick(object sender, RoutedEventArgs e) + private void BtnAdd_OnClick(object sender, RoutedEventArgs e) { - if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value))) + if (!update && (_settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)) || _settings.BuiltinShortcuts.Contains(new CustomShortcutModel(Key, Value)))) { MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut")); return; diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index dc290ccd6..f15de6afe 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2223,7 +2223,7 @@ - - + + - - - From 3c1451e319000ff3ef118b5f974ef42caf129074 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 8 Nov 2022 15:58:17 +0900 Subject: [PATCH 161/235] Change Plugin Store Icon Image Rendermode --- Flow.Launcher/SettingWindow.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 668269461..1892a62d3 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1608,6 +1608,7 @@ Height="32" Margin="18,24,0,0" HorizontalAlignment="Left" + RenderOptions.BitmapScalingMode="Fant" Source="{Binding IcoPath, IsAsync=True}" /> Date: Tue, 8 Nov 2022 18:45:58 +0900 Subject: [PATCH 162/235] Remove unused method --- Flow.Launcher/SettingWindow.xaml.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index dfddd137b..5634bb507 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -428,9 +428,6 @@ namespace Flow.Launcher } } - private void ShowStoreItem_Click(object sender, RoutedEventArgs e) - { - } private void RefreshPluginStoreEventHandler(object sender, RoutedEventArgs e) { if (pluginStoreFilterTxb.Text != lastPluginStoreSearch) From 6e76d87f6636148a209a434718ab70dc085c5a61 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 8 Nov 2022 19:34:40 +0900 Subject: [PATCH 163/235] Add VirtualPanel in other scrollviews --- Flow.Launcher/SettingWindow.xaml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 86f740d78..1ebe69e80 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -607,7 +607,8 @@ + ScrollViewer.CanContentScroll="False" + VirtualizingStackPanel.IsVirtualizing="True"> -  +  + - From 8bac95db662251d579b3c64817d6cbb469f1ddf9 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 18 Nov 2022 01:16:57 +0800 Subject: [PATCH 214/235] fix typo --- Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml | 2 +- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index ec9b41889..6d9f916e1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -61,7 +61,7 @@ Insert file suffixes you want to index. Suffixes should be separated by ';'. (ex>bat;py) - Insert protocols of .url files you want to index. Protocols should be separated by ';', and should end with "//". (ex>ftp://;mailto://) + Insert protocols of .url files you want to index. Protocols should be separated by ';', and should end with "://". (ex>ftp://;mailto://) Run As Different User diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index ac425e092..2b4e81bc4 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -387,7 +387,7 @@ namespace Flow.Launcher.Plugin.Program.Programs } } - private static IEnumerable EnmuerateProgramsInDir(string directory, string[] suffixes, bool recursive = true) + private static IEnumerable EnumerateProgramsInDir(string directory, string[] suffixes, bool recursive = true) { if (!Directory.Exists(directory)) return Enumerable.Empty(); @@ -416,7 +416,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { // Disabled custom sources are not in DisabledProgramSources var paths = directories.AsParallel() - .SelectMany(s => EnmuerateProgramsInDir(s, suffixes)); + .SelectMany(s => EnumerateProgramsInDir(s, suffixes)); // Remove disabled programs in DisabledProgramSources var programs = ExceptDisabledSource(paths).Select(x => GetProgramFromPath(x, protocols)); @@ -427,8 +427,8 @@ namespace Flow.Launcher.Plugin.Program.Programs { var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); - var paths1 = EnmuerateProgramsInDir(directory1, suffixes); - var paths2 = EnmuerateProgramsInDir(directory2, suffixes); + var paths1 = EnumerateProgramsInDir(directory1, suffixes); + var paths2 = EnumerateProgramsInDir(directory2, suffixes); var toFilter = paths1.Concat(paths2); @@ -449,7 +449,7 @@ namespace Flow.Launcher.Plugin.Program.Programs paths = paths.Where(x => commonParents.All(parent => !x.StartsWith(parent, StringComparison.OrdinalIgnoreCase))); - var toFilter = paths.AsParallel().SelectMany(p => EnmuerateProgramsInDir(p, suffixes, recursive: false)); + var toFilter = paths.AsParallel().SelectMany(p => EnumerateProgramsInDir(p, suffixes, recursive: false)); var programs = ExceptDisabledSource(toFilter.Distinct()) .Select(x => GetProgramFromPath(x, protocols)); From db8ba91558c88525836464723db9d35155cca253 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 18 Nov 2022 01:39:42 +0800 Subject: [PATCH 215/235] Fix subpath --- .../Programs/Win32.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 2b4e81bc4..d9c26435a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -737,6 +737,17 @@ namespace Flow.Launcher.Plugin.Program.Programs } } + // https://stackoverflow.com/a/66877016 + private static bool IsSubPathOf(string subPath, string basePath) + { + var rel = Path.GetRelativePath(basePath, subPath); + return rel != "." + && rel != ".." + && !rel.StartsWith("../") + && !rel.StartsWith(@"..\") + && !Path.IsPathRooted(rel); + } + private static List GetCommonParents(IEnumerable programSources) { // To avoid unnecessary io @@ -748,8 +759,8 @@ namespace Flow.Launcher.Plugin.Program.Programs HashSet parents = group.ToHashSet(); foreach (var source in group) { - if (parents.Any(p => source.Location.StartsWith(p.Location, StringComparison.OrdinalIgnoreCase) && - source != p)) + if (parents.Any(p => IsSubPathOf(source.Location, p.Location) && + source != p)) // TODO startwith not accurate { parents.Remove(source); } From 9dcf030e8abfa3405dee158c4defd51fe41c0090 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 18 Nov 2022 01:42:15 +0800 Subject: [PATCH 216/235] formatting --- .../Flow.Launcher.Plugin.Program/Programs/Win32.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index d9c26435a..25ac2b213 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -440,9 +440,9 @@ namespace Flow.Launcher.Plugin.Program.Programs private static IEnumerable PATHPrograms(string[] suffixes, string[] protocols, List commonParents) { var pathEnv = Environment.GetEnvironmentVariable("Path"); - if (String.IsNullOrEmpty(pathEnv)) - { - return Array.Empty(); + if (String.IsNullOrEmpty(pathEnv)) + { + return Array.Empty(); } var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant()); @@ -722,7 +722,8 @@ namespace Flow.Launcher.Plugin.Program.Programs watcher.Deleted += static (_, _) => indexQueue.Writer.TryWrite(default); watcher.EnableRaisingEvents = true; watcher.IncludeSubdirectories = true; - foreach(var extension in extensions) { + foreach (var extension in extensions) + { watcher.Filters.Add($"*.{extension}"); } @@ -760,7 +761,7 @@ namespace Flow.Launcher.Plugin.Program.Programs foreach (var source in group) { if (parents.Any(p => IsSubPathOf(source.Location, p.Location) && - source != p)) // TODO startwith not accurate + source != p)) { parents.Remove(source); } From 9be732279f5fdee33afc9a8740ef48955a655feb Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 03:13:44 +0900 Subject: [PATCH 217/235] Add icons / Change "Flow Launcher Settings" to "Settings" in context menu --- Flow.Launcher/Languages/en.xaml | 2 +- Flow.Launcher/MainWindow.xaml | 12 ++++++++++-- Flow.Launcher/MainWindow.xaml.cs | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 9d21a5d5c..b9f65a58c 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -27,7 +27,7 @@ Reset search window position - Flow Launcher Settings + Settings General Portable Mode Store all settings and user data in one folder (Useful when used with removable drives or cloud services). diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index db798087f..3bf855da7 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -229,8 +229,16 @@ Margin="0" Padding="0,4,0,4" Background="{DynamicResource ContextSeparator}" /> - - + + + + + + + + + + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 7095ed24f..747509d77 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -256,9 +256,11 @@ namespace Flow.Launcher Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon }; + var positionresetIcon = new FontIcon { Glyph = "\ue73f" }; var positionreset = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("PositionReset") + Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), + Icon = positionresetIcon }; var settingsIcon = new FontIcon { Glyph = "\ue713" }; var settings = new MenuItem From 07a69da0c245a8072f464d6b11caff54130727cb Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Fri, 18 Nov 2022 13:40:13 +1100 Subject: [PATCH 218/235] allow branch builds and do not skip md files --- appveyor.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1e15bd159..aa490fd25 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,12 +22,6 @@ assembly_info: assembly_file_version: $(flowVersion) assembly_informational_version: $(flowVersion) -skip_branch_with_pr: true - -skip_commits: - files: - - '*.md' - image: Visual Studio 2022 platform: Any CPU configuration: Release From 4845e35d712d03c1cb0162d47c5a284685773601 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 18 Nov 2022 12:11:24 +0800 Subject: [PATCH 219/235] Fix subpath detection in PATH --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 25ac2b213..8ba40b881 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -447,9 +447,9 @@ namespace Flow.Launcher.Plugin.Program.Programs var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant()); - paths = paths.Where(x => commonParents.All(parent => !x.StartsWith(parent, StringComparison.OrdinalIgnoreCase))); - - var toFilter = paths.AsParallel().SelectMany(p => EnumerateProgramsInDir(p, suffixes, recursive: false)); + var toFilter = paths.Where(x => commonParents.All(parent => !IsSubPathOf(x, parent))) + .AsParallel() + .SelectMany(p => EnumerateProgramsInDir(p, suffixes, recursive: false)); var programs = ExceptDisabledSource(toFilter.Distinct()) .Select(x => GetProgramFromPath(x, protocols)); From 087df5143ef57f564bef3f783c39e2c05cf6b827 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 13:26:29 +0900 Subject: [PATCH 220/235] Changed ActionKeywordWindow to Responsive (Explorer Plugin) --- .../Views/ActionKeywordSetting.xaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml index 195fc7df9..8397145cf 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml @@ -6,12 +6,13 @@ xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Title="{DynamicResource plugin_explorer_manageactionkeywords_header}" - Width="400" - SizeToContent="Height" + Width="Auto" + Height="255" Background="{DynamicResource PopuBGColor}" DataContext="{Binding RelativeSource={RelativeSource Self}}" Foreground="{DynamicResource PopupTextColor}" ResizeMode="NoResize" + SizeToContent="Width" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> @@ -68,7 +69,7 @@ - Date: Fri, 18 Nov 2022 13:57:09 +0900 Subject: [PATCH 221/235] Changed Icons(about) label to string --- Flow.Launcher/Languages/en.xaml | 1 + Flow.Launcher/SettingWindow.xaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index b9f65a58c..e3312d788 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -188,6 +188,7 @@ Github Docs Version + Icons You have activated Flow Launcher {0} times Check for Updates New version {0} is available, would you like to restart Flow Launcher to use the update? diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 636d2d4cd..097da029f 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2922,7 +2922,7 @@ Style="{DynamicResource SettingGroupBox}"> - + Date: Fri, 18 Nov 2022 14:43:28 +0900 Subject: [PATCH 222/235] Adjust Context Menu Hover/Click Colors --- Flow.Launcher/Resources/CustomControlTemplate.xaml | 4 ++-- Flow.Launcher/Resources/Dark.xaml | 3 ++- Flow.Launcher/Resources/Light.xaml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/Resources/CustomControlTemplate.xaml b/Flow.Launcher/Resources/CustomControlTemplate.xaml index 70fe02c95..50c7cf612 100644 --- a/Flow.Launcher/Resources/CustomControlTemplate.xaml +++ b/Flow.Launcher/Resources/CustomControlTemplate.xaml @@ -2956,13 +2956,13 @@ - + - + diff --git a/Flow.Launcher/Resources/Dark.xaml b/Flow.Launcher/Resources/Dark.xaml index 674e04deb..a5eec29ab 100644 --- a/Flow.Launcher/Resources/Dark.xaml +++ b/Flow.Launcher/Resources/Dark.xaml @@ -65,7 +65,8 @@ - + + diff --git a/Flow.Launcher/Resources/Light.xaml b/Flow.Launcher/Resources/Light.xaml index 8b04196dd..a78b14d65 100644 --- a/Flow.Launcher/Resources/Light.xaml +++ b/Flow.Launcher/Resources/Light.xaml @@ -58,7 +58,8 @@ - + + From 65920a50a5330148917a697fc96d12cde4fe3e66 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 15:28:16 +0900 Subject: [PATCH 223/235] Fix ProgramSetting's Button Area --- .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 227c23ebc..74c29576e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -11,7 +11,7 @@ - + @@ -145,8 +145,8 @@ DragEnter="programSourceView_DragEnter" Drop="programSourceView_Drop" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler" - PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp" MouseDoubleClick="programSourceView_MouseDoubleClick" + PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp" SelectionChanged="programSourceView_SelectionChanged" SelectionMode="Extended"> From 24d255a56df78437e255dc7f3a0c660ba35d2b1d Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:32:53 +0800 Subject: [PATCH 224/235] Change spell of plugin --- Flow.Launcher/Languages/en.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index f393af119..1b751eac3 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -105,9 +105,9 @@ Install Uninstall Update - Plug-in already installed + Plugin already installed New Version - This plug-in has been updated within the last 7 days + This plugin has been updated within the last 7 days New Update is Available From c57a2be5f0edee85fbb888767326c517dbea384f Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 16:07:43 +0900 Subject: [PATCH 225/235] Adjust Button Template --- Flow.Launcher/Resources/CustomControlTemplate.xaml | 3 ++- Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Resources/CustomControlTemplate.xaml b/Flow.Launcher/Resources/CustomControlTemplate.xaml index 50c7cf612..07897361c 100644 --- a/Flow.Launcher/Resources/CustomControlTemplate.xaml +++ b/Flow.Launcher/Resources/CustomControlTemplate.xaml @@ -1407,7 +1407,8 @@ Padding="{TemplateBinding Padding}" BorderBrush="{DynamicResource ButtonInsideBorder}" BorderThickness="{DynamicResource CustomButtonInsideBorderThickness}" - CornerRadius="4"> + CornerRadius="4" + SnapsToDevicePixels="True"> - + From 16abd9d4f0443b04b438cac5dce37c0ae6e9a435 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 16:22:19 +0900 Subject: [PATCH 226/235] Fix Button Moving in programSetting panel --- Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 387ed905e..3f9e7196c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -91,6 +91,7 @@ BorderThickness="1" /> From 4ba027d5e26f9158422e121e5e785447019e54c8 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 18:12:10 +0900 Subject: [PATCH 227/235] Adjust Center Line --- .../ProgramSuffixes.xaml | 53 ++++++++++++++----- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml index fbe538b7f..e4467a8b6 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml @@ -8,8 +8,8 @@ Title="{DynamicResource flowlauncher_plugin_program_suffixes}" Width="600" Background="{DynamicResource PopuBGColor}" - Foreground="{DynamicResource PopupTextColor}" DataContext="{Binding RelativeSource={RelativeSource Self}}" + Foreground="{DynamicResource PopupTextColor}" ResizeMode="NoResize" SizeToContent="Height" WindowStartupLocation="CenterScreen" @@ -163,17 +163,32 @@ FontSize="16" FontWeight="SemiBold" Text="{DynamicResource flowlauncher_plugin_program_suffixes_excutable_types}" /> - appref-ms - exe - lnk + + appref-ms + + + exe + + + lnk + + Content="{DynamicResource flowlauncher_plugin_program_suffixes_custom_file_types}" + IsChecked="{Binding UseCustomSuffixes}" /> @@ -189,17 +204,29 @@ FontSize="16" FontWeight="SemiBold" Text="{DynamicResource flowlauncher_plugin_program_suffixes_URL_types}" /> - - - + + + + Content="{DynamicResource flowlauncher_plugin_program_suffixes_custom_urls}" + IsChecked="{Binding UseCustomProtocols}" /> From 48aaf3a7db730a49bcec473eb6b38086364a765b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 18 Nov 2022 23:15:02 -0600 Subject: [PATCH 228/235] fix right click not working (and refactor left click) --- Flow.Launcher/MainWindow.xaml | 246 ++++++++++---------- Flow.Launcher/MainWindow.xaml.cs | 22 -- Flow.Launcher/ResultListBox.xaml | 4 +- Flow.Launcher/ResultListBox.xaml.cs | 48 +++- Flow.Launcher/ViewModel/MainViewModel.cs | 31 +-- Flow.Launcher/ViewModel/ResultsViewModel.cs | 5 + 6 files changed, 192 insertions(+), 164 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 3bf855da7..17444aae8 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -1,5 +1,4 @@ - - - - - - + + + + - - - - - - - - - - - - + + - - - + + - - - - - - - - + - - - - - - - - - - - - + - - - - + + + - - + - + - + - + - - + - + @@ -243,23 +228,19 @@ - - - - - - - - - - + + + - + LeftClickResultCommand="{Binding LeftClickResultCommand}" + RightClickResultCommand="{Binding RightClickResultCommand}" /> - - - + + + - + LeftClickResultCommand="{Binding LeftClickResultCommand}" + RightClickResultCommand="{Binding RightClickResultCommand}" /> - - - + + + - + LeftClickResultCommand="{Binding LeftClickResultCommand}" + RightClickResultCommand="{Binding RightClickResultCommand}" /> diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 747509d77..10b22e33a 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -405,28 +405,6 @@ namespace Flow.Launcher if (e.ChangedButton == MouseButton.Left) DragMove(); } - private void OnPreviewMouseButtonDown(object sender, MouseButtonEventArgs e) - { - if (sender != null && e.OriginalSource != null) - { - var r = (ResultListBox)sender; - var d = (DependencyObject)e.OriginalSource; - var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem; - var result = (ResultViewModel)item?.DataContext; - if (result != null) - { - if (e.ChangedButton == MouseButton.Left) - { - _viewModel.OpenResultCommand.Execute(null); - } - else if (e.ChangedButton == MouseButton.Right) - { - _viewModel.LoadContextMenuCommand.Execute(null); - } - } - } - } - private void OnPreviewDragOver(object sender, DragEventArgs e) { e.Handled = true; diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index 1ece390d1..d6cf3462b 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -27,7 +27,9 @@ Visibility="{Binding Visbility}" mc:Ignorable="d" PreviewMouseMove="ResultList_MouseMove" - PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown"> + PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown" + PreviewMouseLeftButtonUp="ResultListBox_OnPreviewMouseUp" + PreviewMouseRightButtonDown="ResultListBox_OnPreviewMouseRightButtonDown"> diff --git a/Flow.Launcher/ResultListBox.xaml.cs b/Flow.Launcher/ResultListBox.xaml.cs index d1415f8ab..6bd1490c3 100644 --- a/Flow.Launcher/ResultListBox.xaml.cs +++ b/Flow.Launcher/ResultListBox.xaml.cs @@ -17,6 +17,36 @@ namespace Flow.Launcher InitializeComponent(); } + public static readonly DependencyProperty RightClickResultCommandProperty = + DependencyProperty.Register("RightClickResultCommand", typeof(ICommand), typeof(ResultListBox), new UIPropertyMetadata(null)); + + public ICommand RightClickResultCommand + { + get + { + return (ICommand)GetValue(RightClickResultCommandProperty); + } + set + { + SetValue(RightClickResultCommandProperty, value); + } + } + + public static readonly DependencyProperty LeftClickResultCommandProperty = + DependencyProperty.Register("LeftClickResultCommand", typeof(ICommand), typeof(ResultListBox), new UIPropertyMetadata(null)); + + public ICommand LeftClickResultCommand + { + get + { + return (ICommand)GetValue(LeftClickResultCommandProperty); + } + set + { + SetValue(LeftClickResultCommandProperty, value); + } + } + private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) @@ -98,10 +128,24 @@ namespace Flow.Launcher path }); DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy); - + App.API.ChangeQuery(query, true); - + e.Handled = true; } + private void ResultListBox_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result }) + return; + + RightClickResultCommand?.Execute(result.Result); + } + private void ResultListBox_OnPreviewMouseUp(object sender, MouseButtonEventArgs e) + { + if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result }) + return; + + LeftClickResultCommand?.Execute(null); + } } } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 73be0bbed..99d2a0990 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -77,12 +77,22 @@ namespace Flow.Launcher.ViewModel _userSelectedRecord = _userSelectedRecordStorage.Load(); _topMostRecord = _topMostRecordStorage.Load(); - ContextMenu = new ResultsViewModel(Settings); - Results = new ResultsViewModel(Settings); - History = new ResultsViewModel(Settings); + InitializeKeyCommands(); + + ContextMenu = new ResultsViewModel(Settings) + { + LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + }; + Results = new ResultsViewModel(Settings) + { + LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + }; + History = new ResultsViewModel(Settings) + { + LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand + }; _selectedResults = Results; - InitializeKeyCommands(); RegisterViewUpdate(); RegisterResultsUpdatedEvent(); @@ -199,15 +209,10 @@ namespace Flow.Launcher.ViewModel PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); }); OpenSettingCommand = new RelayCommand(_ => { App.API.OpenSettingDialog(); }); - OpenResultCommand = new RelayCommand(async index => + OpenResultCommand = new AsyncRelayCommand(async _ => { var results = SelectedResults; - if (index != null) - { - results.SelectedIndex = int.Parse(index.ToString()!); - } - var result = results.SelectedItem?.Result; if (result == null) { @@ -363,9 +368,9 @@ namespace Flow.Launcher.ViewModel { if (MainWindowWidth + 100 > 1920 || Settings.WindowSize == 1920) { - Settings.WindowSize = 1920; + Settings.WindowSize = 1920; } - else + else { Settings.WindowSize += 100; Settings.WindowLeft -= 50; @@ -648,7 +653,7 @@ namespace Flow.Launcher.ViewModel if (currentCancellationToken.IsCancellationRequested) return; - + // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); diff --git a/Flow.Launcher/ViewModel/ResultsViewModel.cs b/Flow.Launcher/ViewModel/ResultsViewModel.cs index db24825d0..1820ea56b 100644 --- a/Flow.Launcher/ViewModel/ResultsViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultsViewModel.cs @@ -8,6 +8,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; +using System.Windows.Input; +using JetBrains.Annotations; namespace Flow.Launcher.ViewModel { @@ -49,6 +51,9 @@ namespace Flow.Launcher.ViewModel public ResultViewModel SelectedItem { get; set; } public Thickness Margin { get; set; } public Visibility Visbility { get; set; } = Visibility.Collapsed; + + public ICommand RightClickResultCommand { get; init; } + public ICommand LeftClickResultCommand { get; init; } #endregion From 337e6ca4270071157d330785d9f76983f0f62990 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 18 Nov 2022 23:31:17 -0600 Subject: [PATCH 229/235] use Enabled and showtooltipondisabled to show tooltip --- Flow.Launcher/ResultListBox.xaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index d6cf3462b..691158630 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -139,10 +139,11 @@ x:Name="Title" VerticalAlignment="Center" DockPanel.Dock="Left" - IsHitTestVisible="False" Style="{DynamicResource ItemTitleStyle}" Text="{Binding Result.Title}" - ToolTip="{Binding ShowTitleToolTip}"> + ToolTip="{Binding ShowTitleToolTip}" + ToolTipService.ShowOnDisabled="True" + IsEnabled="False"> @@ -153,11 +154,11 @@ - + ToolTip="{Binding ShowSubTitleToolTip}"/> From e5d95f36b3a69ab619397fdaf4a51234e9c8e2a3 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 19 Nov 2022 12:08:32 -0600 Subject: [PATCH 230/235] refactor relaycommands with mvvmtoolkit sourcegenerator to prevent potential null reference --- Flow.Launcher/ViewModel/MainViewModel.cs | 302 +++++++++++------------ 1 file changed, 142 insertions(+), 160 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 99d2a0990..85119fee1 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -77,7 +77,6 @@ namespace Flow.Launcher.ViewModel _userSelectedRecord = _userSelectedRecordStorage.Load(); _topMostRecord = _topMostRecordStorage.Load(); - InitializeKeyCommands(); ContextMenu = new ResultsViewModel(Settings) { @@ -167,160 +166,161 @@ namespace Flow.Launcher.ViewModel } } - - - private void InitializeKeyCommands() + [RelayCommand] + private async Task ReloadPluginDataAsync() { - EscCommand = new RelayCommand(_ => + Hide(); + + await PluginManager.ReloadDataAsync().ConfigureAwait(false); + Notification.Show(InternationalizationManager.Instance.GetTranslation("success"), InternationalizationManager.Instance.GetTranslation("completedSuccessfully")); + } + [RelayCommand] + private void LoadHistory() + { + if (SelectedIsFromQueryResults()) { - if (!SelectedIsFromQueryResults()) - { - SelectedResults = Results; - } - else - { - Hide(); - } - }); - - ClearQueryCommand = new RelayCommand(_ => + SelectedResults = History; + History.SelectedIndex = _history.Items.Count - 1; + } + else { - if (!string.IsNullOrEmpty(QueryText)) - { - ChangeQueryText(string.Empty); - - // Push Event to UI SystemQuery has changed - //OnPropertyChanged(nameof(SystemQueryText)); - } - }); - - SelectNextItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextResult(); }); - - SelectPrevItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevResult(); }); - - SelectNextPageCommand = new RelayCommand(_ => { SelectedResults.SelectNextPage(); }); - - SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); }); - - SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult()); - - StartHelpCommand = new RelayCommand(_ => + SelectedResults = Results; + } + } + [RelayCommand] + private void LoadContextMenu() + { + if (SelectedIsFromQueryResults()) { - PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); - }); - OpenSettingCommand = new RelayCommand(_ => { App.API.OpenSettingDialog(); }); - OpenResultCommand = new AsyncRelayCommand(async _ => + // When switch to ContextMenu from QueryResults, but no item being chosen, should do nothing + // i.e. Shift+Enter/Ctrl+O right after Alt + Space should do nothing + if (SelectedResults.SelectedItem != null) + SelectedResults = ContextMenu; + } + else { - var results = SelectedResults; + SelectedResults = Results; + } + } + [RelayCommand] + private void Backspace(object index) + { + var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins); - var result = results.SelectedItem?.Result; - if (result == null) + // 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}"); + } + [RelayCommand] + private void AutocompleteQuery() + { + var result = SelectedResults.SelectedItem?.Result; + if (result != null && SelectedIsFromQueryResults()) // SelectedItem returns null if selection is empty. + { + var autoCompleteText = result.Title; + + if (!string.IsNullOrEmpty(result.AutoCompleteText)) { - return; + autoCompleteText = result.AutoCompleteText; } - var hideWindow = await result.ExecuteAsync(new ActionContext + else if (!string.IsNullOrEmpty(SelectedResults.SelectedItem?.QuerySuggestionText)) + { + autoCompleteText = SelectedResults.SelectedItem.QuerySuggestionText; + } + + var specialKeyState = GlobalHotkey.CheckModifiers(); + if (specialKeyState.ShiftPressed) + { + autoCompleteText = result.SubTitle; + } + + ChangeQueryText(autoCompleteText); + } + } + [RelayCommand] + private async Task OpenResult() + { + var results = SelectedResults; + + var result = results.SelectedItem?.Result; + if (result == null) + { + return; + } + var hideWindow = await result.ExecuteAsync(new ActionContext { SpecialKeyState = GlobalHotkey.CheckModifiers() - }).ConfigureAwait(false); + }) + .ConfigureAwait(false); - if (hideWindow) - { - Hide(); - } - - if (SelectedIsFromQueryResults()) - { - _userSelectedRecord.Add(result); - _history.Add(result.OriginQuery.RawQuery); - } - else - { - SelectedResults = Results; - } - }); - - AutocompleteQueryCommand = new RelayCommand(_ => - { - var result = SelectedResults.SelectedItem?.Result; - if (result != null && SelectedIsFromQueryResults()) // SelectedItem returns null if selection is empty. - { - var autoCompleteText = result.Title; - - if (!string.IsNullOrEmpty(result.AutoCompleteText)) - { - autoCompleteText = result.AutoCompleteText; - } - else if (!string.IsNullOrEmpty(SelectedResults.SelectedItem?.QuerySuggestionText)) - { - autoCompleteText = SelectedResults.SelectedItem.QuerySuggestionText; - } - - var specialKeyState = GlobalHotkey.CheckModifiers(); - if (specialKeyState.ShiftPressed) - { - autoCompleteText = result.SubTitle; - } - - ChangeQueryText(autoCompleteText); - } - }); - - 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()) - { - // When switch to ContextMenu from QueryResults, but no item being chosen, should do nothing - // i.e. Shift+Enter/Ctrl+O right after Alt + Space should do nothing - if (SelectedResults.SelectedItem != null) - SelectedResults = ContextMenu; - } - else - { - SelectedResults = Results; - } - }); - - LoadHistoryCommand = new RelayCommand(_ => - { - if (SelectedIsFromQueryResults()) - { - SelectedResults = History; - History.SelectedIndex = _history.Items.Count - 1; - } - else - { - SelectedResults = Results; - } - }); - - ReloadPluginDataCommand = new RelayCommand(_ => + if (hideWindow) { Hide(); + } - _ = PluginManager - .ReloadDataAsync() - .ContinueWith(_ => - Application.Current.Dispatcher.Invoke(() => - { - Notification.Show( - InternationalizationManager.Instance.GetTranslation("success"), - InternationalizationManager.Instance.GetTranslation("completedSuccessfully") - ); - }), TaskScheduler.Default) - .ConfigureAwait(false); - }); + if (SelectedIsFromQueryResults()) + { + _userSelectedRecord.Add(result); + _history.Add(result.OriginQuery.RawQuery); + } + else + { + SelectedResults = Results; + } + } + [RelayCommand] + private void OpenSetting() + { + App.API.OpenSettingDialog(); + } + + [RelayCommand] + private void SelectHelp() + { + PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); + } + + [RelayCommand] + private void SelectFirstResult() + { + SelectedResults.SelectFirstResult(); + } + [RelayCommand] + private void SelectPrevPage() + { + SelectedResults.SelectPrevPage(); + } + + [RelayCommand] + private void SelectNextPage() + { + SelectedResults.SelectNextPage(); + } + [RelayCommand] + private void SelectPrevItem() + { + SelectedResults.SelectPrevResult(); + } + [RelayCommand] + private void SelectNextItem() + { + SelectedResults.SelectNextResult(); + } + + [RelayCommand] + private void Esc() + { + if (!SelectedIsFromQueryResults()) + { + SelectedResults = Results; + } + else + { + Hide(); + } } #endregion @@ -416,6 +416,7 @@ namespace Flow.Launcher.ViewModel /// but we don't want to move cursor to end when query is updated from TextBox /// /// + /// Force query even when Query Text doesn't change public void ChangeQueryText(string queryText, bool reQuery = false) { if (QueryText != queryText) @@ -494,25 +495,6 @@ 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; } - public ICommand SelectPrevPageCommand { get; set; } - public ICommand SelectFirstResultCommand { get; set; } - public ICommand StartHelpCommand { get; set; } - public ICommand LoadContextMenuCommand { get; set; } - public ICommand LoadHistoryCommand { get; set; } - public ICommand OpenResultCommand { get; set; } - 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; } public string Image => Constant.QueryTextBoxIconImagePath; From 1b51a461dce886902e375ed233061344b38b0e17 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 21 Nov 2022 18:05:35 +0800 Subject: [PATCH 231/235] Use path of lnk to execute program --- .../Flow.Launcher.Plugin.Program/Programs/Win32.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 8ba40b881..cbf9d27ab 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -37,7 +37,6 @@ namespace Flow.Launcher.Plugin.Program.Programs /// Path of the actual executable file. /// public string ExecutablePath => LnkResolvedPath ?? FullPath; - public string WorkingDir => Directory.GetParent(ExecutablePath)?.FullName ?? string.Empty; public string ParentDirectory { get; set; } public string ExecutableName { get; set; } public string Description { get; set; } @@ -140,8 +139,8 @@ namespace Flow.Launcher.Plugin.Program.Programs var info = new ProcessStartInfo { - FileName = ExecutablePath, - WorkingDirectory = WorkingDir, + FileName = FullPath, + WorkingDirectory = ParentDirectory, UseShellExecute = true, Verb = runAsAdmin ? "runas" : null }; @@ -167,8 +166,8 @@ namespace Flow.Launcher.Plugin.Program.Programs { var info = new ProcessStartInfo { - FileName = ExecutablePath, - WorkingDirectory = WorkingDir, + FileName = FullPath, + WorkingDirectory = ParentDirectory, UseShellExecute = true }; @@ -187,7 +186,7 @@ namespace Flow.Launcher.Plugin.Program.Programs var info = new ProcessStartInfo { FileName = ExecutablePath, - WorkingDirectory = WorkingDir, + WorkingDirectory = ParentDirectory, Verb = "runas", UseShellExecute = true }; @@ -573,6 +572,7 @@ namespace Flow.Launcher.Plugin.Program.Programs private static IEnumerable ProgramsHasher(IEnumerable programs) { + // TODO: Unable to distinguish multiple lnks to the same excutable but with different params return programs.GroupBy(p => p.ExecutablePath.ToLowerInvariant()) .AsParallel() .SelectMany(g => From 626e8b1f42de92ae340b70b6cec80371667e0f24 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 21 Nov 2022 18:11:53 +0800 Subject: [PATCH 232/235] Eliminate warning --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index cbf9d27ab..d973185b2 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -220,8 +220,7 @@ namespace Flow.Launcher.Plugin.Program.Programs return Name; } - public static List Watchers = new List(); - + private static List Watchers = new List(); private static Win32 Win32Program(string path) { From 2b14d5b1400e1d322e493b5b0b4295120cca0d3a Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 21 Nov 2022 19:36:11 +0800 Subject: [PATCH 233/235] Distinguish .lnks by arguments --- .../Programs/ShellLinkHelper.cs | 11 +++++++---- .../Flow.Launcher.Plugin.Program/Programs/Win32.cs | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs index 72b7b0a91..b93fb23c9 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/ShellLinkHelper.cs @@ -97,8 +97,8 @@ namespace Flow.Launcher.Plugin.Program.Programs } // To initialize the app description - public String description = String.Empty; - + public string description = string.Empty; + public string arguments = string.Empty; // Retrieve the target path using Shell Link public string retrieveTargetPath(string path) @@ -122,13 +122,16 @@ namespace Flow.Launcher.Plugin.Program.Programs buffer = new StringBuilder(MAX_PATH); ((IShellLinkW)link).GetDescription(buffer, MAX_PATH); description = buffer.ToString(); + + buffer.Clear(); + ((IShellLinkW)link).GetArguments(buffer, MAX_PATH); + arguments = buffer.ToString(); } // To release unmanaged memory Marshal.ReleaseComObject(link); return target; - } } -} \ No newline at end of file +} diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index d973185b2..7fbffb548 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -26,11 +26,11 @@ namespace Flow.Launcher.Plugin.Program.Programs public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison public string IcoPath { get; set; } /// - /// Path of the file. It's the path of .lnk or .url for .lnk and .url. + /// Path of the file. It's the path of .lnk and .url for .lnk and .url files. /// public string FullPath { get; set; } /// - /// Path of the excutable for .lnk, or the URL for .url. + /// Path of the excutable for .lnk, or the URL for .url. Arguments are included if any. /// public string LnkResolvedPath { get; set; } /// @@ -185,7 +185,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { var info = new ProcessStartInfo { - FileName = ExecutablePath, + FileName = FullPath, WorkingDirectory = ParentDirectory, Verb = "runas", UseShellExecute = true @@ -275,6 +275,12 @@ namespace Flow.Launcher.Plugin.Program.Programs program.LnkResolvedPath = Path.GetFullPath(target); program.ExecutableName = Path.GetFileName(target); + var args = _helper.arguments; + if(!string.IsNullOrEmpty(args)) + { + program.LnkResolvedPath += " " + args; + } + var description = _helper.description; if (!string.IsNullOrEmpty(description)) { From bc28da71844a46cbb63c0fd50430a462791e6586 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 22 Nov 2022 11:24:35 -0600 Subject: [PATCH 234/235] fix result modifier not working --- Flow.Launcher/ViewModel/MainViewModel.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 85119fee1..a7dfd9874 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -241,10 +241,13 @@ namespace Flow.Launcher.ViewModel } } [RelayCommand] - private async Task OpenResult() + private async Task OpenResultAsync(string index) { var results = SelectedResults; - + if (index is not null) + { + results.SelectedIndex = int.Parse(index); + } var result = results.SelectedItem?.Result; if (result == null) { From 7ff29f63d83ba020833658c5eba0b7dca7de2f2e Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 23 Nov 2022 07:23:42 +1100 Subject: [PATCH 235/235] open documentation's usage tips page --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a7dfd9874..400437315 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -283,7 +283,7 @@ namespace Flow.Launcher.ViewModel [RelayCommand] private void SelectHelp() { - PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); + PluginManager.API.OpenUrl("https://www.flowlauncher.com/docs/#/usage-tips"); } [RelayCommand]