Skip to content

Commit e5e8c48

Browse files
committed
Implement editing
1 parent 672616e commit e5e8c48

File tree

5 files changed

+54
-17
lines changed

5 files changed

+54
-17
lines changed

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Models/CustomBrowser.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
{
33
public class CustomBrowser : BaseModel
44
{
5-
public string Name { get; set; }
6-
public string DataDirectoryPath { get; set; }
5+
private string _name;
6+
private string _dataDirectoryPath;
7+
public string Name
8+
{
9+
get => _name;
10+
set
11+
{
12+
_name = value;
13+
OnPropertyChanged(nameof(Name));
14+
}
15+
}
16+
public string DataDirectoryPath
17+
{
18+
get => _dataDirectoryPath;
19+
set
20+
{
21+
_dataDirectoryPath = value;
22+
OnPropertyChanged(nameof(DataDirectoryPath));
23+
}
24+
}
725
}
826
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:local="clr-namespace:Flow.Launcher.Plugin.BrowserBookmark.Models"
77
mc:Ignorable="d"
88
Title="CustomBrowserSetting" Height="450" Width="600"
9+
KeyDown="WindowKeyDown"
910
>
1011
<Window.DataContext>
1112
<local:CustomBrowser/>
@@ -21,13 +22,13 @@
2122
<ColumnDefinition Width="6*"/>
2223
</Grid.ColumnDefinitions>
2324
<TextBlock Grid.Row="0" Grid.Column="0" Text="Browser Name" FontSize="15"
24-
HorizontalAlignment="Center" VerticalAlignment="Center"/>
25+
HorizontalAlignment="Left" VerticalAlignment="Center"/>
2526
<TextBlock Grid.Row="1" Grid.Column="0" Text="Browser Data Directory Path" FontSize="15"
26-
HorizontalAlignment="Center" VerticalAlignment="Center"/>
27+
HorizontalAlignment="Left" VerticalAlignment="Center"/>
2728
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name}"
28-
HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="30"/>
29+
HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Height="30"/>
2930
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding DataDirectoryPath}"
30-
HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="30"/>
31+
HorizontalAlignment="Left" VerticalAlignment="Center" Width="200" Height="30"/>
3132
<StackPanel HorizontalAlignment="Right" Grid.Row="2" Orientation="Horizontal" Grid.Column="1" Height="60">
3233
<Button Content="Confirm" Margin="15" Click="ConfirmEditCustomBrowser"/>
3334
<Button Content="Cancel" Margin="15"/>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public CustomBrowserSettingWindow(CustomBrowser browser)
2727
currentCustomBrowser = browser;
2828
DataContext = new CustomBrowser
2929
{
30-
Name = browser.Name,
31-
DataDirectoryPath = browser.DataDirectoryPath
30+
Name = browser.Name, DataDirectoryPath = browser.DataDirectoryPath
3231
};
3332
}
3433

@@ -41,5 +40,12 @@ private void ConfirmEditCustomBrowser(object sender, RoutedEventArgs e)
4140
}
4241
Close();
4342
}
43+
private void WindowKeyDown(object sender, KeyEventArgs e)
44+
{
45+
if (e.Key == Key.Enter)
46+
{
47+
ConfirmEditCustomBrowser(sender, e);
48+
}
49+
}
4450
}
45-
}
51+
}

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
mc:Ignorable="d"
77
Background="White"
88
d:DesignHeight="300" d:DesignWidth="500"
9-
DataContext="{Binding RelativeSource={RelativeSource Self}, Path=Settings}">
9+
DataContext="{Binding RelativeSource={RelativeSource Self}}">
1010
<Grid>
1111
<Grid.RowDefinitions>
1212
<RowDefinition Height="50" />
@@ -33,30 +33,32 @@
3333
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1" Height="60" Margin="25,13,0,0">
3434
<Label Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_setBrowserFromPath}"
3535
Height="28" Margin="10"/>
36-
<TextBox x:Name="browserPathBox"
36+
<TextBox x:Name="BrowserPathBox"
3737
HorizontalAlignment="Left"
3838
Height="30"
3939
TextWrapping="NoWrap"
4040
VerticalAlignment="Center"
41-
Text="{Binding BrowserPath}"
41+
Text="{Binding Settings.BrowserPath}"
4242
Width="240"
4343
Margin="10"/>
44-
<Button x:Name="viewButton" Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_choose}"
44+
<Button x:Name="ViewButton" Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_choose}"
4545
HorizontalAlignment="Left" Margin="10" Width="100" Height="30" Click="OnChooseClick" FontSize="14" />
4646
</StackPanel>
4747
<StackPanel Grid.Row="2" Orientation="Vertical">
4848
<TextBlock Text="CustomBrowsers" Margin="10"/>
49-
<ListView Grid.Row="2" ItemsSource="{Binding CustomChromiumBrowsers}"
49+
<ListView Grid.Row="2" ItemsSource="{Binding Settings.CustomChromiumBrowsers}"
50+
SelectedItem="{Binding SelectedCustomBrowser}"
5051
Margin="10"
5152
BorderBrush="DarkGray"
5253
BorderThickness="1"
5354
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"
5455
Height="auto"
55-
Name="CustomBrowsers">
56+
Name="CustomBrowsers"
57+
MouseDoubleClick="MouseDoubleClickOnSelectedCustomBrowser">
5658
<ListView.View>
5759
<GridView>
58-
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Browser Name"/>
59-
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath}" Header="DataDirectoryPath"/>
60+
<GridViewColumn DisplayMemberBinding="{Binding Name, Mode=OneWay}" Header="Browser Name"/>
61+
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath, Mode=OneWay}" Header="DataDirectoryPath"/>
6062
</GridView>
6163
</ListView.View>
6264
</ListView>

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Windows;
33
using System.Windows.Controls;
44
using Flow.Launcher.Plugin.BrowserBookmark.Models;
5+
using System.Windows.Input;
56

67
namespace Flow.Launcher.Plugin.BrowserBookmark.Views
78
{
@@ -11,6 +12,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
1112
public partial class SettingsControl
1213
{
1314
public Settings Settings { get; }
15+
public CustomBrowser SelectedCustomBrowser { get; set; }
1416

1517
public SettingsControl(Settings settings)
1618
{
@@ -64,5 +66,13 @@ private void DeleteCustomBrowser(object sender, RoutedEventArgs e)
6466
Settings.CustomChromiumBrowsers.Remove(selectedCustomBrowser);
6567
}
6668
}
69+
private void MouseDoubleClickOnSelectedCustomBrowser(object sender, MouseButtonEventArgs e)
70+
{
71+
if (SelectedCustomBrowser is null)
72+
return;
73+
74+
var window = new CustomBrowserSettingWindow(SelectedCustomBrowser);
75+
window.ShowDialog();
76+
}
6777
}
6878
}

0 commit comments

Comments
 (0)