diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs index cb1f0d654b..a616edce08 100644 --- a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs +++ b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs @@ -1,21 +1,34 @@ using System.Collections.Generic; using System.Linq; +using System.Windows.Controls; +using Wox.Infrastructure.Storage; using Wox.Plugin.BrowserBookmark.Commands; +using Wox.Plugin.BrowserBookmark.Models; +using Wox.Plugin.BrowserBookmark.Views; using Wox.Plugin.SharedCommands; namespace Wox.Plugin.BrowserBookmark { - public class Main : IPlugin, IReloadable, IPluginI18n + public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, ISavable { private PluginInitContext context; - private List cachedBookmarks = new List(); + private List cachedBookmarks = new List(); + + private readonly Settings _settings; + private readonly PluginJsonStorage _storage; + + public Main() + { + _storage = new PluginJsonStorage(); + _settings = _storage.Load(); + + cachedBookmarks = Bookmarks.LoadAllBookmarks(); + } public void Init(PluginInitContext context) { this.context = context; - - cachedBookmarks = Bookmarks.LoadAllBookmarks(); } public List Query(Query query) @@ -42,8 +55,15 @@ namespace Wox.Plugin.BrowserBookmark Score = 5, Action = (e) => { - context.API.HideApp(); - c.Url.NewBrowserWindow(""); + if (_settings.OpenInNewBrowserWindow) + { + c.Url.NewBrowserWindow(_settings.BrowserPath); + } + else + { + c.Url.NewTabInBrowser(_settings.BrowserPath); + } + return true; } }).ToList(); @@ -66,5 +86,14 @@ namespace Wox.Plugin.BrowserBookmark return context.API.GetTranslation("wox_plugin_browserbookmark_plugin_description"); } + public Control CreateSettingPanel() + { + return new SettingsControl(_settings); + } + + public void Save() + { + _storage.Save(); + } } } diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Models/Settings.cs b/Plugins/Wox.Plugin.BrowserBookmark/Models/Settings.cs new file mode 100644 index 0000000000..41d742fe6b --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Models/Settings.cs @@ -0,0 +1,9 @@ +namespace Wox.Plugin.BrowserBookmark.Models +{ + public class Settings : BaseModel + { + public bool OpenInNewBrowserWindow { get; set; } = true; + + public string BrowserPath { get; set; } + } +} \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Views/SettingsControl.xaml b/Plugins/Wox.Plugin.BrowserBookmark/Views/SettingsControl.xaml new file mode 100644 index 0000000000..93b272fcad --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Views/SettingsControl.xaml @@ -0,0 +1,25 @@ + + + + + + + + + +