diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index c42378a9a..25577d96b 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -11,6 +11,7 @@ true false false + true @@ -66,12 +67,8 @@ - - + + diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml index 5dbe925c1..e5f3d541e 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml @@ -20,7 +20,11 @@ Browser Name Data Directory Path Add + Edit Delete + Browse Others Browser Engine + If you are not using Chrome, Firefox or Edge, or you are using their portable version, you need to add bookmarks data directory and select correct browser engine to make this plugin work. + For example: Brave's engine is Chromium; and its default bookmarks data location is: "%LOCALAPPDATA%\BraveSoftware\Brave-Browser\UserData". For Firefox engine, the bookmarks directory is the userdata folder contains the places.sqlite file. \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs index d072a362d..d9a719272 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs @@ -17,16 +17,16 @@ namespace Flow.Launcher.Plugin.BrowserBookmark { public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable { - private PluginInitContext context; + private static PluginInitContext context; - private List cachedBookmarks = new List(); - - private Settings _settings { get; set; } + private static List cachedBookmarks = new List(); + private static Settings _settings; + public void Init(PluginInitContext context) { - this.context = context; - + Main.context = context; + _settings = context.API.LoadSettingJsonStorage(); cachedBookmarks = BookmarkLoader.LoadAllBookmarks(_settings); @@ -136,6 +136,11 @@ namespace Flow.Launcher.Plugin.BrowserBookmark } public void ReloadData() + { + ReloadAllBookmarks(); + } + + public static void ReloadAllBookmarks() { cachedBookmarks.Clear(); diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml index 499d22834..392c9e0a7 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="clr-namespace:Flow.Launcher.Infrastructure.UI;assembly=Flow.Launcher.Infrastructure" Title="{DynamicResource flowlauncher_plugin_browserbookmark_bookmarkDataSetting}" - Width="520" + Width="550" Background="{DynamicResource PopuBGColor}" Foreground="{DynamicResource PopupTextColor}" KeyDown="WindowKeyDown" @@ -39,7 +39,7 @@ diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml.cs index 392d4695a..bdef5bf0f 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml.cs @@ -1,7 +1,7 @@ using Flow.Launcher.Plugin.BrowserBookmark.Models; using System.Windows; -using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Forms; namespace Flow.Launcher.Plugin.BrowserBookmark.Views { @@ -22,29 +22,36 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views BrowserType = browser.BrowserType, }; } - - private void ConfirmCancelEditCustomBrowser(object sender, RoutedEventArgs e) + + private void ConfirmEditCustomBrowser(object sender, RoutedEventArgs e) { - if (DataContext is CustomBrowser editBrowser && e.Source is Button button) - { - if (button.Name == "btnConfirm") - { - currentCustomBrowser.Name = editBrowser.Name; - currentCustomBrowser.DataDirectoryPath = editBrowser.DataDirectoryPath; - currentCustomBrowser.BrowserType = editBrowser.BrowserType; - Close(); - } - } - + CustomBrowser editBrowser = (CustomBrowser)DataContext; + currentCustomBrowser.Name = editBrowser.Name; + currentCustomBrowser.DataDirectoryPath = editBrowser.DataDirectoryPath; + currentCustomBrowser.BrowserType = editBrowser.BrowserType; + DialogResult = true; Close(); } - private void WindowKeyDown(object sender, KeyEventArgs e) + private void CancelEditCustomBrowser(object sender, RoutedEventArgs e) + { + Close(); + } + + private void WindowKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Enter) { - ConfirmCancelEditCustomBrowser(sender, e); + ConfirmEditCustomBrowser(sender, e); } } + + private void OnSelectPathClick(object sender, RoutedEventArgs e) + { + var dialog = new FolderBrowserDialog(); + dialog.ShowDialog(); + CustomBrowser editBrowser = (CustomBrowser)DataContext; + editBrowser.DataDirectoryPath = dialog.SelectedPath; + } } } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml index 628a9417b..014deff03 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml @@ -1,67 +1,83 @@  + x:Class="Flow.Launcher.Plugin.BrowserBookmark.Views.SettingsControl" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + d:DesignHeight="300" + d:DesignWidth="500" + DataContext="{Binding RelativeSource={RelativeSource Self}}" + mc:Ignorable="d"> - + - - - - + + + + +