mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
explorer general touch ups- no logic change
This commit is contained in:
parent
0ee0fb8d2b
commit
5d696bd3ab
12 changed files with 131 additions and 95 deletions
|
|
@ -261,7 +261,7 @@ namespace Flow.Launcher.Test.Plugins
|
||||||
public void GivenDirectoryInfoSearch_WhenSearchPatternHotKeyIsSearchAll_ThenSearchCriteriaShouldUseCriteriaString(string path, string expectedString)
|
public void GivenDirectoryInfoSearch_WhenSearchPatternHotKeyIsSearchAll_ThenSearchCriteriaShouldUseCriteriaString(string path, string expectedString)
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
var criteriaConstructor = new DirectoryInfoSearch(new Settings());
|
var criteriaConstructor = new DirectoryInfoSearch(new PluginInitContext());
|
||||||
|
|
||||||
//When
|
//When
|
||||||
var resultString = criteriaConstructor.ConstructSearchCriteria(path);
|
var resultString = criteriaConstructor.ConstructSearchCriteria(path);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,16 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
internal class ContextMenu : IContextMenu
|
internal class ContextMenu : IContextMenu
|
||||||
{
|
{
|
||||||
|
private PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
|
private Settings Settings { get; set; }
|
||||||
|
|
||||||
|
public ContextMenu(PluginInitContext context, Settings settings)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
Settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Result> LoadContextMenus(Result selectedResult)
|
public List<Result> LoadContextMenus(Result selectedResult)
|
||||||
{
|
{
|
||||||
var contextMenus = new List<Result>();
|
var contextMenus = new List<Result>();
|
||||||
|
|
@ -50,7 +60,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var message = "Fail to set text in clipboard";
|
var message = "Fail to set text in clipboard";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
Main.Context.API.ShowMsg(message);
|
Context.API.ShowMsg(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -72,7 +82,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var message = $"Fail to set {fileOrFolder} in clipboard";
|
var message = $"Fail to set {fileOrFolder} in clipboard";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
Main.Context.API.ShowMsg(message);
|
Context.API.ShowMsg(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +108,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var message = $"Fail to delete {fileOrFolder} at {record.FullPath}";
|
var message = $"Fail to delete {fileOrFolder} at {record.FullPath}";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
Main.Context.API.ShowMsg(message);
|
Context.API.ShowMsg(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,7 +131,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var name = "Plugin: Folder";
|
var name = "Plugin: Folder";
|
||||||
var message = $"File not found: {e.Message}";
|
var message = $"File not found: {e.Message}";
|
||||||
Main.Context.API.ShowMsg(name, message);
|
Context.API.ShowMsg(name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -148,7 +158,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var message = $"Fail to open file at {record.FullPath}";
|
var message = $"Fail to open file at {record.FullPath}";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
Main.Context.API.ShowMsg(message);
|
Context.API.ShowMsg(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,7 +187,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
var message = $"Fail to editor for file at {record.FullPath}";
|
var message = $"Fail to editor for file at {record.FullPath}";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
Main.Context.API.ShowMsg(message);
|
Context.API.ShowMsg(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -193,8 +203,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
SubTitle = "Path: " + record.FullPath,
|
SubTitle = "Path: " + record.FullPath,
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath))
|
if(!Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath))
|
||||||
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(new FolderLink { Path = record.FullPath });
|
Settings.IndexSearchExcludedSubdirectoryPaths.Add(new FolderLink { Path = record.FullPath });
|
||||||
|
|
||||||
var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString());
|
var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString());
|
||||||
|
|
||||||
|
|
@ -202,10 +212,10 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
Main.Context.API.ShowMsg("Excluded from Index Search", "Path: " + record.FullPath, iconPath);
|
Context.API.ShowMsg("Excluded from Index Search", "Path: " + record.FullPath, iconPath);
|
||||||
|
|
||||||
// so the new path can be persisted to storage and not wait till next ViewModel save.
|
// so the new path can be persisted to storage and not wait till next ViewModel save.
|
||||||
Main.Context.API.SaveAppAllSettings();
|
Context.API.SaveAppAllSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -3,37 +3,36 @@ using Flow.Launcher.Plugin.Explorer.Search;
|
||||||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||||
using Flow.Launcher.Plugin.Explorer.Views;
|
using Flow.Launcher.Plugin.Explorer.Views;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer
|
namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu //, IPluginI18n <=== do later
|
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu //, IPluginI18n <=== do later
|
||||||
{
|
{
|
||||||
internal static PluginInitContext Context { get; set; }
|
internal PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
internal static Settings Settings;
|
internal Settings Settings;
|
||||||
|
|
||||||
private SettingsViewModel _viewModel;
|
private SettingsViewModel viewModel;
|
||||||
|
|
||||||
private IContextMenu _contextMenu;
|
private IContextMenu contextMenu;
|
||||||
|
|
||||||
public Control CreateSettingPanel()
|
public Control CreateSettingPanel()
|
||||||
{
|
{
|
||||||
return new ExplorerSettings();
|
return new ExplorerSettings(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
_viewModel = new SettingsViewModel();
|
viewModel = new SettingsViewModel(context);
|
||||||
Settings = _viewModel.Settings;
|
Settings = viewModel.Settings;
|
||||||
_contextMenu = new ContextMenu();
|
contextMenu = new ContextMenu(Context, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Result> LoadContextMenus(Result selectedResult)
|
public List<Result> LoadContextMenus(Result selectedResult)
|
||||||
{
|
{
|
||||||
return _contextMenu.LoadContextMenus(selectedResult);
|
return contextMenu.LoadContextMenus(selectedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Result> Query(Query query)
|
public List<Result> Query(Query query)
|
||||||
|
|
@ -48,7 +47,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
_viewModel.Save();
|
viewModel.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
||||||
{
|
{
|
||||||
public class DirectoryInfoSearch
|
public class DirectoryInfoSearch
|
||||||
{
|
{
|
||||||
private Settings _settings;
|
private readonly ResultManager resultManager;
|
||||||
|
|
||||||
public DirectoryInfoSearch(Settings settings)
|
public DirectoryInfoSearch(PluginInitContext context)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
resultManager = new ResultManager(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<Result> TopLevelDirectorySearch(Query query, string search)
|
internal List<Result> TopLevelDirectorySearch(Query query, string search)
|
||||||
|
|
@ -66,11 +66,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
||||||
|
|
||||||
if (fileSystemInfo is System.IO.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, Constants.DefaultFolderSubtitleString, fileSystemInfo.FullName, query, true, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileList.Add(ResultManager.CreateFileResult(fileSystemInfo.FullName, query, true, false));
|
fileList.Add(resultManager.CreateFileResult(fileSystemInfo.FullName, query, true, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return environmentVariablePath;
|
return environmentVariablePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Result> GetEnvironmentStringPathSuggestions(string querySearch, Query query)
|
internal static List<Result> GetEnvironmentStringPathSuggestions(string querySearch, Query query, PluginInitContext context)
|
||||||
{
|
{
|
||||||
var results = new List<Result>();
|
var results = new List<Result>();
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
var expandedPath = environmentVariables[search];
|
var expandedPath = environmentVariables[search];
|
||||||
|
|
||||||
results.Add(ResultManager.CreateFolderResult($"%{search}%", expandedPath, expandedPath, query));
|
results.Add(new ResultManager(context).CreateFolderResult($"%{search}%", expandedPath, expandedPath, query));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +81,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
if (p.Key.StartsWith(search))
|
if (p.Key.StartsWith(search))
|
||||||
{
|
{
|
||||||
results.Add(ResultManager.CreateFolderResult($"%{p.Key}%", p.Value, p.Value, query));
|
results.Add(new ResultManager(context).CreateFolderResult($"%{p.Key}%", p.Value, p.Value, query));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
|
||||||
{
|
{
|
||||||
public class QuickFolderAccess
|
public class QuickFolderAccess
|
||||||
{
|
{
|
||||||
internal List<Result> FolderList(Query query, List<FolderLink> folderLinks)
|
internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, PluginInitContext context)
|
||||||
{
|
{
|
||||||
string search = query.Search.ToLower();
|
string search = query.Search.ToLower();
|
||||||
var userFolderLinks = folderLinks.Where(
|
var userFolderLinks = folderLinks.Where(
|
||||||
x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
|
x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
|
||||||
var results = userFolderLinks.Select(item =>
|
var results = userFolderLinks.Select(item =>
|
||||||
ResultManager.CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query)).ToList();
|
new ResultManager(context).CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query)).ToList();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
using Flow.Launcher.Infrastructure;
|
using Flow.Launcher.Infrastructure;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer.Search
|
namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
internal static class ResultManager
|
public class ResultManager
|
||||||
{
|
{
|
||||||
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, bool showIndexState = false, bool windowsIndexed = false)
|
private readonly PluginInitContext context;
|
||||||
|
|
||||||
|
public ResultManager(PluginInitContext context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
internal Result CreateFolderResult(string title, string subtitle, string path, Query query, bool showIndexState = false, bool windowsIndexed = false)
|
||||||
{
|
{
|
||||||
return new Result
|
return new Result
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +40,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
}
|
}
|
||||||
|
|
||||||
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
|
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
|
||||||
Main.Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ?
|
context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ?
|
||||||
changeTo :
|
changeTo :
|
||||||
query.ActionKeyword + " " + changeTo);
|
query.ActionKeyword + " " + changeTo);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -45,7 +49,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
internal Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
||||||
{
|
{
|
||||||
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
||||||
|
|
||||||
|
|
@ -85,7 +89,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Result CreateFileResult(string filePath, Query query, bool showIndexState = false, bool windowsIndexed = false)
|
internal Result CreateFileResult(string filePath, Query query, bool showIndexState = false, bool windowsIndexed = false)
|
||||||
{
|
{
|
||||||
var result = new Result
|
var result = new Result
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
|
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
|
|
@ -10,25 +10,29 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
{
|
{
|
||||||
public class SearchManager
|
public class SearchManager
|
||||||
{
|
{
|
||||||
private Settings _settings;
|
private readonly PluginInitContext context;
|
||||||
private PluginInitContext _context;
|
|
||||||
|
|
||||||
private IndexSearch _indexSearch;
|
private readonly IndexSearch indexSearch;
|
||||||
|
|
||||||
private QuickFolderAccess quickFolderAccess = new QuickFolderAccess();
|
private readonly QuickFolderAccess quickFolderAccess = new QuickFolderAccess();
|
||||||
|
|
||||||
|
private readonly ResultManager resultManager;
|
||||||
|
|
||||||
|
private readonly Settings settings;
|
||||||
|
|
||||||
public SearchManager(Settings settings, PluginInitContext context)
|
public SearchManager(Settings settings, PluginInitContext context)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
this.context = context;
|
||||||
_context = context;
|
indexSearch = new IndexSearch(context);
|
||||||
_indexSearch = new IndexSearch();
|
resultManager = new ResultManager(context);
|
||||||
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<Result> Search(Query query)
|
internal List<Result> Search(Query query)
|
||||||
{
|
{
|
||||||
var querySearch = query.Search;
|
var querySearch = query.Search;
|
||||||
|
|
||||||
var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.QuickFolderAccessLinks);
|
var quickFolderLinks = quickFolderAccess.FolderList(query, settings.QuickFolderAccessLinks, context);
|
||||||
|
|
||||||
if (quickFolderLinks.Count > 0)
|
if (quickFolderLinks.Count > 0)
|
||||||
return quickFolderLinks;
|
return quickFolderLinks;
|
||||||
|
|
@ -40,7 +44,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
if (EnvironmentVariables.IsEnvironmentVariableSearch(locationPath))
|
if (EnvironmentVariables.IsEnvironmentVariableSearch(locationPath))
|
||||||
{
|
{
|
||||||
return EnvironmentVariables.GetEnvironmentStringPathSuggestions(locationPath, query);
|
return EnvironmentVariables.GetEnvironmentStringPathSuggestions(locationPath, query, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
|
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
|
||||||
|
|
@ -56,7 +60,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
|
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
|
||||||
|
|
||||||
results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
|
results.Add(resultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
|
||||||
|
|
||||||
results.AddRange(TopLevelDirectorySearchBehaviour(WindowsIndexTopLevelFolderSearch,
|
results.AddRange(TopLevelDirectorySearchBehaviour(WindowsIndexTopLevelFolderSearch,
|
||||||
DirectoryInfoClassSearch,
|
DirectoryInfoClassSearch,
|
||||||
|
|
@ -69,7 +73,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
private List<Result> DirectoryInfoClassSearch(Query query, string querySearch)
|
private List<Result> DirectoryInfoClassSearch(Query query, string querySearch)
|
||||||
{
|
{
|
||||||
var directoryInfoSearch = new DirectoryInfoSearch(_settings);
|
var directoryInfoSearch = new DirectoryInfoSearch(context);
|
||||||
|
|
||||||
return directoryInfoSearch.TopLevelDirectorySearch(query, querySearch);
|
return directoryInfoSearch.TopLevelDirectorySearch(query, querySearch);
|
||||||
}
|
}
|
||||||
|
|
@ -89,9 +93,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
private List<Result> WindowsIndexFilesAndFoldersSearch(Query query, string querySearchString)
|
private List<Result> WindowsIndexFilesAndFoldersSearch(Query query, string querySearchString)
|
||||||
{
|
{
|
||||||
var queryConstructor = new QueryConstructor(_settings);
|
var queryConstructor = new QueryConstructor(settings);
|
||||||
|
|
||||||
return _indexSearch.WindowsIndexSearch(querySearchString,
|
return indexSearch.WindowsIndexSearch(querySearchString,
|
||||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||||
queryConstructor.QueryForAllFilesAndFolders,
|
queryConstructor.QueryForAllFilesAndFolders,
|
||||||
query);
|
query);
|
||||||
|
|
@ -99,9 +103,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
private List<Result> WindowsIndexTopLevelFolderSearch(Query query, string path)
|
private List<Result> WindowsIndexTopLevelFolderSearch(Query query, string path)
|
||||||
{
|
{
|
||||||
var queryConstructor = new QueryConstructor(_settings);
|
var queryConstructor = new QueryConstructor(settings);
|
||||||
|
|
||||||
return _indexSearch.WindowsIndexSearch(path,
|
return indexSearch.WindowsIndexSearch(path,
|
||||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||||
query);
|
query);
|
||||||
|
|
@ -109,14 +113,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
|
|
||||||
private bool UseWindowsIndexForDirectorySearch(string locationPath)
|
private bool UseWindowsIndexForDirectorySearch(string locationPath)
|
||||||
{
|
{
|
||||||
if (!_settings.UseWindowsIndexForDirectorySearch)
|
if (!settings.UseWindowsIndexForDirectorySearch)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_settings.IndexSearchExcludedSubdirectoryPaths
|
if (settings.IndexSearchExcludedSubdirectoryPaths
|
||||||
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x.Path)))
|
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).StartsWith(x.Path)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return _indexSearch.PathIsIndexed(locationPath);
|
return indexSearch.PathIsIndexed(locationPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
||||||
{
|
{
|
||||||
private readonly object _lock = new object();
|
private readonly object _lock = new object();
|
||||||
|
|
||||||
public OleDbConnection conn;
|
private OleDbConnection conn;
|
||||||
|
|
||||||
public OleDbCommand command;
|
private OleDbCommand command;
|
||||||
|
|
||||||
public OleDbDataReader dataReaderResults;
|
private OleDbDataReader dataReaderResults;
|
||||||
|
|
||||||
|
private readonly ResultManager resultManager;
|
||||||
|
|
||||||
// Reserved keywords in oleDB
|
// Reserved keywords in oleDB
|
||||||
private string ReservedStringPattern = @"^[\/\\\$\%]+$";
|
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$";
|
||||||
|
|
||||||
|
internal IndexSearch(PluginInitContext context)
|
||||||
|
{
|
||||||
|
resultManager = new ResultManager(context);
|
||||||
|
}
|
||||||
|
|
||||||
internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string connectionString, Query query)
|
internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string connectionString, Query query)
|
||||||
{
|
{
|
||||||
|
|
@ -71,16 +78,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
||||||
private Result CreateResult(string filename, string path, string fileType, Query query)
|
private Result CreateResult(string filename, string path, string fileType, Query query)
|
||||||
{
|
{
|
||||||
if (fileType == "Directory")
|
if (fileType == "Directory")
|
||||||
return ResultManager.CreateFolderResult(filename, Constants.DefaultFolderSubtitleString, path, query, true, true);
|
return resultManager.CreateFolderResult(filename, Constants.DefaultFolderSubtitleString, path, query, true, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ResultManager.CreateFileResult(path, query, true, true);
|
return resultManager.CreateFileResult(path, query, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery, Query query)
|
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery, Query query)
|
||||||
{
|
{
|
||||||
var regexMatch = Regex.Match(searchString, ReservedStringPattern);
|
var regexMatch = Regex.Match(searchString, reservedStringPattern);
|
||||||
|
|
||||||
if (regexMatch.Success)
|
if (regexMatch.Success)
|
||||||
return new List<Result>();
|
return new List<Result>();
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
||||||
{
|
{
|
||||||
public class QueryConstructor
|
public class QueryConstructor
|
||||||
{
|
{
|
||||||
private Settings _settings;
|
private readonly Settings settings;
|
||||||
|
|
||||||
private const string SystemIndex = "SystemIndex";
|
private const string SystemIndex = "SystemIndex";
|
||||||
|
|
||||||
public QueryConstructor(Settings settings)
|
public QueryConstructor(Settings settings)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CSearchQueryHelper CreateBaseQuery()
|
public CSearchQueryHelper CreateBaseQuery()
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
||||||
var baseQuery = CreateQueryHelper();
|
var baseQuery = CreateQueryHelper();
|
||||||
|
|
||||||
// Set the number of results we want. Don't set this property if all results are needed.
|
// Set the number of results we want. Don't set this property if all results are needed.
|
||||||
baseQuery.QueryMaxResults = _settings.MaxResult;
|
baseQuery.QueryMaxResults = settings.MaxResult;
|
||||||
|
|
||||||
// Set list of columns we want to display, getting the path presently
|
// Set list of columns we want to display, getting the path presently
|
||||||
baseQuery.QuerySelectColumns = "System.FileName, System.ItemPathDisplay, System.ItemType";
|
baseQuery.QuerySelectColumns = "System.FileName, System.ItemPathDisplay, System.ItemType";
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
||||||
///</summary>
|
///</summary>
|
||||||
public string QueryForTopLevelDirectorySearch(string path)
|
public string QueryForTopLevelDirectorySearch(string path)
|
||||||
{
|
{
|
||||||
string query = "SELECT TOP " + _settings.MaxResult + $" {CreateBaseQuery().QuerySelectColumns} FROM {SystemIndex} WHERE ";
|
string query = "SELECT TOP " + settings.MaxResult + $" {CreateBaseQuery().QuerySelectColumns} FROM {SystemIndex} WHERE ";
|
||||||
|
|
||||||
if (path.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > path.LastIndexOf(Constants.DirectorySeperator))
|
if (path.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > path.LastIndexOf(Constants.DirectorySeperator))
|
||||||
return query + QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(path);
|
return query + QueryWhereRestrictionsForTopLevelDirectoryAllFilesAndFoldersSearch(path);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Flow.Launcher.Infrastructure.Storage;
|
using Flow.Launcher.Infrastructure.Storage;
|
||||||
|
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -7,19 +8,26 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
||||||
{
|
{
|
||||||
public class SettingsViewModel
|
public class SettingsViewModel
|
||||||
{
|
{
|
||||||
private readonly PluginJsonStorage<Settings> _storage;
|
private readonly PluginJsonStorage<Settings> storage;
|
||||||
|
|
||||||
public Settings Settings { get; set; }
|
internal Settings Settings { get; set; }
|
||||||
|
|
||||||
public SettingsViewModel()
|
internal PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
|
public SettingsViewModel(PluginInitContext context)
|
||||||
{
|
{
|
||||||
_storage = new PluginJsonStorage<Settings>();
|
Context = context;
|
||||||
Settings = _storage.Load();
|
storage = new PluginJsonStorage<Settings>();
|
||||||
|
Settings = storage.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
_storage.Save();
|
storage.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void RemoveFolderLinkFromQuickFolders(FolderLink selectedRow) => Settings.QuickFolderAccessLinks.Remove(selectedRow);
|
||||||
|
|
||||||
|
internal void RemoveFolderLinkFromExcludedIndexPaths(FolderLink selectedRow) => Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
|
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
|
||||||
|
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
@ -18,13 +19,16 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ExplorerSettings
|
public partial class ExplorerSettings
|
||||||
{
|
{
|
||||||
public ExplorerSettings()
|
private readonly SettingsViewModel viewModel;
|
||||||
|
public ExplorerSettings(SettingsViewModel viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
lbxFolderLinks.ItemsSource = Main.Settings.QuickFolderAccessLinks;
|
this.viewModel = viewModel;
|
||||||
|
|
||||||
lbxExcludedPaths.ItemsSource = Main.Settings.IndexSearchExcludedSubdirectoryPaths;
|
lbxFolderLinks.ItemsSource = this.viewModel.Settings.QuickFolderAccessLinks;
|
||||||
|
|
||||||
|
lbxExcludedPaths.ItemsSource = this.viewModel.Settings.IndexSearchExcludedSubdirectoryPaths;
|
||||||
|
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
|
|
@ -106,22 +110,22 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
if (selectedRow != null)
|
if (selectedRow != null)
|
||||||
{
|
{
|
||||||
string msg = string.Format(Main.Context.API.GetTranslation("flowlauncher_plugin_folder_delete_folder_link"), selectedRow.Path);
|
string msg = string.Format(viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_delete_folder_link"), selectedRow.Path);
|
||||||
|
|
||||||
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
if (expFolderLinks.IsExpanded)
|
if (expFolderLinks.IsExpanded)
|
||||||
Main.Settings.QuickFolderAccessLinks.Remove(selectedRow);
|
viewModel.RemoveFolderLinkFromQuickFolders(selectedRow);
|
||||||
|
|
||||||
if (expExcludedPaths.IsExpanded)
|
if (expExcludedPaths.IsExpanded)
|
||||||
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
|
viewModel.RemoveFolderLinkFromExcludedIndexPaths(selectedRow);
|
||||||
|
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string warning = Main.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
|
string warning = viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
|
||||||
MessageBox.Show(warning);
|
MessageBox.Show(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,13 +142,13 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
{
|
{
|
||||||
if (expFolderLinks.IsExpanded)
|
if (expFolderLinks.IsExpanded)
|
||||||
{
|
{
|
||||||
var link = Main.Settings.QuickFolderAccessLinks.First(x => x.Path == selectedRow.Path);
|
var link = viewModel.Settings.QuickFolderAccessLinks.First(x => x.Path == selectedRow.Path);
|
||||||
link.Path = folderBrowserDialog.SelectedPath;
|
link.Path = folderBrowserDialog.SelectedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expExcludedPaths.IsExpanded)
|
if (expExcludedPaths.IsExpanded)
|
||||||
{
|
{
|
||||||
var link = Main.Settings.IndexSearchExcludedSubdirectoryPaths.First(x => x.Path == selectedRow.Path);
|
var link = viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.First(x => x.Path == selectedRow.Path);
|
||||||
link.Path = folderBrowserDialog.SelectedPath;
|
link.Path = folderBrowserDialog.SelectedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +157,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string warning = Main.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
|
string warning = viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
|
||||||
MessageBox.Show(warning);
|
MessageBox.Show(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,8 +184,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
|
|
||||||
if (files != null && files.Count() > 0)
|
if (files != null && files.Count() > 0)
|
||||||
{
|
{
|
||||||
if (expFolderLinks.IsExpanded && Main.Settings.QuickFolderAccessLinks == null)
|
if (expFolderLinks.IsExpanded && viewModel.Settings.QuickFolderAccessLinks == null)
|
||||||
Main.Settings.QuickFolderAccessLinks = new List<FolderLink>();
|
viewModel.Settings.QuickFolderAccessLinks = new List<FolderLink>();
|
||||||
|
|
||||||
foreach (string s in files)
|
foreach (string s in files)
|
||||||
{
|
{
|
||||||
|
|
@ -203,21 +207,21 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
private void AddFolderLink(FolderLink newFolderLink)
|
private void AddFolderLink(FolderLink newFolderLink)
|
||||||
{
|
{
|
||||||
if (expFolderLinks.IsExpanded
|
if (expFolderLinks.IsExpanded
|
||||||
&& !Main.Settings.QuickFolderAccessLinks.Any(x => x.Path == newFolderLink.Path))
|
&& !viewModel.Settings.QuickFolderAccessLinks.Any(x => x.Path == newFolderLink.Path))
|
||||||
{
|
{
|
||||||
if (Main.Settings.QuickFolderAccessLinks == null)
|
if (viewModel.Settings.QuickFolderAccessLinks == null)
|
||||||
Main.Settings.QuickFolderAccessLinks = new List<FolderLink>();
|
viewModel.Settings.QuickFolderAccessLinks = new List<FolderLink>();
|
||||||
|
|
||||||
Main.Settings.QuickFolderAccessLinks.Add(newFolderLink);
|
viewModel.Settings.QuickFolderAccessLinks.Add(newFolderLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expExcludedPaths.IsExpanded
|
if (expExcludedPaths.IsExpanded
|
||||||
&& !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == newFolderLink.Path))
|
&& !viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == newFolderLink.Path))
|
||||||
{
|
{
|
||||||
if (Main.Settings.IndexSearchExcludedSubdirectoryPaths == null)
|
if (viewModel.Settings.IndexSearchExcludedSubdirectoryPaths == null)
|
||||||
Main.Settings.IndexSearchExcludedSubdirectoryPaths = new List<FolderLink>();
|
viewModel.Settings.IndexSearchExcludedSubdirectoryPaths = new List<FolderLink>();
|
||||||
|
|
||||||
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(newFolderLink);
|
viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.Add(newFolderLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue