mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Add user selection option for browserbookmark plugin
This commit is contained in:
@@ -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<Bookmark> cachedBookmarks = new List<Bookmark>();
|
||||
private List<Bookmark> cachedBookmarks = new List<Bookmark>();
|
||||
|
||||
private readonly Settings _settings;
|
||||
private readonly PluginJsonStorage<Settings> _storage;
|
||||
|
||||
public Main()
|
||||
{
|
||||
_storage = new PluginJsonStorage<Settings>();
|
||||
_settings = _storage.Load();
|
||||
|
||||
cachedBookmarks = Bookmarks.LoadAllBookmarks();
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
cachedBookmarks = Bookmarks.LoadAllBookmarks();
|
||||
}
|
||||
|
||||
public List<Result> 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("");
|
||||
}
|
||||
else
|
||||
{
|
||||
c.Url.NewTabInBrowser("");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user