11using System . Collections . Generic ;
22using System . Linq ;
3+ using System . Windows . Controls ;
4+ using Wox . Infrastructure . Storage ;
35using Wox . Plugin . BrowserBookmark . Commands ;
6+ using Wox . Plugin . BrowserBookmark . Models ;
7+ using Wox . Plugin . BrowserBookmark . Views ;
48using Wox . Plugin . SharedCommands ;
59
610namespace Wox . Plugin . BrowserBookmark
711{
8- public class Main : IPlugin , IReloadable , IPluginI18n
12+ public class Main : ISettingProvider , IPlugin , IReloadable , IPluginI18n , ISavable
913 {
1014 private PluginInitContext context ;
1115
12- private List < Bookmark > cachedBookmarks = new List < Bookmark > ( ) ;
16+ private List < Bookmark > cachedBookmarks = new List < Bookmark > ( ) ;
1317
14- public void Init ( PluginInitContext context )
18+ private readonly Settings _settings ;
19+ private readonly PluginJsonStorage < Settings > _storage ;
20+
21+ public Main ( )
1522 {
16- this . context = context ;
23+ _storage = new PluginJsonStorage < Settings > ( ) ;
24+ _settings = _storage . Load ( ) ;
1725
1826 cachedBookmarks = Bookmarks . LoadAllBookmarks ( ) ;
1927 }
2028
29+ public void Init ( PluginInitContext context )
30+ {
31+ this . context = context ;
32+ }
33+
2134 public List < Result > Query ( Query query )
2235 {
2336 string param = query . GetAllRemainingParameter ( ) . TrimStart ( ) ;
@@ -42,8 +55,15 @@ public List<Result> Query(Query query)
4255 Score = 5 ,
4356 Action = ( e ) =>
4457 {
45- context . API . HideApp ( ) ;
46- c . Url . NewBrowserWindow ( "" ) ;
58+ if ( _settings . OpenInNewBrowserWindow )
59+ {
60+ c . Url . NewBrowserWindow ( "" ) ;
61+ }
62+ else
63+ {
64+ c . Url . NewTabInBrowser ( "" ) ;
65+ }
66+
4767 return true ;
4868 }
4969 } ) . ToList ( ) ;
@@ -66,5 +86,14 @@ public string GetTranslatedPluginDescription()
6686 return context . API . GetTranslation ( "wox_plugin_browserbookmark_plugin_description" ) ;
6787 }
6888
89+ public Control CreateSettingPanel ( )
90+ {
91+ return new SettingsControl ( _settings ) ;
92+ }
93+
94+ public void Save ( )
95+ {
96+ _storage . Save ( ) ;
97+ }
6998 }
7099}
0 commit comments