Reduce folder plugin results (#5631)
* Reduce folder plugin results * Added warning message * Added UI content for warning message in folder plugin * nit fixes for folder plugin changes * Localised warning message * fix Merge conflicts * nit fixes and move warning to end of results * Add IDisposable interface to folder plugin * Add images to MSI
This commit is contained in:
parent
dcd0ca8daa
commit
1c77887629
|
@ -901,7 +901,7 @@
|
||||||
<?endforeach?>
|
<?endforeach?>
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="FolderImagesComponent" Directory="FolderPluginImagesFolder" Guid="6C5226EB-E312-4768-B4D1-B1D3ACFCCBDF">
|
<Component Id="FolderImagesComponent" Directory="FolderPluginImagesFolder" Guid="6C5226EB-E312-4768-B4D1-B1D3ACFCCBDF">
|
||||||
<?foreach File in copy.dark.png;copy.light.png;delete.dark.png;delete.light.png;file.dark.png;file.light.png;folder.dark.png;folder.light.png;user.dark.png;user.light.png?>
|
<?foreach File in copy.dark.png;copy.light.png;delete.dark.png;delete.light.png;file.dark.png;file.light.png;folder.dark.png;folder.light.png;user.dark.png;user.light.png;Warning.dark.png;Warning.light.png?>
|
||||||
<File Id="FolderPlugin_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\Plugins\Microsoft.Plugin.Folder\Images\$(var.File)" />
|
<File Id="FolderPlugin_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\Plugins\Microsoft.Plugin.Folder\Images\$(var.File)" />
|
||||||
<?endforeach?>
|
<?endforeach?>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -11,5 +11,11 @@ namespace Microsoft.Plugin.Folder
|
||||||
{
|
{
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public List<FolderLink> FolderLinks { get; } = new List<FolderLink>();
|
public List<FolderLink> FolderLinks { get; } = new List<FolderLink>();
|
||||||
|
|
||||||
|
[JsonProperty]
|
||||||
|
public int MaxFolderResults { get; set; } = 50;
|
||||||
|
|
||||||
|
[JsonProperty]
|
||||||
|
public int MaxFileResults { get; set; } = 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 566 B |
Binary file not shown.
After Width: | Height: | Size: 580 B |
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
|
@ -14,4 +14,7 @@
|
||||||
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_copy_path">Copy path (Ctrl+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
|
||||||
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
<system:String x:Key="Microsoft_plugin_folder_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_title">Warning: Folder Plugin Results truncated.</system:String>
|
||||||
|
<system:String x:Key="Microsoft_plugin_folder_truncation_warning_subtitle">Showing {0} of {1} results</system:String>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
|
@ -18,7 +18,7 @@ using Wox.Plugin;
|
||||||
|
|
||||||
namespace Microsoft.Plugin.Folder
|
namespace Microsoft.Plugin.Folder
|
||||||
{
|
{
|
||||||
public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMenu
|
public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMenu, IDisposable
|
||||||
{
|
{
|
||||||
public const string FolderImagePath = "Images\\folder.dark.png";
|
public const string FolderImagePath = "Images\\folder.dark.png";
|
||||||
public const string FileImagePath = "Images\\file.dark.png";
|
public const string FileImagePath = "Images\\file.dark.png";
|
||||||
|
@ -26,14 +26,13 @@ namespace Microsoft.Plugin.Folder
|
||||||
public const string CopyImagePath = "Images\\copy.dark.png";
|
public const string CopyImagePath = "Images\\copy.dark.png";
|
||||||
|
|
||||||
private const string _fileExplorerProgramName = "explorer";
|
private const string _fileExplorerProgramName = "explorer";
|
||||||
|
|
||||||
private static readonly PluginJsonStorage<FolderSettings> _storage = new PluginJsonStorage<FolderSettings>();
|
private static readonly PluginJsonStorage<FolderSettings> _storage = new PluginJsonStorage<FolderSettings>();
|
||||||
private static readonly FolderSettings _settings = _storage.Load();
|
private static readonly FolderSettings _settings = _storage.Load();
|
||||||
|
|
||||||
private static List<string> _driverNames;
|
private static List<string> _driverNames;
|
||||||
private PluginInitContext _context;
|
private static PluginInitContext _context;
|
||||||
|
|
||||||
private IContextMenu _contextMenuLoader;
|
private IContextMenu _contextMenuLoader;
|
||||||
|
private static string warningIconPath;
|
||||||
|
private bool _disposed = false;
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
|
@ -47,9 +46,30 @@ namespace Microsoft.Plugin.Folder
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context ?? throw new ArgumentNullException(nameof(context));
|
||||||
_contextMenuLoader = new ContextMenuLoader(context);
|
_contextMenuLoader = new ContextMenuLoader(context);
|
||||||
InitialDriverList();
|
InitialDriverList();
|
||||||
|
|
||||||
|
_context.API.ThemeChanged += OnThemeChanged;
|
||||||
|
UpdateIconPath(_context.API.GetCurrentTheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateIconPath(Theme theme)
|
||||||
|
{
|
||||||
|
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
|
||||||
|
{
|
||||||
|
warningIconPath = "Images/Warning.light.png";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
warningIconPath = "Images/Warning.dark.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "The parameter is unused")]
|
||||||
|
private void OnThemeChanged(Theme _, Theme newTheme)
|
||||||
|
{
|
||||||
|
UpdateIconPath(newTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Do not want to change the behavior of the application, but want to enforce static analysis")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Do not want to change the behavior of the application, but want to enforce static analysis")]
|
||||||
|
@ -253,8 +273,28 @@ namespace Microsoft.Plugin.Folder
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
|
results = results.Concat(folderList.OrderBy(x => x.Title).Take(_settings.MaxFolderResults)).Concat(fileList.OrderBy(x => x.Title).Take(_settings.MaxFileResults)).ToList();
|
||||||
return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList();
|
|
||||||
|
// Show warning message if result has been truncated
|
||||||
|
if (folderList.Count > _settings.MaxFolderResults || fileList.Count > _settings.MaxFileResults)
|
||||||
|
{
|
||||||
|
var preTruncationCount = folderList.Count + fileList.Count;
|
||||||
|
var postTruncationCount = Math.Min(folderList.Count, _settings.MaxFolderResults) + Math.Min(fileList.Count, _settings.MaxFileResults);
|
||||||
|
results.Add(CreateTruncatedItemsResult(search, preTruncationCount, postTruncationCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
return results.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Result CreateTruncatedItemsResult(string search, int preTruncationCount, int postTruncationCount)
|
||||||
|
{
|
||||||
|
return new Result
|
||||||
|
{
|
||||||
|
Title = _context.API.GetTranslation("Microsoft_plugin_folder_truncation_warning_title"),
|
||||||
|
QueryTextDisplay = search,
|
||||||
|
SubTitle = string.Format(CultureInfo.InvariantCulture, _context.API.GetTranslation("Microsoft_plugin_folder_truncation_warning_subtitle"), postTruncationCount, preTruncationCount),
|
||||||
|
IcoPath = warningIconPath,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alve and instead inform the user of the error")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alve and instead inform the user of the error")]
|
||||||
|
@ -330,5 +370,23 @@ namespace Microsoft.Plugin.Folder
|
||||||
public void UpdateSettings(PowerLauncherSettings settings)
|
public void UpdateSettings(PowerLauncherSettings settings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,12 @@
|
||||||
<None Update="Images\user.light.png">
|
<None Update="Images\user.light.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Images\Warning.dark.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Images\Warning.light.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||||
|
|
Loading…
Reference in a new issue