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">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
index f87c29412..104bef336 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
@@ -1,27 +1,236 @@
-using Flow.Launcher.Plugin.Explorer.ViewModels;
+using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
using System;
using System.Collections.Generic;
-using System.Text;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Forms;
+using DataFormats = System.Windows.DataFormats;
+using DragDropEffects = System.Windows.DragDropEffects;
+using DragEventArgs = System.Windows.DragEventArgs;
+using MessageBox = System.Windows.MessageBox;
namespace Flow.Launcher.Plugin.Explorer.Views
{
///
/// Interaction logic for ExplorerSettings.xaml
///
- public partial class ExplorerSettings : UserControl
+ public partial class ExplorerSettings
{
public ExplorerSettings()
{
InitializeComponent();
+
+ lbxFolderLinks.ItemsSource = Main.Settings.QuickFolderAccessLinks;
+
+ lbxExcludedPaths.ItemsSource = Main.Settings.IndexSearchExcludedSubdirectoryPaths;
+
+ RefreshView();
+ }
+
+ public void RefreshView()
+ {
+ lbxFolderLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
+
+ lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
+
+ btnDelete.Visibility = Visibility.Hidden;
+ btnEdit.Visibility = Visibility.Hidden;
+ btnAdd.Visibility = Visibility.Hidden;
+
+ if (expFolderLinks.IsExpanded || expExcludedPaths.IsExpanded)
+ {
+ btnAdd.Visibility = Visibility.Visible;
+
+ if ((lbxFolderLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0)
+ && btnDelete.Visibility == Visibility.Visible
+ && btnEdit.Visibility == Visibility.Visible)
+ {
+ btnDelete.Visibility = Visibility.Hidden;
+ btnEdit.Visibility = Visibility.Hidden;
+ }
+
+ if (expFolderLinks.IsExpanded
+ && lbxFolderLinks.Items.Count > 0
+ && btnDelete.Visibility == Visibility.Hidden
+ && btnEdit.Visibility == Visibility.Hidden)
+ {
+ btnDelete.Visibility = Visibility.Visible;
+ btnEdit.Visibility = Visibility.Visible;
+ }
+
+ if (expExcludedPaths.IsExpanded
+ && lbxExcludedPaths.Items.Count > 0
+ && btnDelete.Visibility == Visibility.Hidden
+ && btnEdit.Visibility == Visibility.Hidden)
+ {
+ btnDelete.Visibility = Visibility.Visible;
+ btnEdit.Visibility = Visibility.Visible;
+ }
+ }
+
+ lbxFolderLinks.Items.Refresh();
+
+ lbxExcludedPaths.Items.Refresh();
+ }
+
+ private void expFolderLinks_Click(object sender, RoutedEventArgs e)
+ {
+ if (expFolderLinks.IsExpanded)
+ expFolderLinks.Height = 235;
+
+ if (!expFolderLinks.IsExpanded)
+ expFolderLinks.Height = Double.NaN;
+
+ if (expExcludedPaths.IsExpanded)
+ expExcludedPaths.IsExpanded = false;
+
+ RefreshView();
+ }
+
+ private void expExcludedPaths_Click(object sender, RoutedEventArgs e)
+ {
+ if (expExcludedPaths.IsExpanded)
+ expFolderLinks.Height = Double.NaN;
+
+ if (expFolderLinks.IsExpanded)
+ expFolderLinks.IsExpanded = false;
+
+ RefreshView();
+ }
+
+ private void btnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ var selectedRow = lbxFolderLinks.SelectedItem as FolderLink?? lbxExcludedPaths.SelectedItem as FolderLink;
+
+ if (selectedRow != null)
+ {
+ string msg = string.Format(Main.Context.API.GetTranslation("flowlauncher_plugin_folder_delete_folder_link"), selectedRow.Path);
+
+ if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+ {
+ if (expFolderLinks.IsExpanded)
+ Main.Settings.QuickFolderAccessLinks.Remove(selectedRow);
+
+ if (expExcludedPaths.IsExpanded)
+ Main.Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
+
+ RefreshView();
+ }
+ }
+ else
+ {
+ string warning = Main.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
+ MessageBox.Show(warning);
+ }
+ }
+
+ private void btnEdit_Click(object sender, RoutedEventArgs e)
+ {
+ var selectedRow = lbxFolderLinks.SelectedItem as FolderLink ?? lbxExcludedPaths.SelectedItem as FolderLink;
+
+ if (selectedRow != null)
+ {
+ var folderBrowserDialog = new FolderBrowserDialog();
+ folderBrowserDialog.SelectedPath = selectedRow.Path;
+ if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (expFolderLinks.IsExpanded)
+ {
+ var link = Main.Settings.QuickFolderAccessLinks.First(x => x.Path == selectedRow.Path);
+ link.Path = folderBrowserDialog.SelectedPath;
+ }
+
+ if (expExcludedPaths.IsExpanded)
+ {
+ var link = Main.Settings.IndexSearchExcludedSubdirectoryPaths.First(x => x.Path == selectedRow.Path);
+ link.Path = folderBrowserDialog.SelectedPath;
+ }
+ }
+
+ RefreshView();
+ }
+ else
+ {
+ string warning = Main.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
+ MessageBox.Show(warning);
+ }
+ }
+
+ private void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ var folderBrowserDialog = new FolderBrowserDialog();
+ if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
+ {
+ var newFolderLink = new FolderLink
+ {
+ Path = folderBrowserDialog.SelectedPath
+ };
+
+ AddFolderLink(newFolderLink);
+ }
+
+ RefreshView();
+ }
+
+ private void lbxFolders_Drop(object sender, DragEventArgs e)
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+
+ if (files != null && files.Count() > 0)
+ {
+ if (expFolderLinks.IsExpanded && Main.Settings.QuickFolderAccessLinks == null)
+ Main.Settings.QuickFolderAccessLinks = new List();
+
+ foreach (string s in files)
+ {
+ if (Directory.Exists(s))
+ {
+ var newFolderLink = new FolderLink
+ {
+ Path = s
+ };
+
+ AddFolderLink(newFolderLink);
+ }
+
+ RefreshView();
+ }
+ }
+ }
+
+ private void AddFolderLink(FolderLink newFolderLink)
+ {
+ if (expFolderLinks.IsExpanded
+ && !Main.Settings.QuickFolderAccessLinks.Any(x => x.Path == newFolderLink.Path))
+ {
+ if (Main.Settings.QuickFolderAccessLinks == null)
+ Main.Settings.QuickFolderAccessLinks = new List();
+
+ Main.Settings.QuickFolderAccessLinks.Add(newFolderLink);
+ }
+
+ if (expExcludedPaths.IsExpanded
+ && !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == newFolderLink.Path))
+ {
+ if (Main.Settings.IndexSearchExcludedSubdirectoryPaths == null)
+ Main.Settings.IndexSearchExcludedSubdirectoryPaths = new List();
+
+ Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(newFolderLink);
+ }
+ }
+
+ private void lbxFolders_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ e.Effects = DragDropEffects.Link;
+ }
+ else
+ {
+ e.Effects = DragDropEffects.None;
+ }
}
}
}