Skip to content

Commit d3025a6

Browse files
Merge pull request #1897 from onesounds/GuideForBookmarkPlugin
Custom Browser managing UI Improvement in Bookmarks Plugin
2 parents 43b5c06 + 6cfdc30 commit d3025a6

File tree

7 files changed

+217
-101
lines changed

7 files changed

+217
-101
lines changed

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1212
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1313
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
14+
<UseWindowsForms>true</UseWindowsForms>
1415
</PropertyGroup>
1516

1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -66,12 +67,8 @@
6667

6768
<Target Name="CopyDLLs" AfterTargets="Build">
6869
<Message Text="Executing CopyDLLs task" Importance="High" />
69-
<Copy
70-
SourceFiles="$(TargetDir)\runtimes\win-x64\native\SQLite.Interop.dll"
71-
DestinationFolder="$(TargetDir)\x64" />
72-
<Copy
73-
SourceFiles="$(TargetDir)\runtimes\win-x86\native\SQLite.Interop.dll"
74-
DestinationFolder="$(TargetDir)\x86" />
70+
<Copy SourceFiles="$(TargetDir)\runtimes\win-x64\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x64" />
71+
<Copy SourceFiles="$(TargetDir)\runtimes\win-x86\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x86" />
7572
</Target>
7673

7774
<Target Name="DeleteRuntimesFolder" AfterTargets="CopyDLLs">

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
<system:String x:Key="flowlauncher_plugin_browserbookmark_browserName">Browser Name</system:String>
2121
<system:String x:Key="flowlauncher_plugin_browserbookmark_browserBookmarkDataDirectory">Data Directory Path</system:String>
2222
<system:String x:Key="flowlauncher_plugin_browserbookmark_addBrowserBookmark">Add</system:String>
23+
<system:String x:Key="flowlauncher_plugin_browserbookmark_editBrowserBookmark">Edit</system:String>
2324
<system:String x:Key="flowlauncher_plugin_browserbookmark_removeBrowserBookmark">Delete</system:String>
25+
<system:String x:Key="flowlauncher_plugin_browserbookmark_browseBrowserBookmark">Browse</system:String>
2426
<system:String x:Key="flowlauncher_plugin_browserbookmark_others">Others</system:String>
2527
<system:String x:Key="flowlauncher_plugin_browserbookmark_browserEngine">Browser Engine</system:String>
28+
<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>
29+
<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 userdata folder contains the places.sqlite file.</system:String>
2630
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ namespace Flow.Launcher.Plugin.BrowserBookmark
1717
{
1818
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
1919
{
20-
private PluginInitContext context;
20+
private static PluginInitContext context;
2121

22-
private List<Bookmark> cachedBookmarks = new List<Bookmark>();
23-
24-
private Settings _settings { get; set; }
22+
private static List<Bookmark> cachedBookmarks = new List<Bookmark>();
2523

24+
private static Settings _settings;
25+
2626
public void Init(PluginInitContext context)
2727
{
28-
this.context = context;
29-
28+
Main.context = context;
29+
3030
_settings = context.API.LoadSettingJsonStorage<Settings>();
3131

3232
cachedBookmarks = BookmarkLoader.LoadAllBookmarks(_settings);
@@ -136,6 +136,11 @@ internal static void RegisterBookmarkFile(string path)
136136
}
137137

138138
public void ReloadData()
139+
{
140+
ReloadAllBookmarks();
141+
}
142+
143+
public static void ReloadAllBookmarks()
139144
{
140145
cachedBookmarks.Clear();
141146

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:ui="clr-namespace:Flow.Launcher.Infrastructure.UI;assembly=Flow.Launcher.Infrastructure"
99
Title="{DynamicResource flowlauncher_plugin_browserbookmark_bookmarkDataSetting}"
10-
Width="520"
10+
Width="550"
1111
Background="{DynamicResource PopuBGColor}"
1212
Foreground="{DynamicResource PopupTextColor}"
1313
KeyDown="WindowKeyDown"
@@ -39,7 +39,7 @@
3939
</Grid.ColumnDefinitions>
4040
<Button
4141
Grid.Column="4"
42-
Click="ConfirmCancelEditCustomBrowser"
42+
Click="CancelEditCustomBrowser"
4343
Style="{StaticResource TitleBarCloseButtonStyle}">
4444
<Path
4545
Width="46"
@@ -71,8 +71,8 @@
7171
TextAlignment="Left" />
7272
</StackPanel>
7373

74-
<StackPanel Margin="0,10,0,20" Orientation="Horizontal">
75-
<Grid Width="444" HorizontalAlignment="Stretch">
74+
<StackPanel Margin="0,0,0,20" Orientation="Horizontal">
75+
<Grid Width="474" HorizontalAlignment="Stretch">
7676
<Grid.ColumnDefinitions>
7777
<ColumnDefinition Width="Auto" />
7878
<ColumnDefinition Width="*" />
@@ -81,17 +81,45 @@
8181
<RowDefinition />
8282
<RowDefinition />
8383
<RowDefinition />
84+
<RowDefinition />
8485
</Grid.RowDefinitions>
85-
<TextBlock
86+
<StackPanel
8687
Grid.Row="0"
8788
Grid.Column="0"
89+
Grid.ColumnSpan="2"
90+
Margin="5,0,0,20">
91+
<TextBlock
92+
Margin="0,0,0,4"
93+
HorizontalAlignment="Left"
94+
VerticalAlignment="Center"
95+
FontSize="14"
96+
Text="{DynamicResource flowlauncher_plugin_browserbookmark_guideMessage01}"
97+
TextWrapping="WrapWithOverflow" />
98+
<TextBlock
99+
Margin="0,4,0,4"
100+
HorizontalAlignment="Left"
101+
VerticalAlignment="Center"
102+
FontSize="14"
103+
Text="{DynamicResource flowlauncher_plugin_browserbookmark_guideMessage02}"
104+
TextWrapping="WrapWithOverflow" />
105+
<TextBlock
106+
Margin="0,4,0,0"
107+
HorizontalAlignment="Left"
108+
VerticalAlignment="Center"
109+
FontSize="14"
110+
Text="{DynamicResource flowlauncher_plugin_browserbookmark_guideMessage03}"
111+
TextWrapping="WrapWithOverflow" />
112+
</StackPanel>
113+
<TextBlock
114+
Grid.Row="1"
115+
Grid.Column="0"
88116
Margin="5,0,20,0"
89117
HorizontalAlignment="Left"
90118
VerticalAlignment="Center"
91119
FontSize="14"
92120
Text="{DynamicResource flowlauncher_plugin_browserbookmark_browserName}" />
93121
<TextBox
94-
Grid.Row="0"
122+
Grid.Row="1"
95123
Grid.Column="1"
96124
Width="120"
97125
Height="34"
@@ -100,40 +128,51 @@
100128
VerticalAlignment="Center"
101129
Text="{Binding Name}" />
102130
<TextBlock
103-
Grid.Row="1"
131+
Grid.Row="2"
104132
Grid.Column="0"
105133
Margin="5,10,20,0"
106134
HorizontalAlignment="Left"
107135
VerticalAlignment="Center"
108136
FontSize="14"
109137
Text="{DynamicResource flowlauncher_plugin_browserbookmark_browserEngine}" />
110138
<ComboBox
111-
Grid.Row="1"
139+
Grid.Row="2"
112140
Grid.Column="1"
113141
Width="120"
114142
Height="34"
115143
Margin="5,10,10,0"
116144
HorizontalAlignment="Left"
117145
VerticalAlignment="Center"
118146
ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type local:BrowserType}}}"
119-
SelectedItem="{Binding BrowserType}">
120-
</ComboBox>
147+
SelectedItem="{Binding BrowserType}" />
121148
<TextBlock
122-
Grid.Row="2"
149+
Grid.Row="3"
123150
Grid.Column="0"
124151
Margin="5,10,20,0"
125152
HorizontalAlignment="Left"
126153
VerticalAlignment="Center"
127154
FontSize="14"
128155
Text="{DynamicResource flowlauncher_plugin_browserbookmark_browserBookmarkDataDirectory}" />
129-
<TextBox
130-
Grid.Row="2"
156+
<DockPanel
157+
Grid.Row="3"
131158
Grid.Column="1"
132-
Height="34"
133-
Margin="5,10,0,0"
134-
HorizontalAlignment="Stretch"
135-
VerticalAlignment="Center"
136-
Text="{Binding DataDirectoryPath}" />
159+
LastChildFill="True">
160+
<Button
161+
Height="34"
162+
MinWidth="100"
163+
Margin="5,10,0,0"
164+
VerticalContentAlignment="Stretch"
165+
Click="OnSelectPathClick"
166+
Content="{DynamicResource flowlauncher_plugin_browserbookmark_browseBrowserBookmark}"
167+
DockPanel.Dock="Right" />
168+
<TextBox
169+
Name="PathTextBox"
170+
Height="34"
171+
Margin="5,10,0,0"
172+
HorizontalAlignment="Stretch"
173+
VerticalAlignment="Center"
174+
Text="{Binding DataDirectoryPath}" />
175+
</DockPanel>
137176
</Grid>
138177
</StackPanel>
139178
</StackPanel>
@@ -148,13 +187,13 @@
148187
x:Name="btnCancel"
149188
MinWidth="145"
150189
Margin="0,0,5,0"
151-
Click="ConfirmCancelEditCustomBrowser"
190+
Click="CancelEditCustomBrowser"
152191
Content="{DynamicResource cancel}" />
153192
<Button
154193
Name="btnConfirm"
155194
MinWidth="145"
156195
Margin="5,0,0,0"
157-
Click="ConfirmCancelEditCustomBrowser"
196+
Click="ConfirmEditCustomBrowser"
158197
Style="{StaticResource AccentButtonStyle}">
159198
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
160199
</Button>
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Flow.Launcher.Plugin.BrowserBookmark.Models;
22
using System.Windows;
3-
using System.Windows.Controls;
43
using System.Windows.Input;
4+
using System.Windows.Forms;
55

66
namespace Flow.Launcher.Plugin.BrowserBookmark.Views
77
{
@@ -22,29 +22,36 @@ public CustomBrowserSettingWindow(CustomBrowser browser)
2222
BrowserType = browser.BrowserType,
2323
};
2424
}
25-
26-
private void ConfirmCancelEditCustomBrowser(object sender, RoutedEventArgs e)
25+
26+
private void ConfirmEditCustomBrowser(object sender, RoutedEventArgs e)
2727
{
28-
if (DataContext is CustomBrowser editBrowser && e.Source is Button button)
29-
{
30-
if (button.Name == "btnConfirm")
31-
{
32-
currentCustomBrowser.Name = editBrowser.Name;
33-
currentCustomBrowser.DataDirectoryPath = editBrowser.DataDirectoryPath;
34-
currentCustomBrowser.BrowserType = editBrowser.BrowserType;
35-
Close();
36-
}
37-
}
28+
CustomBrowser editBrowser = (CustomBrowser)DataContext;
29+
currentCustomBrowser.Name = editBrowser.Name;
30+
currentCustomBrowser.DataDirectoryPath = editBrowser.DataDirectoryPath;
31+
currentCustomBrowser.BrowserType = editBrowser.BrowserType;
32+
DialogResult = true;
33+
Close();
34+
}
3835

36+
private void CancelEditCustomBrowser(object sender, RoutedEventArgs e)
37+
{
3938
Close();
4039
}
4140

42-
private void WindowKeyDown(object sender, KeyEventArgs e)
41+
private void WindowKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
4342
{
4443
if (e.Key == Key.Enter)
4544
{
46-
ConfirmCancelEditCustomBrowser(sender, e);
45+
ConfirmEditCustomBrowser(sender, e);
4746
}
4847
}
48+
49+
private void OnSelectPathClick(object sender, RoutedEventArgs e)
50+
{
51+
var dialog = new FolderBrowserDialog();
52+
dialog.ShowDialog();
53+
CustomBrowser editBrowser = (CustomBrowser)DataContext;
54+
editBrowser.DataDirectoryPath = dialog.SelectedPath;
55+
}
4956
}
5057
}

0 commit comments

Comments
 (0)