mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
Added Features
Feature: Search additional folders by default (shallow search) Feature: Disable bookmarks
This commit is contained in:
parent
c076717133
commit
636350c395
BIN
Doc/Thumbs.db
Normal file
BIN
Doc/Thumbs.db
Normal file
Binary file not shown.
@ -56,6 +56,9 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
[JsonProperty]
|
||||
public bool EnablePythonPlugins { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool EnableBookmarkPlugin { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double Opacity { get; set; }
|
||||
|
||||
@ -122,6 +125,7 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
protected override void LoadDefaultConfig()
|
||||
{
|
||||
EnablePythonPlugins = true;
|
||||
EnableBookmarkPlugin = true;
|
||||
Theme = "Dark";
|
||||
ReplaceWinR = true;
|
||||
WebSearches = LoadDefaultWebSearches();
|
||||
|
@ -49,6 +49,11 @@ namespace Wox.Plugin.SystemPlugins
|
||||
|
||||
protected override void InitInternal(PluginInitContext context)
|
||||
{
|
||||
if (!Wox.Infrastructure.Storage.UserSettings.UserSettingStorage.Instance.EnableBookmarkPlugin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarks.Clear();
|
||||
LoadChromeBookmarks();
|
||||
|
||||
|
@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
using Wox.Plugin.SystemPlugins.ProgramSources;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.ProgramSources {
|
||||
//TODO: Create Deep Version that grabs all subfolders like FileSystemProgramSource
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class FileSystemFolderSourceShallow : FileSystemProgramSource {
|
||||
//private static Dictionary<string, DirectoryInfo[]> parentDirectories = new Dictionary<string, DirectoryInfo[]>();
|
||||
|
||||
|
||||
public FileSystemFolderSourceShallow(string baseDirectory)
|
||||
: base(baseDirectory) { }
|
||||
|
||||
public FileSystemFolderSourceShallow(ProgramSource source)
|
||||
: base(source) { }
|
||||
|
||||
public override List<Program> LoadPrograms() {
|
||||
List<Program> list = new List<Program>();
|
||||
|
||||
foreach (var Folder in Directory.GetDirectories(BaseDirectory)) {
|
||||
list.Add(CreateEntry(Folder));
|
||||
}
|
||||
|
||||
|
||||
foreach (string file in Directory.GetFiles(base.BaseDirectory)) {
|
||||
if (Suffixes.Any(o => file.EndsWith("." + o))) {
|
||||
list.Add(CreateEntry(file));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
return typeof(UserStartMenuProgramSource).Name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public class FolderSource : IProgramSource {
|
||||
private PluginInitContext context;
|
||||
public string Location { get; set; }
|
||||
public int BonusPoints { get; set; }
|
||||
|
||||
public FolderSource(string Location) {
|
||||
this.Location = Location;
|
||||
}
|
||||
|
||||
public List<Program> LoadPrograms() {
|
||||
List<Result> results = new List<Result>();
|
||||
|
||||
if (Directory.Exists(Location)) {
|
||||
// show all child directory
|
||||
if (Location.EndsWith("\\") || Location.EndsWith("/")) {
|
||||
var dirInfo = new DirectoryInfo(Location);
|
||||
var dirs = dirInfo.GetDirectories();
|
||||
|
||||
var parentDirKey = Location.TrimEnd('\\', '/');
|
||||
if (!parentDirectories.ContainsKey(parentDirKey))
|
||||
parentDirectories.Add(parentDirKey, dirs);
|
||||
|
||||
foreach (var dir in dirs) {
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
continue;
|
||||
|
||||
var dirPath = dir.FullName;
|
||||
Result result = new Result {
|
||||
Title = dir.Name,
|
||||
IcoPath = "Images/folder.png",
|
||||
Action = (c) => {
|
||||
context.ChangeQuery(dirPath);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
if (results.Count == 0) {
|
||||
Result result = new Result {
|
||||
Title = "Open this directory",
|
||||
SubTitle = "No files in this directory",
|
||||
IcoPath = "Images/folder.png",
|
||||
Action = (c) => {
|
||||
Process.Start(Location);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Result result = new Result {
|
||||
Title = "Open this directory",
|
||||
SubTitle = string.Format("path: {0}", Location),
|
||||
Score = 50,
|
||||
IcoPath = "Images/folder.png",
|
||||
Action = (c) => {
|
||||
Process.Start(Location);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// change to search in current directory
|
||||
var parentDir = Path.GetDirectoryName(Location);
|
||||
if (!string.IsNullOrEmpty(parentDir) && results.Count == 0) {
|
||||
parentDir = parentDir.TrimEnd('\\', '/');
|
||||
if (parentDirectories.ContainsKey(parentDir)) {
|
||||
|
||||
var dirs = parentDirectories[parentDir];
|
||||
var queryFileName = Path.GetFileName(Location).ToLower();
|
||||
var fuzzy = FuzzyMatcher.Create(queryFileName);
|
||||
foreach (var dir in dirs) {
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
continue;
|
||||
|
||||
var matchResult = fuzzy.Evaluate(dir.Name);
|
||||
if (!matchResult.Success)
|
||||
continue;
|
||||
|
||||
var dirPath = dir.FullName;
|
||||
Result result = new Result {
|
||||
Title = dir.Name,
|
||||
IcoPath = "Images/folder.png",
|
||||
Score = matchResult.Score,
|
||||
Action = (c) => {
|
||||
context.ChangeQuery(dirPath);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw new Exception("Debug this!");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
@ -53,6 +53,7 @@ namespace Wox.Plugin.SystemPlugins
|
||||
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
|
||||
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
|
||||
{"AppPathsProgramSource", typeof(AppPathsProgramSource)},
|
||||
{"FileSystemFolderSourceShallow", typeof(FileSystemFolderSourceShallow)},
|
||||
};
|
||||
private PluginInitContext context;
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
||||
</Compile>
|
||||
<Compile Include="ProgramSources\AppPathsProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\FileSystemFolderSourceShallow.cs" />
|
||||
<Compile Include="ProgramSources\PortableAppsProgramSource.cs" />
|
||||
<Compile Include="IProgramSource.cs" />
|
||||
<Compile Include="BaseSystemPlugin.cs" />
|
||||
|
@ -62,7 +62,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" ToolTip="{Binding Name}" x:Name="tbTitle" Text="{Binding Name}"></TextBlock>
|
||||
<TextBlock ToolTip="{Binding Description}" Visibility="{Binding Description, Converter={wox:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding Description}" Opacity="0.5"></TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type woxPlugin:PluginPair}">
|
||||
@ -271,7 +271,11 @@
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick" Content="enable plugin installer"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<CheckBox x:Name="cbEnableBookmarkPlugin" />
|
||||
<TextBlock Text="Enable Bookmark Plugin" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
|
@ -67,6 +67,15 @@ namespace Wox
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
cbEnableBookmarkPlugin.Checked += (o, e) => {
|
||||
UserSettingStorage.Instance.EnableBookmarkPlugin = true;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
cbEnableBookmarkPlugin.Unchecked += (o, e) => {
|
||||
UserSettingStorage.Instance.EnableBookmarkPlugin = false;
|
||||
UserSettingStorage.Instance.Save();
|
||||
};
|
||||
|
||||
#region Load Theme Data
|
||||
|
||||
if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) &&
|
||||
|
Loading…
Reference in New Issue
Block a user