Added Features

Feature: Search additional folders by default (shallow search)
Feature: Disable bookmarks
This commit is contained in:
Aaron Campf 2014-03-29 14:32:29 -07:00
parent c076717133
commit 636350c395
8 changed files with 185 additions and 2 deletions

BIN
Doc/Thumbs.db Normal file

Binary file not shown.

View File

@ -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();

View File

@ -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();

View File

@ -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!");
}
}
*/
}
}

View File

@ -53,6 +53,7 @@ namespace Wox.Plugin.SystemPlugins
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
{"AppPathsProgramSource", typeof(AppPathsProgramSource)},
{"FileSystemFolderSourceShallow", typeof(FileSystemFolderSourceShallow)},
};
private PluginInitContext context;

View File

@ -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" />

View File

@ -270,6 +270,10 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick" Content="enable plugin installer"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbEnableBookmarkPlugin" />
<TextBlock Text="Enable Bookmark Plugin" />
</StackPanel>
</StackPanel>
</TabItem>

View File

@ -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) &&