From 0ee0fb8d2bf717abfbc1d30fa843c054c3040c98 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 6 Jun 2020 22:13:22 +1000 Subject: [PATCH] add Explorer plugin's settings page --- .../SharedCommands/FilesFolders.cs | 2 +- .../ContextMenu.cs | 5 +- .../Flow.Launcher.Plugin.Explorer.csproj | 1 + .../Search/FolderLinks/FolderLink.cs | 29 +++ .../QuickFolderAccess.cs | 2 +- .../Search/QuickFolderLinks/FolderLink.cs | 18 -- .../Search/SearchManager.cs | 6 +- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 9 +- .../Views/ExplorerSettings.xaml | 45 +++- .../Views/ExplorerSettings.xaml.cs | 231 +++++++++++++++++- 10 files changed, 305 insertions(+), 43 deletions(-) create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/FolderLink.cs rename Plugins/Flow.Launcher.Plugin.Explorer/Search/{QuickFolderLinks => FolderLinks}/QuickFolderAccess.cs (92%) delete mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs index 32f6507fa..ce067e8a0 100644 --- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs +++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs @@ -187,7 +187,7 @@ namespace Flow.Launcher.Plugin.SharedCommands } /// - /// Returns the previous level directory if path incomplete. + /// Returns the previous level directory if path incomplete (does not end with '\'). /// Does not check if previous level directory exists. /// Returns passed in string if is complete path /// diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index e36b09eb7..417161300 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -7,6 +7,7 @@ using System.Windows; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Plugin.Explorer.Search; +using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; using System.Linq; using System.Reflection; @@ -192,8 +193,8 @@ namespace Flow.Launcher.Plugin.Explorer SubTitle = "Path: " + record.FullPath, Action = _ => { - if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x == record.FullPath)) - Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(record.FullPath); + if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath)) + Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(new FolderLink { Path = record.FullPath }); var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString()); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj index 65eed12d6..f45a70c52 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj @@ -4,6 +4,7 @@ Library netcoreapp3.1 true + true false diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/FolderLink.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/FolderLink.cs new file mode 100644 index 000000000..379b5848f --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/FolderLink.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; +using System; +using System.Linq; + +namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks +{ + [JsonObject(MemberSerialization.OptIn)] + public class FolderLink + { + [JsonProperty] + public string Path { get; set; } + + public string Nickname + { + get + { + var path = Path.EndsWith(Constants.DirectorySeperator) ? Path[0..^1] : Path; + + if (path.EndsWith(':')) + return path[0..^1] + " Drive"; + + return path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None) + .Last() + + " (" + System.IO.Path.GetDirectoryName(Path) + ")"; + } + } + } + +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs similarity index 92% rename from Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs rename to Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs index 4bddf8168..1ffd8378b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Windows; -namespace Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks +namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks { public class QuickFolderAccess { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs deleted file mode 100644 index 33c6d37dc..000000000 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Linq; - -namespace Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks -{ - [JsonObject(MemberSerialization.OptIn)] - public class FolderLink - { - [JsonProperty] - public string Path { get; set; } - - public string Nickname => - Path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None) - .Last() - + " (" + System.IO.Path.GetDirectoryName(Path) + ")"; - } -} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 65a2f4ac9..5d6550f74 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -1,5 +1,5 @@ using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; -using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks; +using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; using Flow.Launcher.Plugin.SharedCommands; using System; @@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search { var querySearch = query.Search; - var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.FolderLinks); + var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.QuickFolderAccessLinks); if (quickFolderLinks.Count > 0) return quickFolderLinks; @@ -113,7 +113,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return false; if (_settings.IndexSearchExcludedSubdirectoryPaths - .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x))) + .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x.Path))) return false; return _indexSearch.PathIsIndexed(locationPath); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 6b442384d..d4bfdbbfc 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -1,5 +1,4 @@ -using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; -using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks; +using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; using Newtonsoft.Json; using System.Collections.Generic; @@ -11,12 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer public int MaxResult { get; set; } = 100; [JsonProperty] - public List FolderLinks { get; set; } = new List(); + public List QuickFolderAccessLinks { get; set; } = new List(); [JsonProperty] public bool UseWindowsIndexForDirectorySearch { get; set; } = true; [JsonProperty] - public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); + public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 93defd985..9e04c8b8f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -6,7 +6,48 @@ xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - - + + + + + + + + + + + + + + + + + + + + + + + + +