Skip to content

Commit 0ee0fb8

Browse files
committed
add Explorer plugin's settings page
1 parent e34bcbd commit 0ee0fb8

File tree

10 files changed

+305
-43
lines changed

10 files changed

+305
-43
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public static string GetPreviousExistingDirectory(Func<string, bool> locationExi
187187
}
188188

189189
///<summary>
190-
/// Returns the previous level directory if path incomplete.
190+
/// Returns the previous level directory if path incomplete (does not end with '\').
191191
/// Does not check if previous level directory exists.
192192
/// Returns passed in string if is complete path
193193
///</summary>

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Flow.Launcher.Infrastructure.Logger;
88
using Flow.Launcher.Plugin.SharedCommands;
99
using Flow.Launcher.Plugin.Explorer.Search;
10+
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
1011
using System.Linq;
1112
using System.Reflection;
1213

@@ -192,8 +193,8 @@ private Result CreateAddToIndexSearchExclusionListResult(SearchResult record)
192193
SubTitle = "Path: " + record.FullPath,
193194
Action = _ =>
194195
{
195-
if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x == record.FullPath))
196-
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(record.FullPath);
196+
if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath))
197+
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(new FolderLink { Path = record.FullPath });
197198

198199
var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString());
199200

Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<UseWPF>true</UseWPF>
7+
<UseWindowsForms>true</UseWindowsForms>
78
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
89
<ApplicationIcon />
910
<StartupObject />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Linq;
4+
5+
namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
6+
{
7+
[JsonObject(MemberSerialization.OptIn)]
8+
public class FolderLink
9+
{
10+
[JsonProperty]
11+
public string Path { get; set; }
12+
13+
public string Nickname
14+
{
15+
get
16+
{
17+
var path = Path.EndsWith(Constants.DirectorySeperator) ? Path[0..^1] : Path;
18+
19+
if (path.EndsWith(':'))
20+
return path[0..^1] + " Drive";
21+
22+
return path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None)
23+
.Last()
24+
+ " (" + System.IO.Path.GetDirectoryName(Path) + ")";
25+
}
26+
}
27+
}
28+
29+
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs renamed to Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Text;
77
using System.Windows;
88

9-
namespace Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks
9+
namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
1010
{
1111
public class QuickFolderAccess
1212
{

Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
2-
using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks;
2+
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
33
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
44
using Flow.Launcher.Plugin.SharedCommands;
55
using System;
@@ -28,7 +28,7 @@ internal List<Result> Search(Query query)
2828
{
2929
var querySearch = query.Search;
3030

31-
var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.FolderLinks);
31+
var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.QuickFolderAccessLinks);
3232

3333
if (quickFolderLinks.Count > 0)
3434
return quickFolderLinks;
@@ -113,7 +113,7 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
113113
return false;
114114

115115
if (_settings.IndexSearchExcludedSubdirectoryPaths
116-
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x)))
116+
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x.Path)))
117117
return false;
118118

119119
return _indexSearch.PathIsIndexed(locationPath);
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
2-
using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks;
1+
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
32
using Newtonsoft.Json;
43
using System.Collections.Generic;
54

@@ -11,12 +10,12 @@ public class Settings
1110
public int MaxResult { get; set; } = 100;
1211

1312
[JsonProperty]
14-
public List<FolderLink> FolderLinks { get; set; } = new List<FolderLink>();
13+
public List<FolderLink> QuickFolderAccessLinks { get; set; } = new List<FolderLink>();
1514

1615
[JsonProperty]
1716
public bool UseWindowsIndexForDirectorySearch { get; set; } = true;
1817

1918
[JsonProperty]
20-
public List<string> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<string>();
19+
public List<FolderLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<FolderLink>();
2120
}
22-
}
21+
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,48 @@
66
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
77
mc:Ignorable="d"
88
d:DesignHeight="450" d:DesignWidth="800">
9-
<Grid>
10-
9+
<UserControl.Resources>
10+
<DataTemplate x:Key="ListViewTemplateFolderLinks">
11+
<TextBlock
12+
Text="{Binding Nickname, Mode=OneTime}"
13+
Margin="0,5,0,5" />
14+
</DataTemplate>
15+
<DataTemplate x:Key="ListViewTemplateExcludedPaths">
16+
<TextBlock
17+
Text="{Binding Nickname, Mode=OneTime}"
18+
Margin="0,5,0,5" />
19+
</DataTemplate>
20+
</UserControl.Resources>
21+
<Grid Margin="10">
22+
<Grid.RowDefinitions>
23+
<RowDefinition Height="*"/>
24+
<RowDefinition Height="100"/>
25+
</Grid.RowDefinitions>
26+
<ScrollViewer Margin="20 35 0 0" HorizontalScrollBarVisibility="Hidden" Grid.Row="0" VerticalScrollBarVisibility="Auto">
27+
<StackPanel>
28+
<Expander Name="expFolderLinks" Header="Quick Folder Access Paths"
29+
Expanded="expFolderLinks_Click" Collapsed="expFolderLinks_Click">
30+
<ListView
31+
x:Name="lbxFolderLinks" AllowDrop="True"
32+
Drop="lbxFolders_Drop"
33+
DragEnter="lbxFolders_DragEnter"
34+
ItemTemplate="{StaticResource ListViewTemplateFolderLinks}"/>
35+
</Expander>
36+
<Expander x:Name="expExcludedPaths" Header="Index Search Excluded Paths"
37+
Expanded="expExcludedPaths_Click" Collapsed="expExcludedPaths_Click"
38+
Margin="0 10 0 0">
39+
<ListView
40+
x:Name="lbxExcludedPaths" AllowDrop="True"
41+
Drop="lbxFolders_Drop"
42+
DragEnter="lbxFolders_DragEnter"
43+
ItemTemplate="{StaticResource ListViewTemplateExcludedPaths}"/>
44+
</Expander>
45+
</StackPanel>
46+
</ScrollViewer>
47+
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
48+
<Button x:Name="btnDelete" Click="btnDelete_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_delete}"/>
49+
<Button x:Name="btnEdit" Click="btnEdit_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_edit}"/>
50+
<Button x:Name="btnAdd" Click="btnAdd_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_add}"/>
51+
</StackPanel>
1152
</Grid>
1253
</UserControl>

0 commit comments

Comments
 (0)