Allow user to disable loading bookmark from certain browser

This commit is contained in:
Hongtao Zhang 2022-10-12 16:11:15 -05:00
parent 768c44567a
commit 2189eaaa0c
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB
3 changed files with 66 additions and 47 deletions

View file

@ -19,21 +19,28 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Commands
internal static List<Bookmark> LoadAllBookmarks(Settings setting) internal static List<Bookmark> LoadAllBookmarks(Settings setting)
{ {
var chromeBookmarks = new ChromeBookmarkLoader();
var mozBookmarks = new FirefoxBookmarkLoader();
var edgeBookmarks = new EdgeBookmarkLoader();
var allBookmarks = new List<Bookmark>(); var allBookmarks = new List<Bookmark>();
// Add Firefox bookmarks if (setting.LoadChromeBookmark)
allBookmarks.AddRange(mozBookmarks.GetBookmarks()); {
// Add Chrome bookmarks
var chromeBookmarks = new ChromeBookmarkLoader();
allBookmarks.AddRange(chromeBookmarks.GetBookmarks());
}
// Add Chrome bookmarks if (setting.LoadFirefoxBookmark)
allBookmarks.AddRange(chromeBookmarks.GetBookmarks()); {
// Add Firefox bookmarks
var mozBookmarks = new FirefoxBookmarkLoader();
allBookmarks.AddRange(mozBookmarks.GetBookmarks());
}
// Add Edge (Chromium) bookmarks if (setting.LoadEdgeBookmark)
allBookmarks.AddRange(edgeBookmarks.GetBookmarks()); {
// Add Edge (Chromium) bookmarks
var edgeBookmarks = new EdgeBookmarkLoader();
allBookmarks.AddRange(edgeBookmarks.GetBookmarks());
}
foreach (var browser in setting.CustomChromiumBrowsers) foreach (var browser in setting.CustomChromiumBrowsers)
{ {

View file

@ -10,6 +10,10 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Models
public string BrowserPath { get; set; } public string BrowserPath { get; set; }
public bool LoadChromeBookmark { get; set; } = true;
public bool LoadFirefoxBookmark { get; set; } = true;
public bool LoadEdgeBookmark { get; set; } = true;
public ObservableCollection<CustomBrowser> CustomChromiumBrowsers { get; set; } = new(); public ObservableCollection<CustomBrowser> CustomChromiumBrowsers { get; set; } = new();
} }
} }

View file

@ -1,57 +1,65 @@
<UserControl <UserControl
x:Class="Flow.Launcher.Plugin.BrowserBookmark.Views.SettingsControl" x:Class="Flow.Launcher.Plugin.BrowserBookmark.Views.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300" d:DesignHeight="300"
d:DesignWidth="500" d:DesignWidth="500"
DataContext="{Binding RelativeSource={RelativeSource Self}}" DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Margin="60,0,10,0"> <Grid Margin="60,0,10,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto" /> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Margin="0,10,0,10" Orientation="Vertical"> <StackPanel Margin="0,10,0,10" Orientation="Vertical">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Margin="10" Text="{DynamicResource flowlauncher_plugin_browserbookmark_loadBrowserFrom}" /> <TextBlock Margin="10" Text="{DynamicResource flowlauncher_plugin_browserbookmark_loadBrowserFrom}"/>
<CheckBox Margin="0,0,15,0" Content="Chrome" /> <CheckBox Margin="0,0,15,0"
<CheckBox Margin="0,0,15,0" Content="Edge" /> Content="Chrome"
<CheckBox Margin="0,0,15,0" Content="Firefox" /> IsChecked="{Binding Settings.LoadChromeBookmark}"/>
<CheckBox Margin="0,0,15,0"
Content="Edge"
IsChecked="{Binding Settings.LoadEdgeBookmark}"/>
<CheckBox Margin="0,0,15,0"
Content="Firefox"
IsChecked="{Binding Settings.LoadFirefoxBookmark}"/>
<Button <Button
Margin="0,0,15,0" Margin="0,0,15,0"
Click="Others_Click" Click="Others_Click"
Content="{DynamicResource flowlauncher_plugin_browserbookmark_others}" /> Content="{DynamicResource flowlauncher_plugin_browserbookmark_others}"/>
</StackPanel> </StackPanel>
<StackPanel Name="CustomBrowsersList" Visibility="Collapsed"> <StackPanel Name="CustomBrowsersList" Visibility="Collapsed">
<ListView <ListView
Name="CustomBrowsers" Name="CustomBrowsers"
Height="auto" Height="auto"
Margin="10" Margin="10"
BorderBrush="DarkGray" BorderBrush="DarkGray"
BorderThickness="1" BorderThickness="1"
ItemsSource="{Binding Settings.CustomChromiumBrowsers}" ItemsSource="{Binding Settings.CustomChromiumBrowsers}"
MouseDoubleClick="MouseDoubleClickOnSelectedCustomBrowser" MouseDoubleClick="MouseDoubleClickOnSelectedCustomBrowser"
SelectedItem="{Binding SelectedCustomBrowser}" SelectedItem="{Binding SelectedCustomBrowser}"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"> Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn DisplayMemberBinding="{Binding Name, Mode=OneWay}" Header="{DynamicResource flowlauncher_plugin_browserbookmark_browserName}" /> <GridViewColumn DisplayMemberBinding="{Binding Name, Mode=OneWay}"
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath, Mode=OneWay}" Header="{DynamicResource flowlauncher_plugin_browserbookmark_browserBookmarkDataDirectory}" /> Header="{DynamicResource flowlauncher_plugin_browserbookmark_browserName}"/>
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath, Mode=OneWay}"
Header="{DynamicResource flowlauncher_plugin_browserbookmark_browserBookmarkDataDirectory}"/>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button <Button
MinWidth="130" MinWidth="130"
Margin="10" Margin="10"
Click="NewCustomBrowser" Click="NewCustomBrowser"
Content="{DynamicResource flowlauncher_plugin_browserbookmark_addBrowserBookmark}" /> Content="{DynamicResource flowlauncher_plugin_browserbookmark_addBrowserBookmark}"/>
<Button <Button
MinWidth="120" MinWidth="120"
Margin="10" Margin="10"
Click="DeleteCustomBrowser" Click="DeleteCustomBrowser"
Content="{DynamicResource flowlauncher_plugin_browserbookmark_removeBrowserBookmark}" /> Content="{DynamicResource flowlauncher_plugin_browserbookmark_removeBrowserBookmark}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>