From 3fa3090ee34fda35867a016fc55da3bb2bce47fb Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 30 Jun 2020 06:20:22 +1000 Subject: [PATCH 1/4] Explorer plugin- change DefaultFolderSubtitleString to path --- .../Search/DirectoryInfo/DirectoryInfoSearch.cs | 2 +- .../Search/FolderLinks/QuickFolderAccess.cs | 4 ++-- .../Search/WindowsIndex/IndexSearch.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index b198395b8..02de0eeae 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -65,7 +65,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo if (fileSystemInfo is System.IO.DirectoryInfo) { - folderList.Add(resultManager.CreateFolderResult(fileSystemInfo.Name, Constants.DefaultFolderSubtitleString, fileSystemInfo.FullName, query, true, false)); + folderList.Add(resultManager.CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, fileSystemInfo.FullName, query, true, false)); } else { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs index 689c865c0..ebde039d6 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs @@ -12,7 +12,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks return folderLinks .Select(item => new ResultManager(context) - .CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query)) + .CreateFolderResult(item.Nickname, item.Path, item.Path, query)) .ToList(); string search = query.Search.ToLower(); @@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks return queriedFolderLinks.Select(item => new ResultManager(context) - .CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query)) + .CreateFolderResult(item.Nickname, item.Path, item.Path, query)) .ToList(); } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 5401c2845..c1793b42b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -54,8 +54,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex if (dataReaderResults.GetString(2) == "Directory") { folderResults.Add(resultManager.CreateFolderResult( - dataReaderResults.GetString(0), - Constants.DefaultFolderSubtitleString, + dataReaderResults.GetString(0), + dataReaderResults.GetString(1), dataReaderResults.GetString(1), query, true, true)); } From 492c02eea4660d01d2de89249b3524f9e1e75119 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 30 Jun 2020 06:45:04 +1000 Subject: [PATCH 2/4] add custom plugin ToolTip on result hover over --- Flow.Launcher.Plugin/Result.cs | 10 ++++++++++ Flow.Launcher/ResultListBox.xaml | 4 ++-- Flow.Launcher/ViewModel/ResultViewModel.cs | 8 ++++++++ .../Flow.Launcher.Plugin.Explorer/Search/Constants.cs | 2 +- .../Search/ResultManager.cs | 6 +++++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index bfd2fb0a4..d210ba1d8 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -130,5 +130,15 @@ namespace Flow.Launcher.Plugin /// Plugin ID that generated this result /// public string PluginID { get; internal set; } + + /// + /// Show message as ToolTip on result Title hover over + /// + public string TitleToolTip { get; set; } + + /// + /// Show message as ToolTip on result SubTitle hover over + /// + public string SubTitleToolTip { get; set; } } } \ No newline at end of file diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index a8560c263..3280dc457 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -62,7 +62,7 @@ @@ -71,7 +71,7 @@ - diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 0a9731f18..4392234eb 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -29,6 +29,14 @@ namespace Flow.Launcher.ViewModel public string OpenResultModifiers => Settings.OpenResultModifiers; + public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip) + ? Result.Title + : Result.TitleToolTip; + + public string ShowSubTitleToolTip => string.IsNullOrEmpty(Result.SubTitleToolTip) + ? Result.SubTitle + : Result.SubTitleToolTip; + public ImageSource Image { get diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index 9c8a300bc..5285dfe6e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -16,7 +16,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal const string DifferentUserIconImagePath = "Images\\user.png"; internal const string IndexingOptionsIconImagePath = "Images\\windowsindexingoptions.png"; - internal const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory"; + internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory"; internal const char AllFilesFolderSearchWildcard = '>'; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index e2fd1c7da..dacc57c22 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -38,13 +38,15 @@ namespace Flow.Launcher.Plugin.Explorer.Search return false; } } - + string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ? changeTo : query.ActionKeyword + " " + changeTo); return false; }, + TitleToolTip = Constants.ToolTipOpenDirectory, + SubTitleToolTip = Constants.ToolTipOpenDirectory, ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed } }; } @@ -85,6 +87,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search FilesFolders.OpenPath(retrievedDirectoryPath); return true; }, + TitleToolTip = Constants.ToolTipOpenDirectory, + SubTitleToolTip = Constants.ToolTipOpenDirectory, ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed } }; } From 90b7559d32fb08a96af6931831d84b2f79d43c77 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 30 Jun 2020 07:53:46 +1000 Subject: [PATCH 3/4] show ToolTip directory path on current folder result --- Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index dacc57c22..bfde8c2c7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -87,8 +87,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search FilesFolders.OpenPath(retrievedDirectoryPath); return true; }, - TitleToolTip = Constants.ToolTipOpenDirectory, - SubTitleToolTip = Constants.ToolTipOpenDirectory, + TitleToolTip = retrievedDirectoryPath, + SubTitleToolTip = retrievedDirectoryPath, ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed } }; } From bd645126431378a218a149e90458df4707499c16 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 30 Jun 2020 08:15:10 +1000 Subject: [PATCH 4/4] add open containing folder to file results --- Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs | 8 ++++++++ Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 2 +- .../Search/Constants.cs | 2 ++ .../Search/ResultManager.cs | 12 +++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs index ce067e8a0..98cd777aa 100644 --- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs +++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs @@ -8,6 +8,9 @@ namespace Flow.Launcher.Plugin.SharedCommands public static class FilesFolders { private const string FileExplorerProgramName = "explorer"; + + private const string FileExplorerProgramEXE = "explorer.exe"; + public static void Copy(this string sourcePath, string targetPath) { // Get the subdirectories for the specified directory. @@ -128,6 +131,11 @@ namespace Flow.Launcher.Plugin.SharedCommands } } + public static void OpenContainingFolder(string path) + { + Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\""); + } + /// /// This checks whether a given string is a directory path or network location string. /// It does not check if location actually exists. diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 90a3fb2e8..89dbb3f88 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -156,7 +156,7 @@ namespace Flow.Launcher.Plugin.Explorer { try { - Process.Start("explorer.exe", $" /select,\"{record.FullPath}\""); + FilesFolders.OpenContainingFolder(record.FullPath); } catch (Exception e) { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index 5285dfe6e..d474fb0e7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -18,6 +18,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory"; + internal const string ToolTipOpenContainingFolder = "Ctrl + Enter to open the containing folder"; + internal const char AllFilesFolderSearchWildcard = '>'; internal const char DirectorySeperator = '\\'; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index bfde8c2c7..6a336c59a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -1,6 +1,7 @@ using Flow.Launcher.Infrastructure; using Flow.Launcher.Plugin.SharedCommands; using System; +using System.Diagnostics; using System.IO; using System.Linq; using System.Windows; @@ -105,7 +106,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search { try { - FilesFolders.OpenPath(filePath); + if (c.SpecialKeyState.CtrlPressed) + { + FilesFolders.OpenContainingFolder(filePath); + } + else + { + FilesFolders.OpenPath(filePath); + } } catch (Exception ex) { @@ -114,6 +122,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search return true; }, + TitleToolTip = Constants.ToolTipOpenContainingFolder, + SubTitleToolTip = Constants.ToolTipOpenContainingFolder, ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed } }; return result;