diff --git a/Doc/Thumbs.db b/Doc/Thumbs.db new file mode 100644 index 0000000000..c3da9c149e Binary files /dev/null and b/Doc/Thumbs.db differ diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index 14a223eaf3..f876498dd6 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -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(); diff --git a/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs b/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs index 69f2dd495a..4521a6c062 100644 --- a/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs +++ b/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs @@ -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(); diff --git a/Wox.Plugin.SystemPlugins/ProgramSources/FileSystemFolderSourceShallow.cs b/Wox.Plugin.SystemPlugins/ProgramSources/FileSystemFolderSourceShallow.cs new file mode 100644 index 0000000000..ad2db77bc7 --- /dev/null +++ b/Wox.Plugin.SystemPlugins/ProgramSources/FileSystemFolderSourceShallow.cs @@ -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 + + /// + /// + /// + public class FileSystemFolderSourceShallow : FileSystemProgramSource { + //private static Dictionary parentDirectories = new Dictionary(); + + + public FileSystemFolderSourceShallow(string baseDirectory) + : base(baseDirectory) { } + + public FileSystemFolderSourceShallow(ProgramSource source) + : base(source) { } + + public override List LoadPrograms() { + List list = new List(); + + 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 LoadPrograms() { + List results = new List(); + + 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!"); + } + + } + */ + } +} diff --git a/Wox.Plugin.SystemPlugins/Programs.cs b/Wox.Plugin.SystemPlugins/Programs.cs index 3fec22df92..1ec59f18bd 100644 --- a/Wox.Plugin.SystemPlugins/Programs.cs +++ b/Wox.Plugin.SystemPlugins/Programs.cs @@ -53,6 +53,7 @@ namespace Wox.Plugin.SystemPlugins {"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)}, {"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)}, {"AppPathsProgramSource", typeof(AppPathsProgramSource)}, + {"FileSystemFolderSourceShallow", typeof(FileSystemFolderSourceShallow)}, }; private PluginInitContext context; diff --git a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj index 617ae64cc1..d813bdea13 100644 --- a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj +++ b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj @@ -63,6 +63,7 @@ + diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 4bd481ecc6..f6ef5abbc7 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -62,7 +62,7 @@ - + @@ -271,7 +271,11 @@