mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Auto reload all bookmarks when finish editing
This commit is contained in:
parent
dd61d195e2
commit
ab0d6245df
4 changed files with 29 additions and 28 deletions
|
|
@ -27,5 +27,4 @@
|
|||
<system:String x:Key="flowlauncher_plugin_browserbookmark_browserEngine">Browser Engine</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_browserbookmark_guideMessage01">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.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_browserbookmark_guideMessage02">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 folder contains the places.sqlite file.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_browserbookmark_guideMessage03">After changing these values, close all setting windows and press F5 when Flow Launcher is open to reload the plug-in.</system:String>
|
||||
</ResourceDictionary>
|
||||
|
|
@ -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<Bookmark> cachedBookmarks = new List<Bookmark>();
|
||||
|
||||
private Settings _settings { get; set; }
|
||||
private static List<Bookmark> cachedBookmarks = new List<Bookmark>();
|
||||
|
||||
private static Settings _settings;
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
Main.context = context;
|
||||
|
||||
_settings = context.API.LoadSettingJsonStorage<Settings>();
|
||||
|
||||
cachedBookmarks = BookmarkLoader.LoadAllBookmarks(_settings);
|
||||
|
|
@ -136,6 +136,11 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
|
|||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
ReloadAllBookmarks();
|
||||
}
|
||||
|
||||
public static void ReloadAllBookmarks()
|
||||
{
|
||||
cachedBookmarks.Clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Grid.Column="4"
|
||||
Click="ConfirmCancelEditCustomBrowser"
|
||||
Click="CancelEditCustomBrowser"
|
||||
Style="{StaticResource TitleBarCloseButtonStyle}">
|
||||
<Path
|
||||
Width="46"
|
||||
|
|
@ -187,13 +187,13 @@
|
|||
x:Name="btnCancel"
|
||||
MinWidth="145"
|
||||
Margin="0,0,5,0"
|
||||
Click="ConfirmCancelEditCustomBrowser"
|
||||
Click="CancelEditCustomBrowser"
|
||||
Content="{DynamicResource cancel}" />
|
||||
<Button
|
||||
Name="btnConfirm"
|
||||
MinWidth="145"
|
||||
Margin="5,0,0,0"
|
||||
Click="ConfirmCancelEditCustomBrowser"
|
||||
Click="ConfirmEditCustomBrowser"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
||||
{
|
||||
|
|
@ -25,20 +23,19 @@ 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 System.Windows.Controls.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;
|
||||
_ = Task.Run(() => Main.ReloadAllBookmarks());
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CancelEditCustomBrowser(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +43,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
ConfirmCancelEditCustomBrowser(sender, e);
|
||||
ConfirmEditCustomBrowser(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,8 +51,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
{
|
||||
var dialog = new FolderBrowserDialog();
|
||||
dialog.ShowDialog();
|
||||
PathTextBox.Text = dialog.SelectedPath;
|
||||
string folder = dialog.SelectedPath;
|
||||
CustomBrowser editBrowser = (CustomBrowser)DataContext;
|
||||
editBrowser.DataDirectoryPath = dialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue