From efd34c980f7326ddc6b938a1f68d8bfea10fda79 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 Dec 2021 16:13:49 -0600 Subject: [PATCH 001/326] 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/326] 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/326] 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/326] 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/326] 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/326] - 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 190/326] 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 191/326] 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 192/326] 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 243/326] 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 244/326] 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 245/326] 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 246/326] 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 247/326] 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 248/326] 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 249/326] 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 250/326] 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 251/326] 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 252/326] 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 253/326] 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 254/326] 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 255/326] 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 256/326] 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 caf4d13d506a6b85f0d5ed1aac08c5ebb60b1293 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 20:52:15 +0900 Subject: [PATCH 257/326] Add Time Formats --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 65321e6ba..e7ef4da11 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -463,7 +463,10 @@ namespace Flow.Launcher.ViewModel "dd'/'MM", "ddd MM'/'dd", "dddd MM'/'dd", - "dddd" + "dddd", + "ddd dd'/MM'", + "dddd dd'/MM'" + }; public double WindowWidthSize From ddb5f898d39387ff2ea68d3860c1a6f87b61d2f4 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 21:08:39 +0900 Subject: [PATCH 258/326] Add timeformats --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index e7ef4da11..aa79248b8 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -464,8 +464,11 @@ namespace Flow.Launcher.ViewModel "ddd MM'/'dd", "dddd MM'/'dd", "dddd", - "ddd dd'/MM'", - "dddd dd'/MM'" + "ddd dd'/'MM", + "dddd dd'/'MM", + "dddd dd', 'MMMM", + "dddd DDDD', 'MMMM", + "dd', 'MMMM" }; From 9e8bf456c0cc4a9f611c5907625013fe70bef137 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 21:11:27 +0900 Subject: [PATCH 259/326] Formatting --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index aa79248b8..e6df8e4fd 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -467,9 +467,7 @@ namespace Flow.Launcher.ViewModel "ddd dd'/'MM", "dddd dd'/'MM", "dddd dd', 'MMMM", - "dddd DDDD', 'MMMM", "dd', 'MMMM" - }; public double WindowWidthSize From 7270c9f35d392e8f26bf2b3f53df810e48da9324 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 00:47:04 +0800 Subject: [PATCH 260/326] Display current time in time/date format combobox --- Flow.Launcher/SettingWindow.xaml | 8 ++-- Flow.Launcher/SettingWindow.xaml.cs | 11 +++++ .../ViewModel/SettingWindowViewModel.cs | 44 ++++++++++++++++++- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 5584983a9..6e2aa590c 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2169,8 +2169,8 @@ Margin="0,0,18,0" VerticalAlignment="Center" FontSize="14" - ItemsSource="{Binding TimeFormatList}" - SelectedValue="{Binding Settings.TimeFormat}" + ItemsSource="{Binding TimeFormatDisplayList}" + SelectedIndex="{Binding TimeFormatIndex, Mode=OneTime}" SelectionChanged="PreviewClockAndDate" /> x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; + DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; + + TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); + DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); + UpdateSettingsDateTimeFormat(); // just in case something wrong } public Settings Settings { get; set; } @@ -422,8 +430,6 @@ namespace Flow.Launcher.ViewModel } } - - public class SearchWindowPosition { public string Display { get; set; } @@ -470,6 +476,40 @@ namespace Flow.Launcher.ViewModel "dd', 'MMMM" }; + public int TimeFormatIndex { get; set; } = 0; + + public int DateFormatIndex { get; set; } = 0; + + public List TimeFormatDisplayList { get; set; } = null; + + public List DateFormatDisplayList { get; set; } = null; + + public void UpdateSettingsDateTimeFormat() + { + Settings.DateFormat = DateFormatList[DateFormatIndex]; + Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + } + + public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) + { + if (dateIndex == -1 || timeIndex == -1) + return; + DateFormatIndex = dateIndex; + TimeFormatIndex = timeIndex; + + for (int i = 0; i < TimeFormatList.Count; ++i) + { + TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); + } + + for (int i = 0; i < DateFormatList.Count; ++i) + { + DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); + } + + UpdateSettingsDateTimeFormat(); + } + public double WindowWidthSize { get => Settings.WindowSize; From a70b9fcb2dc1ebb9f71940cc23e363551865835f Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 01:43:20 +0800 Subject: [PATCH 261/326] Try to avoid recurion and comment --- Flow.Launcher/SettingWindow.xaml.cs | 4 ++++ Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 7e029910f..bdc858527 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -519,6 +519,10 @@ namespace Flow.Launcher { if (DateFormat != null && TimeFormat != null) { + if (DateFormat.SelectedIndex == -1 || TimeFormat.SelectedIndex == -1) + { + return; + } viewModel.UpdateDateTimeDisplayList(DateFormat.SelectedIndex, TimeFormat.SelectedIndex); DateFormat.Items.Refresh(); TimeFormat.Items.Refresh(); // selected = -1 diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 302310e43..5066d0ca6 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -52,7 +52,7 @@ namespace Flow.Launcher.ViewModel int tmp = 0; TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; - + // TODO: CurrentCulture may equal to settings.language when this is constructed TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); UpdateSettingsDateTimeFormat(); // just in case something wrong @@ -492,8 +492,6 @@ namespace Flow.Launcher.ViewModel public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) { - if (dateIndex == -1 || timeIndex == -1) - return; DateFormatIndex = dateIndex; TimeFormatIndex = timeIndex; From 8159b6edf1b101609e02ee6a80f372e04778fa7b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 12:25:46 +0800 Subject: [PATCH 262/326] auto update value string in index setter --- .../ViewModel/SettingWindowViewModel.cs | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 5066d0ca6..1d78ca1aa 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -55,7 +55,7 @@ namespace Flow.Launcher.ViewModel // TODO: CurrentCulture may equal to settings.language when this is constructed TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); - UpdateSettingsDateTimeFormat(); // just in case something wrong + //UpdateSettingsDateTimeFormat(); // just in case something wrong } public Settings Settings { get; set; } @@ -64,7 +64,7 @@ namespace Flow.Launcher.ViewModel { await _updater.UpdateAppAsync(App.API, false); } - + public bool AutoUpdates { get => Settings.AutoUpdates; @@ -310,11 +310,11 @@ namespace Flow.Launcher.ViewModel } } - private IList LabelMaker(IList list) + private IList LabelMaker(IList list) { - return list.Select(p=>new PluginStoreItemViewModel(p)) + return list.Select(p => new PluginStoreItemViewModel(p)) .OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease) - .ThenByDescending(p=>p.Category == PluginStoreItemViewModel.RecentlyUpdated) + .ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.None) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed) .ToList(); @@ -348,10 +348,10 @@ namespace Flow.Launcher.ViewModel internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0) { - var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0 - ? string.Empty + var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0 + ? string.Empty : plugin.Metadata.ActionKeywords[actionKeywordPosition]; - + App.API.ChangeQuery($"{actionKeyword} {queryToDisplay}"); App.API.ShowMainWindow(); } @@ -476,9 +476,27 @@ namespace Flow.Launcher.ViewModel "dd', 'MMMM" }; - public int TimeFormatIndex { get; set; } = 0; + private int timeFormatIndex = 0; + public int TimeFormatIndex + { + get => timeFormatIndex; + set + { + timeFormatIndex = value; + Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + } + } - public int DateFormatIndex { get; set; } = 0; + private int dateFormatIndex = 0; + public int DateFormatIndex + { + get => dateFormatIndex; + set + { + dateFormatIndex = value; + Settings.DateFormat = DateFormatList[DateFormatIndex]; + } + } public List TimeFormatDisplayList { get; set; } = null; @@ -505,7 +523,7 @@ namespace Flow.Launcher.ViewModel DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } - UpdateSettingsDateTimeFormat(); + //UpdateSettingsDateTimeFormat(); } public double WindowWidthSize @@ -815,15 +833,15 @@ namespace Flow.Launcher.ViewModel } } public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); - + public string CheckLogFolder { - get + get { var dirInfo = new DirectoryInfo(Path.Combine(DataLocation.DataDirectory(), Constant.Logs, Constant.Version)); long size = dirInfo.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length); - - return _translater.GetTranslation("clearlogfolder") + " (" + FormatBytes(size) + ")" ; + + return _translater.GetTranslation("clearlogfolder") + " (" + FormatBytes(size) + ")"; } } From 48aaf3a7db730a49bcec473eb6b38086364a765b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 18 Nov 2022 23:15:02 -0600 Subject: [PATCH 263/326] 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 264/326] 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 673e8c8e9dd2ec44525cadb13225bcefad95b5d3 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 19 Nov 2022 14:33:27 +0900 Subject: [PATCH 265/326] Add Datetimeformat --- .../ViewModel/SettingWindowViewModel.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 5066d0ca6..d48e64380 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -455,9 +455,13 @@ namespace Flow.Launcher.ViewModel public List TimeFormatList { get; set; } = new List() { + "h:mm", "hh:mm", + "H:mm", "HH:mm", + "tt h:mm", "tt hh:mm", + "h:mm tt", "hh:mm tt" }; @@ -466,7 +470,10 @@ namespace Flow.Launcher.ViewModel "MM'/'dd dddd", "MM'/'dd ddd", "MM'/'dd", + "MM'-'dd", + "MMMM', 'dd", "dd'/'MM", + "dd'-'MM", "ddd MM'/'dd", "dddd MM'/'dd", "dddd", @@ -500,6 +507,15 @@ namespace Flow.Launcher.ViewModel TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } + TimeFormatDisplayList[0] = DateTime.Now.ToString(TimeFormatList[0], CultureInfo.CurrentCulture) + " (h:mm)"; + TimeFormatDisplayList[1] = DateTime.Now.ToString(TimeFormatList[1], CultureInfo.CurrentCulture) + " (hh:mm)"; + TimeFormatDisplayList[2] = DateTime.Now.ToString(TimeFormatList[2], CultureInfo.CurrentCulture) + " (H:mm)"; + TimeFormatDisplayList[3] = DateTime.Now.ToString(TimeFormatList[3], CultureInfo.CurrentCulture) + " (HH:mm)"; + TimeFormatDisplayList[4] = DateTime.Now.ToString(TimeFormatList[4], CultureInfo.CurrentCulture) + " (tt h:mm)"; + TimeFormatDisplayList[5] = DateTime.Now.ToString(TimeFormatList[5], CultureInfo.CurrentCulture) + " (tt hh:mm)"; + TimeFormatDisplayList[6] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (h:mm tt)"; + TimeFormatDisplayList[7] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (hh:mm tt)"; + for (int i = 0; i < DateFormatList.Count; ++i) { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); From 32c7ca8ade8123067ccfccf75c369e040b227072 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 19 Nov 2022 14:35:56 +0900 Subject: [PATCH 266/326] Remove Timeformat info --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index d48e64380..24229e9da 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -507,15 +507,6 @@ namespace Flow.Launcher.ViewModel TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } - TimeFormatDisplayList[0] = DateTime.Now.ToString(TimeFormatList[0], CultureInfo.CurrentCulture) + " (h:mm)"; - TimeFormatDisplayList[1] = DateTime.Now.ToString(TimeFormatList[1], CultureInfo.CurrentCulture) + " (hh:mm)"; - TimeFormatDisplayList[2] = DateTime.Now.ToString(TimeFormatList[2], CultureInfo.CurrentCulture) + " (H:mm)"; - TimeFormatDisplayList[3] = DateTime.Now.ToString(TimeFormatList[3], CultureInfo.CurrentCulture) + " (HH:mm)"; - TimeFormatDisplayList[4] = DateTime.Now.ToString(TimeFormatList[4], CultureInfo.CurrentCulture) + " (tt h:mm)"; - TimeFormatDisplayList[5] = DateTime.Now.ToString(TimeFormatList[5], CultureInfo.CurrentCulture) + " (tt hh:mm)"; - TimeFormatDisplayList[6] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (h:mm tt)"; - TimeFormatDisplayList[7] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (hh:mm tt)"; - for (int i = 0; i < DateFormatList.Count; ++i) { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); From 45e9a430601cd070c4ee798ba4ff9b5c710a6ceb Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:44:51 +0800 Subject: [PATCH 267/326] reorganize logic for date/time dropdown --- Flow.Launcher/SettingWindow.xaml | 7 ++-- Flow.Launcher/SettingWindow.xaml.cs | 33 +++++++++++-------- .../ViewModel/SettingWindowViewModel.cs | 27 +++++++-------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 6e2aa590c..3eb2c21bb 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1815,6 +1815,7 @@ @@ -2170,7 +2171,8 @@ VerticalAlignment="Center" FontSize="14" ItemsSource="{Binding TimeFormatDisplayList}" - SelectedIndex="{Binding TimeFormatIndex, Mode=OneTime}" + SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}" + DropDownOpened="RefreshDateTimeList" SelectionChanged="PreviewClockAndDate" /> timeFormatIndex; set { - timeFormatIndex = value; - Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + if (value != -1) + { + timeFormatIndex = value; + Settings.TimeFormat = TimeFormatList[value]; + } } } @@ -493,8 +496,11 @@ namespace Flow.Launcher.ViewModel get => dateFormatIndex; set { - dateFormatIndex = value; - Settings.DateFormat = DateFormatList[DateFormatIndex]; + if (value != -1) + { + dateFormatIndex = value; + Settings.DateFormat = DateFormatList[value]; + } } } @@ -502,17 +508,8 @@ namespace Flow.Launcher.ViewModel public List DateFormatDisplayList { get; set; } = null; - public void UpdateSettingsDateTimeFormat() + public void UpdateDateTimeDisplayList() { - Settings.DateFormat = DateFormatList[DateFormatIndex]; - Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; - } - - public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) - { - DateFormatIndex = dateIndex; - TimeFormatIndex = timeIndex; - for (int i = 0; i < TimeFormatList.Count; ++i) { TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); @@ -522,8 +519,6 @@ namespace Flow.Launcher.ViewModel { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } - - //UpdateSettingsDateTimeFormat(); } public double WindowWidthSize From bde471afa87748490267f81ea72136f876d0f272 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:03:44 +0800 Subject: [PATCH 268/326] Use binding for date time preview --- Flow.Launcher/SettingWindow.xaml | 27 ++++++++++-------- Flow.Launcher/SettingWindow.xaml.cs | 28 ------------------- .../ViewModel/SettingWindowViewModel.cs | 9 ++++++ 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 3eb2c21bb..e08ce7c40 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -39,6 +39,7 @@ + @@ -1820,9 +1821,17 @@ Style="{DynamicResource QueryBoxStyle}" Text="{DynamicResource hiThere}" /> - - - + + + + DropDownOpened="RefreshDateTimeList"/> + Style="{DynamicResource SideToggleSwitch}"/>  @@ -2211,14 +2218,12 @@ FontSize="14" ItemsSource="{Binding DateFormatDisplayList}" SelectedIndex="{Binding DateFormatIndex, Mode=OneWayToSource}" - DropDownOpened="RefreshDateTimeList" - SelectionChanged="PreviewClockAndDate" /> + DropDownOpened="RefreshDateTimeList"/> + Style="{DynamicResource SideToggleSwitch}"/>  diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 97493ca5c..8a80ed680 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -517,34 +517,6 @@ namespace Flow.Launcher } } - private void PreviewClockAndDate(object sender, RoutedEventArgs e) - { - ClockDisplay(); - } - - public void ClockDisplay() - { - if (settings.UseClock) - { - ClockBox.Visibility = Visibility.Visible; - ClockBox.Text = DateTime.Now.ToString(settings.TimeFormat); - } - else - { - ClockBox.Visibility = Visibility.Collapsed; - } - - if (settings.UseDate) - { - DateBox.Visibility = Visibility.Visible; - DateBox.Text = DateTime.Now.ToString(settings.DateFormat); - } - else - { - DateBox.Visibility = Visibility.Collapsed; - } - } - public void InitializePosition() { if (settings.SettingWindowTop >= 0 && settings.SettingWindowLeft >= 0) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 8f02a7083..4a4cf9404 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -486,6 +486,7 @@ namespace Flow.Launcher.ViewModel { timeFormatIndex = value; Settings.TimeFormat = TimeFormatList[value]; + ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); } } } @@ -500,10 +501,15 @@ namespace Flow.Launcher.ViewModel { dateFormatIndex = value; Settings.DateFormat = DateFormatList[value]; + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } } } + public string ClockText { get; private set; } + + public string DateText { get; private set; } + public List TimeFormatDisplayList { get; set; } = null; public List DateFormatDisplayList { get; set; } = null; @@ -519,6 +525,9 @@ namespace Flow.Launcher.ViewModel { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } + + ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } public double WindowWidthSize From e60635608d9a336020153b8e66d2fbf784e45582 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:22:46 +0800 Subject: [PATCH 269/326] Separate date/time format list refresh --- Flow.Launcher/SettingWindow.xaml | 4 +-- Flow.Launcher/SettingWindow.xaml.cs | 26 +++++++++++++------ .../ViewModel/SettingWindowViewModel.cs | 25 +++++++++++------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index e08ce7c40..996c30542 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2181,7 +2181,7 @@ FontSize="14" ItemsSource="{Binding TimeFormatDisplayList}" SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}" - DropDownOpened="RefreshDateTimeList"/> + DropDownOpened="RefreshTimeList"/> + DropDownOpened="RefreshDateList"/> x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; - // TODO: CurrentCulture may equal to settings.language when this is constructed + // TODO: CurrentCulture may not equal to settings.language when this is constructed TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); - //UpdateSettingsDateTimeFormat(); // just in case something wrong } public Settings Settings { get; set; } @@ -514,20 +513,26 @@ namespace Flow.Launcher.ViewModel public List DateFormatDisplayList { get; set; } = null; - public void UpdateDateTimeDisplayList() + public void UpdateDateDisplayList() + { + for (int i = 0; i < DateFormatList.Count; ++i) + { + DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); + } + // TODO: CurrentCulture may not equal to settings.language + // Cross thread issue? + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); + } + + public void UpdateTimeDisplayList() { for (int i = 0; i < TimeFormatList.Count; ++i) { TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } - - for (int i = 0; i < DateFormatList.Count; ++i) - { - DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); - } - + // TODO: CurrentCulture may not equal to settings.language + // Cross thread issue? ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); - DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } public double WindowWidthSize From f1889a950d0e4fbd992f00028546ca3c6df2fffb Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:36:27 +0800 Subject: [PATCH 270/326] Remov unused imports --- Flow.Launcher/SettingWindow.xaml.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index ae84cdad2..a3cb85b41 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -7,21 +7,17 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.ViewModel; -using Microsoft.VisualBasic; using ModernWpf; using ModernWpf.Controls; using System; -using System.Drawing.Printing; using System.IO; using System.Windows; -using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Navigation; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; using Button = System.Windows.Controls.Button; using Control = System.Windows.Controls.Control; using KeyEventArgs = System.Windows.Input.KeyEventArgs; From e2fcd9120297b4f7c0fc507d772eaf5e0f9ead8c Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:54:34 +0800 Subject: [PATCH 271/326] Fix ClockText type --- 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 73be0bbed..dc8121c5a 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -323,7 +323,7 @@ namespace Flow.Launcher.ViewModel #region ViewModel Properties public Settings Settings { get; } - public object ClockText { get; private set; } + public string ClockText { get; private set; } public string DateText { get; private set; } private async Task RegisterClockAndDateUpdateAsync() From dbfb0393173a56cf6d691df2f54c21296d2395d3 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 18:03:25 +0800 Subject: [PATCH 272/326] Remove null check for selected shortcut --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index f3538e02d..cfc53a370 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -783,7 +783,7 @@ namespace Flow.Launcher.ViewModel string deleteWarning = string.Format( InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), - item?.Key, item?.Value); + item.Key, item.Value); if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { From 28a26644f255bb4c25dc94ef8e068a466f227944 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 18:10:21 +0800 Subject: [PATCH 273/326] fix indent --- Flow.Launcher/SettingWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 996c30542..bc0ff1ce4 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1822,8 +1822,8 @@ Text="{DynamicResource hiThere}" /> + x:Name="ClockPanel" + Style="{DynamicResource ClockPanel}"> Date: Sat, 19 Nov 2022 12:08:32 -0600 Subject: [PATCH 274/326] 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 7b90808b43da615c91912f7cfad088bf386e0f71 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 19 Nov 2022 16:09:39 -0600 Subject: [PATCH 275/326] Use Converter to transform format to actual display --- .../DateTimeFormatToNowConverter.cs | 19 + Flow.Launcher/SettingWindow.xaml | 1666 +++++++++-------- Flow.Launcher/SettingWindow.xaml.cs | 24 - .../ViewModel/SettingWindowViewModel.cs | 99 +- 4 files changed, 920 insertions(+), 888 deletions(-) create mode 100644 Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs diff --git a/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs b/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs new file mode 100644 index 000000000..3c46fd01a --- /dev/null +++ b/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Flow.Launcher.Converters +{ + public class DateTimeFormatToNowConverter : IValueConverter + { + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value is not string format ? null : DateTime.Now.ToString(format); + } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index bc0ff1ce4..5b841978f 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1,5 +1,4 @@ - - + - + - + @@ -44,12 +47,15 @@ - + + - + @@ -59,127 +65,172 @@ - - - - - - - - - - - - - - - - - - - - - + @@ -606,13 +717,11 @@ - - - + @@ -628,25 +738,24 @@ - + - - - - + - + - @@ -672,10 +781,10 @@ - + - @@ -685,13 +794,14 @@ - + - + - @@ -702,24 +812,26 @@ - - + + - - + - + - - - + + - @@ -752,14 +865,16 @@ - + - - + + - - + - + - @@ -789,11 +905,12 @@ - - + + - @@ -803,52 +920,46 @@ - - - - + - - - - - + - - - - - + - - + - - + - - - - - - - + @@ -717,11 +606,13 @@ - - - + @@ -738,24 +628,25 @@ - + - - - - + - + - @@ -781,10 +672,10 @@ - + - @@ -794,14 +685,13 @@ - + - + - @@ -812,26 +702,24 @@ - - + + - - + - + - - - + + - @@ -865,16 +752,14 @@ - + - - + + - - + - + - @@ -905,12 +789,11 @@ - - + + - @@ -920,46 +803,52 @@ - - - - + - - - - - + - - - - - + - - + - - + - - + + diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 9ceb9789d..70758540d 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -10,7 +10,9 @@ using Flow.Launcher.ViewModel; using ModernWpf; using ModernWpf.Controls; using System; +using System.Diagnostics; using System.IO; +using System.Security.Policy; using System.Windows; using System.Windows.Data; using System.Windows.Forms; diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 60dc95e2e..0c25dcc85 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -799,6 +799,7 @@ namespace Flow.Launcher.ViewModel #region about public string Website => Constant.Website; + public string SponsorPage => Constant.SponsorPage; public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest"; public string Documentation => Constant.Documentation; public string Docs => Constant.Docs; From d70c0ce58c601fe0ac70b127eab7c9cf0f77f49d Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 24 Nov 2022 20:24:08 +0900 Subject: [PATCH 316/326] Add Become A sponsor button --- Flow.Launcher/SettingWindow.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 4a8a52ea1..2c0e4db25 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2863,7 +2863,6 @@ NavigateUri="{Binding SponsorPage, Mode=OneWay}" RequestNavigate="OnRequestNavigate" TextDecorations="None"> - Date: Thu, 24 Nov 2022 20:05:07 +0800 Subject: [PATCH 317/326] Store CultureInfo in i18n manager --- Flow.Launcher.Core/Resource/Internationalization.cs | 7 ++++++- Flow.Launcher/ViewModel/MainViewModel.cs | 10 +--------- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 4 +--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 4568e92f3..91bcfdf5a 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -17,6 +17,7 @@ namespace Flow.Launcher.Core.Resource public class Internationalization { public Settings Settings { get; set; } + public CultureInfo CurrentCulture { get; private set; } private const string Folder = "Languages"; private const string DefaultFile = "en.xaml"; private const string Extension = ".xaml"; @@ -62,6 +63,7 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(AvailableLanguages.English); _oldResources.Clear(); + CurrentCulture = new CultureInfo("en"); } public void ChangeLanguage(string languageCode) @@ -96,9 +98,12 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(language); } - Settings.Language = language.LanguageCode; CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode); CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture; + CurrentCulture = CultureInfo.CurrentCulture; + + // Raise event after this.CurrentCulture is set + Settings.Language = language.LanguageCode; _ = Task.Run(() => { UpdatePluginMetadataTranslations(); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 109cfc81e..5be065429 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -65,16 +65,10 @@ namespace Flow.Launcher.ViewModel Settings = settings; Settings.PropertyChanged += (_, args) => { - if (args.PropertyName == nameof(Settings.WindowSize)) - { - } switch (args.PropertyName) { case nameof(Settings.WindowSize): OnPropertyChanged(nameof(MainWindowWidth)); break; - case nameof(Settings.Language): - Culture = new CultureInfo(Settings.Language); - break; } }; @@ -106,8 +100,6 @@ namespace Flow.Launcher.ViewModel RegisterClockAndDateUpdateAsync(); SetOpenResultModifiers(); - - Culture = new CultureInfo(Settings.Language); } private void RegisterViewUpdate() @@ -343,7 +335,7 @@ namespace Flow.Launcher.ViewModel public Settings Settings { get; } public string ClockText { get; private set; } public string DateText { get; private set; } - public CultureInfo Culture { get; set; } + public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; private async Task RegisterClockAndDateUpdateAsync() { diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index c51e3e421..f31e838fa 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -56,14 +56,12 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(ClockText)); break; case nameof(Settings.Language): - Culture = new CultureInfo(Settings.Language); OnPropertyChanged(nameof(ClockText)); OnPropertyChanged(nameof(DateText)); break; } }; - Culture = new CultureInfo(Settings.Language); } public Settings Settings { get; set; } @@ -87,7 +85,7 @@ namespace Flow.Launcher.ViewModel } } - public CultureInfo Culture { get; private set; } + public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; public bool StartFlowLauncherOnSystemStartup { From 303d3b97541715af83a2fd02d8209c49cfbffb88 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 24 Nov 2022 14:18:31 -0600 Subject: [PATCH 318/326] remove task.run outside --- Flow.Launcher/ViewModel/ResultViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index d12a765ae..282c45f46 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -15,7 +15,7 @@ namespace Flow.Launcher.ViewModel public class ResultViewModel : BaseModel { private static PrivateFontCollection fontCollection = new(); - private static Dictionary fonts = new(); + private static Dictionary fonts = new(); public ResultViewModel(Result result, Settings settings) { @@ -173,7 +173,7 @@ namespace Flow.Launcher.ViewModel } // We need to modify the property not field here to trigger the OnPropertyChanged event - var i = await Task.Run(async () => await ImageLoader.LoadAsync(imagePath, loadFullImage)); + var i = await ImageLoader.LoadAsync(imagePath, loadFullImage); Image = i; } From fb3a23fb2c58b040966bf11fcef42377b79e03c6 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 24 Nov 2022 14:19:16 -0600 Subject: [PATCH 319/326] remove unnecessary local variable --- Flow.Launcher/ViewModel/ResultViewModel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 282c45f46..2d61f6cab 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -173,8 +173,7 @@ namespace Flow.Launcher.ViewModel } // We need to modify the property not field here to trigger the OnPropertyChanged event - var i = await ImageLoader.LoadAsync(imagePath, loadFullImage); - Image = i; + Image = await ImageLoader.LoadAsync(imagePath, loadFullImage).ConfigureAwait(false); } public Result Result { get; } From 17bc59d0bf21780b960fba351db78dba016f6127 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Fri, 25 Nov 2022 13:59:30 +1100 Subject: [PATCH 320/326] update sponsor link --- Flow.Launcher.Infrastructure/Constant.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs index ed4e34fee..b0eebd2df 100644 --- a/Flow.Launcher.Infrastructure/Constant.cs +++ b/Flow.Launcher.Infrastructure/Constant.cs @@ -45,7 +45,7 @@ namespace Flow.Launcher.Infrastructure public const string Logs = "Logs"; public const string Website = "https://flowlauncher.com"; - public const string SponsorPage = "https://opencollective.com/flow-launcher"; + public const string SponsorPage = "https://github.com/sponsors/Flow-Launcher"; public const string GitHub = "https://github.com/Flow-Launcher/Flow.Launcher"; public const string Docs = "https://flowlauncher.com/docs"; } From 30987f9c95e22bee43f16ccb8b7cb3ce74cbcf38 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 25 Nov 2022 12:00:37 +0800 Subject: [PATCH 321/326] Use DefaultThreadCurrentCulture for culture in app domain --- .../Resource/Internationalization.cs | 14 ++++++++------ .../UserSettings/Settings.cs | 1 - .../Converters/QuerySuggestionBoxConverter.cs | 5 +++-- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 2 +- Plugins/Flow.Launcher.Plugin.Calculator/Main.cs | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 91bcfdf5a..acc693ed5 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -17,7 +17,6 @@ namespace Flow.Launcher.Core.Resource public class Internationalization { public Settings Settings { get; set; } - public CultureInfo CurrentCulture { get; private set; } private const string Folder = "Languages"; private const string DefaultFile = "en.xaml"; private const string Extension = ".xaml"; @@ -63,7 +62,6 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(AvailableLanguages.English); _oldResources.Clear(); - CurrentCulture = new CultureInfo("en"); } public void ChangeLanguage(string languageCode) @@ -98,11 +96,15 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(language); } - CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode); + // Culture of this thread + // Use CreateSpecificCulture to preserve possible user-override settings in Windows + CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode); CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture; - CurrentCulture = CultureInfo.CurrentCulture; + // App domain + CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode); + CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture; - // Raise event after this.CurrentCulture is set + // Raise event after culture is set Settings.Language = language.LanguageCode; _ = Task.Run(() => { @@ -191,7 +193,7 @@ namespace Flow.Launcher.Core.Resource { p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle(); p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription(); - pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture); + pluginI18N.OnCultureInfoChanged(CultureInfo.DefaultThreadCurrentCulture); } catch (Exception e) { diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 33072b53d..3561c6ffe 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -6,7 +6,6 @@ using System.Text.Json.Serialization; using System.Windows; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; -using Flow.Launcher; using Flow.Launcher.ViewModel; namespace Flow.Launcher.Infrastructure.UserSettings diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs index ecdfc5851..1e39473e0 100644 --- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs +++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs @@ -52,7 +52,8 @@ namespace Flow.Launcher.Converters // Check if Text will be larger then our QueryTextBox System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch); - System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black); + // TODO: Obsolete warning? + System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.DefaultThreadCurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black); var offset = QueryTextBox.Padding.Right; @@ -75,4 +76,4 @@ namespace Flow.Launcher.Converters throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5be065429..4db8e3df3 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -335,7 +335,7 @@ namespace Flow.Launcher.ViewModel public Settings Settings { get; } public string ClockText { get; private set; } public string DateText { get; private set; } - public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; + public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture; private async Task RegisterClockAndDateUpdateAsync() { diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index f31e838fa..de4544233 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -85,7 +85,7 @@ namespace Flow.Launcher.ViewModel } } - public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; + public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture; public bool StartFlowLauncherOnSystemStartup { diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index bc79219b6..d5dcdacea 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Runtime.InteropServices; @@ -61,7 +61,7 @@ namespace Flow.Launcher.Plugin.Caculator switch (_settings.DecimalSeparator) { case DecimalSeparator.Comma: - case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",": + case DecimalSeparator.UseSystemLocale when CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator == ",": expression = query.Search.Replace(",", "."); break; default: @@ -157,7 +157,7 @@ namespace Flow.Launcher.Plugin.Caculator private string GetDecimalSeparator() { - string systemDecimalSeperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; + string systemDecimalSeperator = CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator; switch (_settings.DecimalSeparator) { case DecimalSeparator.UseSystemLocale: return systemDecimalSeperator; From e38a3b0505677b78b511ce85169dbaa728262f4a Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 25 Nov 2022 14:08:37 +0900 Subject: [PATCH 322/326] Change Keyword to ws from * --- Plugins/Flow.Launcher.Plugin.WindowsSettings/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/plugin.json b/Plugins/Flow.Launcher.Plugin.WindowsSettings/plugin.json index b5121b36a..17e6eb39b 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/plugin.json @@ -1,6 +1,6 @@ { "ID": "5043CETYU6A748679OPA02D27D99677A", - "ActionKeyword": "*", + "ActionKeyword": "ws", "Description": "Search settings inside Control Panel and Settings App", "Name": "Windows Settings", "Author": "TobiasSekan", From 21babd13dbcca0cf9db31389278aaef0ba4a6279 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 25 Nov 2022 15:30:26 +0900 Subject: [PATCH 323/326] Fix Plugin Trigger Icon Position --- Flow.Launcher/MainWindow.xaml | 47 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index c71a2d7a3..82c32a3d8 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -260,28 +260,31 @@ Text="{Binding DateText}" Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" /> - - - - - + + + + + + + + From 32e406e575c4e4acce47d4950d2e144865e92b48 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 25 Nov 2022 16:20:54 +0900 Subject: [PATCH 324/326] Add MinWidth ContextMenu --- Flow.Launcher/MainWindow.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 82c32a3d8..49854ed81 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -210,7 +210,7 @@ - + From 7f375be727f84eab553b8b23718f07c1c037da1f Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 25 Nov 2022 16:35:00 +0900 Subject: [PATCH 325/326] Add SnapPixel --- Flow.Launcher/Themes/Base.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher/Themes/Base.xaml b/Flow.Launcher/Themes/Base.xaml index edb9ce04d..94740a730 100644 --- a/Flow.Launcher/Themes/Base.xaml +++ b/Flow.Launcher/Themes/Base.xaml @@ -87,6 +87,8 @@ + +