Skip to content

Commit 97ca626

Browse files
authored
merge PR #94: Explorer plugin enhancements
2 parents 718f683 + bd64512 commit 97ca626

File tree

10 files changed

+53
-11
lines changed

10 files changed

+53
-11
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,15 @@ public Result() { }
130130
/// Plugin ID that generated this result
131131
/// </summary>
132132
public string PluginID { get; internal set; }
133+
134+
/// <summary>
135+
/// Show message as ToolTip on result Title hover over
136+
/// </summary>
137+
public string TitleToolTip { get; set; }
138+
139+
/// <summary>
140+
/// Show message as ToolTip on result SubTitle hover over
141+
/// </summary>
142+
public string SubTitleToolTip { get; set; }
133143
}
134144
}

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Flow.Launcher.Plugin.SharedCommands
88
public static class FilesFolders
99
{
1010
private const string FileExplorerProgramName = "explorer";
11+
12+
private const string FileExplorerProgramEXE = "explorer.exe";
13+
1114
public static void Copy(this string sourcePath, string targetPath)
1215
{
1316
// Get the subdirectories for the specified directory.
@@ -128,6 +131,11 @@ public static void OpenPath(string fileOrFolderPath)
128131
}
129132
}
130133

134+
public static void OpenContainingFolder(string path)
135+
{
136+
Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
137+
}
138+
131139
///<summary>
132140
/// This checks whether a given string is a directory path or network location string.
133141
/// It does not check if location actually exists.

Flow.Launcher/ResultListBox.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</TextBlock>
6363
</StackPanel>
6464
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left"
65-
VerticalAlignment="Center" ToolTip="{Binding Result.Title}" x:Name="Title"
65+
VerticalAlignment="Center" ToolTip="{Binding ShowTitleToolTip}" x:Name="Title"
6666
Text="{Binding Result.Title}">
6767
<vm:ResultsViewModel.FormattedText>
6868
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
@@ -71,7 +71,7 @@
7171
</MultiBinding>
7272
</vm:ResultsViewModel.FormattedText>
7373
</TextBlock>
74-
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding Result.SubTitle}"
74+
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding ShowSubTitleToolTip}"
7575
Grid.Row="1" x:Name="SubTitle" Text="{Binding Result.SubTitle}" MinWidth="750">
7676
<vm:ResultsViewModel.FormattedText>
7777
<MultiBinding Converter="{StaticResource HighlightTextConverter}">

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public ResultViewModel(Result result, Settings settings)
2929

3030
public string OpenResultModifiers => Settings.OpenResultModifiers;
3131

32+
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
33+
? Result.Title
34+
: Result.TitleToolTip;
35+
36+
public string ShowSubTitleToolTip => string.IsNullOrEmpty(Result.SubTitleToolTip)
37+
? Result.SubTitle
38+
: Result.SubTitleToolTip;
39+
3240
public ImageSource Image
3341
{
3442
get

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private Result CreateOpenContainingFolderResult(SearchResult record)
156156
{
157157
try
158158
{
159-
Process.Start("explorer.exe", $" /select,\"{record.FullPath}\"");
159+
FilesFolders.OpenContainingFolder(record.FullPath);
160160
}
161161
catch (Exception e)
162162
{

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ internal static class Constants
1616
internal const string DifferentUserIconImagePath = "Images\\user.png";
1717
internal const string IndexingOptionsIconImagePath = "Images\\windowsindexingoptions.png";
1818

19-
internal const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
19+
internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory";
20+
21+
internal const string ToolTipOpenContainingFolder = "Ctrl + Enter to open the containing folder";
2022

2123
internal const char AllFilesFolderSearchWildcard = '>';
2224

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private List<Result> DirectorySearch(SearchOption searchOption, Query query, str
6565

6666
if (fileSystemInfo is System.IO.DirectoryInfo)
6767
{
68-
folderList.Add(resultManager.CreateFolderResult(fileSystemInfo.Name, Constants.DefaultFolderSubtitleString, fileSystemInfo.FullName, query, true, false));
68+
folderList.Add(resultManager.CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, fileSystemInfo.FullName, query, true, false));
6969
}
7070
else
7171
{

Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, Plug
1212
return folderLinks
1313
.Select(item =>
1414
new ResultManager(context)
15-
.CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query))
15+
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
1616
.ToList();
1717

1818
string search = query.Search.ToLower();
@@ -21,7 +21,7 @@ internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, Plug
2121

2222
return queriedFolderLinks.Select(item =>
2323
new ResultManager(context)
24-
.CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query))
24+
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
2525
.ToList();
2626
}
2727
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Flow.Launcher.Infrastructure;
22
using Flow.Launcher.Plugin.SharedCommands;
33
using System;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
67
using System.Windows;
@@ -38,13 +39,15 @@ internal Result CreateFolderResult(string title, string subtitle, string path, Q
3839
return false;
3940
}
4041
}
41-
42+
4243
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
4344
context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ?
4445
changeTo :
4546
query.ActionKeyword + " " + changeTo);
4647
return false;
4748
},
49+
TitleToolTip = Constants.ToolTipOpenDirectory,
50+
SubTitleToolTip = Constants.ToolTipOpenDirectory,
4851
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
4952
};
5053
}
@@ -85,6 +88,8 @@ internal Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed =
8588
FilesFolders.OpenPath(retrievedDirectoryPath);
8689
return true;
8790
},
91+
TitleToolTip = retrievedDirectoryPath,
92+
SubTitleToolTip = retrievedDirectoryPath,
8893
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
8994
};
9095
}
@@ -101,7 +106,14 @@ internal Result CreateFileResult(string filePath, Query query, bool showIndexSta
101106
{
102107
try
103108
{
104-
FilesFolders.OpenPath(filePath);
109+
if (c.SpecialKeyState.CtrlPressed)
110+
{
111+
FilesFolders.OpenContainingFolder(filePath);
112+
}
113+
else
114+
{
115+
FilesFolders.OpenPath(filePath);
116+
}
105117
}
106118
catch (Exception ex)
107119
{
@@ -110,6 +122,8 @@ internal Result CreateFileResult(string filePath, Query query, bool showIndexSta
110122

111123
return true;
112124
},
125+
TitleToolTip = Constants.ToolTipOpenContainingFolder,
126+
SubTitleToolTip = Constants.ToolTipOpenContainingFolder,
113127
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
114128
};
115129
return result;

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string
5454
if (dataReaderResults.GetString(2) == "Directory")
5555
{
5656
folderResults.Add(resultManager.CreateFolderResult(
57-
dataReaderResults.GetString(0),
58-
Constants.DefaultFolderSubtitleString,
57+
dataReaderResults.GetString(0),
58+
dataReaderResults.GetString(1),
5959
dataReaderResults.GetString(1),
6060
query, true, true));
6161
}

0 commit comments

Comments
 (0)