From 3b425413a22b925a1479db6ee2345aa69b5065c4 Mon Sep 17 00:00:00 2001 From: 01Dri Date: Sun, 25 May 2025 04:31:08 -0300 Subject: [PATCH] Edit access link --- .../Search/QuickAccessLinks/AccessLink.cs | 21 +----- .../ViewModels/SettingsViewModel.cs | 36 +++++++---- .../Views/ExplorerSettings.xaml | 4 +- .../Views/QuickAccessLinkSettings.xaml.cs | 64 +++++++++++++------ 4 files changed, 74 insertions(+), 51 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/AccessLink.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/AccessLink.cs index 8650b4c4c..ce086ac8c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/AccessLink.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/AccessLink.cs @@ -1,28 +1,13 @@ -using System; -using System.Linq; -using System.Text.Json.Serialization; - -namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks +namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks { public class AccessLink { public string Path { get; set; } public ResultType Type { get; set; } = ResultType.Folder; - + public string Name { get; set; } - - private string GetPathName() - { - var path = Path.EndsWith(Constants.DirectorySeparator) ? Path[0..^1] : Path; - if (path.EndsWith(':')) - return path[0..^1] + " Drive"; - - return path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None) - .Last(); - } - } - + } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 508e20893..eeb6b450e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -328,33 +328,43 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } [RelayCommand] - private void EditLink(object commandParameter) + private void EditQuickAccessLink(object commandParameter) { - var (selectedLink, collection) = commandParameter switch + if (SelectedQuickAccessLink is null) { - "QuickAccessLink" => (SelectedQuickAccessLink, Settings.QuickAccessLinks), - "IndexSearchExcludedPaths" => (SelectedIndexSearchExcludedPath, Settings.IndexSearchExcludedSubdirectoryPaths), - _ => throw new ArgumentOutOfRangeException(nameof(commandParameter)) - }; + ShowUnselectedMessage(); + return; + } + + var quickAccessLinkSettings = new QuickAccessLinkSettings(SelectedQuickAccessLink); + quickAccessLinkSettings.ShowDialog(); + } - if (selectedLink is null) + [RelayCommand] + private void EditIndexSearchExcludePaths(object commandParameter) + { + + var collection = Settings.IndexSearchExcludedSubdirectoryPaths; + + if (SelectedIndexSearchExcludedPath is null) { ShowUnselectedMessage(); return; } - var path = PromptUserSelectPath(selectedLink.Type, - selectedLink.Type == ResultType.Folder - ? selectedLink.Path - : Path.GetDirectoryName(selectedLink.Path)); + var path = PromptUserSelectPath(SelectedIndexSearchExcludedPath.Type, + SelectedIndexSearchExcludedPath.Type == ResultType.Folder + ? SelectedIndexSearchExcludedPath.Path + : Path.GetDirectoryName(SelectedIndexSearchExcludedPath.Path)); if (path is null) return; - collection.Remove(selectedLink); + var selectedType = SelectedIndexSearchExcludedPath.Type; + collection.Remove(SelectedIndexSearchExcludedPath); collection.Add(new AccessLink { - Path = path, Type = selectedLink.Type, + Path = path, Type = selectedType, }); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 07f05b1c1..0a52487c3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -756,7 +756,7 @@