Skip to content

Commit 3688837

Browse files
authored
Merge pull request #3739 from onesounds/250617-Fixquicklink
Improve Quick Access Link Adding UI
2 parents 00a80ae + bc8e77a commit 3688837

File tree

9 files changed

+201
-133
lines changed

9 files changed

+201
-133
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
</ItemGroup>
9696

9797
<ItemGroup>
98+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
9899
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
99100
</ItemGroup>
100101

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System.Windows;
2-
using Flow.Launcher.Plugin.BrowserBookmark.Models;
32
using System.Windows.Input;
4-
using System.ComponentModel;
53
using System.Threading.Tasks;
4+
using CommunityToolkit.Mvvm.ComponentModel;
5+
using Flow.Launcher.Plugin.BrowserBookmark.Models;
66

77
namespace Flow.Launcher.Plugin.BrowserBookmark.Views;
88

9-
public partial class SettingsControl : INotifyPropertyChanged
9+
[INotifyPropertyChanged]
10+
public partial class SettingsControl
1011
{
1112
public Settings Settings { get; }
1213
public CustomBrowser SelectedCustomBrowser { get; set; }
@@ -53,12 +54,10 @@ public bool OpenInNewBrowserWindow
5354
set
5455
{
5556
Settings.OpenInNewBrowserWindow = value;
56-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OpenInNewBrowserWindow)));
57+
OnPropertyChanged();
5758
}
5859
}
5960

60-
public event PropertyChangedEventHandler PropertyChanged;
61-
6261
private void NewCustomBrowser(object sender, RoutedEventArgs e)
6362
{
6463
var newBrowser = new CustomBrowser();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@
9898
<system:String x:Key="plugin_explorer_deletefilefolder">Delete</system:String>
9999
<system:String x:Key="plugin_explorer_deletefile_subtitle">Permanently delete current file</system:String>
100100
<system:String x:Key="plugin_explorer_deletefolder_subtitle">Permanently delete current folder</system:String>
101-
<system:String x:Key="plugin_explorer_path">Path:</system:String>
102-
<system:String x:Key="plugin_explorer_name">Name:</system:String>
101+
<system:String x:Key="plugin_explorer_name">Name</system:String>
102+
<system:String x:Key="plugin_explorer_type">Type</system:String>
103+
<system:String x:Key="plugin_explorer_path">Path</system:String>
104+
<system:String x:Key="plugin_explorer_file">File</system:String>
105+
<system:String x:Key="plugin_explorer_folder">Folder</system:String>
103106
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
104107
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
105108
<system:String x:Key="plugin_explorer_runasdifferentuser_subtitle">Run the selected using a different user account</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
using System.ComponentModel;
2-
using System.Runtime.CompilerServices;
1+
#nullable enable
32

4-
#nullable enable
5-
6-
namespace Flow.Launcher.Plugin.Explorer.Views
3+
namespace Flow.Launcher.Plugin.Explorer.ViewModels
74
{
8-
public class ActionKeywordModel : INotifyPropertyChanged
5+
public partial class ActionKeywordModel : BaseModel
96
{
107
private static Settings _settings = null!;
118

12-
public event PropertyChangedEventHandler? PropertyChanged;
13-
149
public static void Init(Settings settings)
1510
{
1611
_settings = settings;
@@ -28,13 +23,7 @@ internal ActionKeywordModel(Settings.ActionKeyword actionKeyword, string descrip
2823

2924
internal Settings.ActionKeyword KeywordProperty { get; }
3025

31-
private void OnPropertyChanged([CallerMemberName] string propertyName = "")
32-
{
33-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
34-
}
35-
3626
private string? keyword;
37-
3827
public string Keyword
3928
{
4029
get => keyword ??= _settings.GetActionKeyword(KeywordProperty);
@@ -45,8 +34,8 @@ public string Keyword
4534
OnPropertyChanged();
4635
}
4736
}
48-
private bool? enabled;
4937

38+
private bool? enabled;
5039
public bool Enabled
5140
{
5241
get => enabled ??= _settings.GetActionKeywordEnabled(KeywordProperty);

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
using System.Collections.Generic;
2-
using System.ComponentModel;
3-
using System.Linq;
4-
using System.Runtime.CompilerServices;
1+
using System.Linq;
52
using System.Windows;
63
using System.Windows.Input;
4+
using CommunityToolkit.Mvvm.ComponentModel;
5+
using Flow.Launcher.Plugin.Explorer.ViewModels;
76

87
namespace Flow.Launcher.Plugin.Explorer.Views
98
{
10-
/// <summary>
11-
/// Interaction logic for ActionKeywordSetting.xaml
12-
/// </summary>
13-
public partial class ActionKeywordSetting : INotifyPropertyChanged
9+
[INotifyPropertyChanged]
10+
public partial class ActionKeywordSetting
1411
{
1512
private ActionKeywordModel CurrentActionKeyword { get; }
1613

@@ -21,14 +18,14 @@ public string ActionKeyword
2118
{
2219
// Set Enable to be true if user change ActionKeyword
2320
KeywordEnabled = true;
24-
_ = SetField(ref actionKeyword, value);
21+
_ = SetProperty(ref actionKeyword, value);
2522
}
2623
}
2724

2825
public bool KeywordEnabled
2926
{
3027
get => _keywordEnabled;
31-
set => SetField(ref _keywordEnabled, value);
28+
set => _ = SetProperty(ref _keywordEnabled, value);
3229
}
3330

3431
private string actionKeyword;
@@ -116,20 +113,5 @@ private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
116113
e.CancelCommand();
117114
}
118115
}
119-
120-
public event PropertyChangedEventHandler PropertyChanged;
121-
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
122-
{
123-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
124-
}
125-
126-
private bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
127-
{
128-
if (EqualityComparer<T>.Default.Equals(field, value))
129-
return false;
130-
field = value;
131-
OnPropertyChanged(propertyName);
132-
return true;
133-
}
134116
}
135117
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
xmlns:qa="clr-namespace:Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks"
99
xmlns:ui="http://schemas.modernwpf.com/2019"
1010
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
11-
xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
1211
d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}"
1312
d:DesignHeight="450"
1413
d:DesignWidth="800"
@@ -18,7 +17,7 @@
1817
<DataTemplate x:Key="ListViewTemplateAccessLinks" DataType="qa:AccessLink">
1918
<TextBlock Margin="0 5 0 5" Text="{Binding Path, Mode=OneTime}" />
2019
</DataTemplate>
21-
<DataTemplate x:Key="ListViewActionKeywords" DataType="{x:Type views:ActionKeywordModel}">
20+
<DataTemplate x:Key="ListViewActionKeywords" DataType="{x:Type viewModels:ActionKeywordModel}">
2221
<Grid>
2322
<TextBlock
2423
Margin="0 5 0 0"

Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
using System.Globalization;
44
using System.IO;
55
using System.Linq;
6-
using System.Runtime.CompilerServices;
76
using System.Threading;
87
using System.Threading.Tasks;
98
using System.Windows;
109
using System.Windows.Controls;
1110
using System.Windows.Media;
1211
using System.Windows.Media.Imaging;
1312
using Flow.Launcher.Plugin.Explorer.Search;
13+
using CommunityToolkit.Mvvm.ComponentModel;
1414

1515
namespace Flow.Launcher.Plugin.Explorer.Views;
1616

1717
#nullable enable
1818

19-
public partial class PreviewPanel : UserControl, INotifyPropertyChanged
19+
[INotifyPropertyChanged]
20+
public partial class PreviewPanel : UserControl
2021
{
2122
private static readonly string ClassName = nameof(PreviewPanel);
2223

@@ -327,11 +328,4 @@ private static string GetFileAge(DateTime fileDateTime)
327328
return yearsDiff == 1 ? Main.Context.API.GetTranslation("OneYearAgo") :
328329
string.Format(Main.Context.API.GetTranslation("YearsAgo"), yearsDiff);
329330
}
330-
331-
public event PropertyChangedEventHandler? PropertyChanged;
332-
333-
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
334-
{
335-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
336-
}
337331
}
Lines changed: 86 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
<Window x:Class="Flow.Launcher.Plugin.Explorer.Views.QuickAccessLinkSettings"
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5-
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
6-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7-
Title="{DynamicResource plugin_explorer_manage_quick_access_links_header}"
8-
Width="Auto"
9-
Height="255"
10-
Background="{DynamicResource PopuBGColor}"
11-
DataContext="{Binding RelativeSource={RelativeSource Self}}"
12-
Foreground="{DynamicResource PopupTextColor}"
13-
ResizeMode="NoResize"
14-
SizeToContent="Width"
15-
WindowStartupLocation="CenterScreen"
16-
mc:Ignorable="d">
17-
<WindowChrome.WindowChrome>
18-
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
19-
</WindowChrome.WindowChrome>
1+
<Window
2+
x:Class="Flow.Launcher.Plugin.Explorer.Views.QuickAccessLinkSettings"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
Title="{DynamicResource plugin_explorer_manage_quick_access_links_header}"
9+
Width="Auto"
10+
Height="300"
11+
Background="{DynamicResource PopuBGColor}"
12+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
13+
Foreground="{DynamicResource PopupTextColor}"
14+
ResizeMode="NoResize"
15+
SizeToContent="Width"
16+
WindowStartupLocation="CenterScreen"
17+
mc:Ignorable="d">
18+
<WindowChrome.WindowChrome>
19+
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
20+
</WindowChrome.WindowChrome>
2021
<Grid>
2122
<Grid.RowDefinitions>
2223
<RowDefinition />
@@ -58,55 +59,91 @@
5859
<StackPanel Margin="26 0 26 0">
5960
<StackPanel Margin="0 0 0 12">
6061
<TextBlock
61-
Margin="0 0 0 0"
6262
FontSize="20"
6363
FontWeight="SemiBold"
6464
Text="{DynamicResource plugin_explorer_manage_quick_access_links_header}"
6565
TextAlignment="Left" />
6666
</StackPanel>
67-
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
67+
68+
<Grid>
69+
<Grid.ColumnDefinitions>
70+
<ColumnDefinition Width="Auto" MinWidth="100" />
71+
<ColumnDefinition Width="*" />
72+
<ColumnDefinition Width="Auto" />
73+
</Grid.ColumnDefinitions>
74+
<Grid.RowDefinitions>
75+
<RowDefinition Height="Auto" />
76+
<RowDefinition Height="Auto" />
77+
<RowDefinition Height="Auto" />
78+
</Grid.RowDefinitions>
79+
80+
<!-- Name -->
6881
<TextBlock
69-
MinWidth="150"
70-
Margin="0 10 15 10"
71-
HorizontalAlignment="Left"
82+
Grid.Row="0"
83+
Grid.Column="0"
84+
Margin="0 10 0 0"
7285
VerticalAlignment="Center"
7386
FontSize="14"
7487
Text="{DynamicResource plugin_explorer_name}" />
7588
<TextBox
76-
Margin="10 0 0 0"
89+
Grid.Row="0"
90+
Grid.Column="1"
91+
Margin="10 10 0 0"
7792
VerticalAlignment="Center"
7893
FontSize="12"
79-
Width="250"
8094
Text="{Binding SelectedName, Mode=TwoWay}" />
81-
</StackPanel>
82-
83-
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
95+
96+
<!-- Type -->
8497
<TextBlock
85-
MinWidth="150"
86-
Margin="0 10 15 10"
87-
HorizontalAlignment="Left"
98+
Grid.Row="1"
99+
Grid.Column="0"
100+
Margin="0 10 0 0"
101+
VerticalAlignment="Center"
102+
FontSize="14"
103+
Text="{DynamicResource plugin_explorer_type}" />
104+
<StackPanel
105+
Grid.Row="1"
106+
Grid.Column="1"
107+
Orientation="Horizontal">
108+
<RadioButton
109+
Margin="10 10 0 0"
110+
Content="{DynamicResource plugin_explorer_file}"
111+
GroupName="PathType"
112+
IsChecked="{Binding IsFileSelected}" />
113+
<RadioButton
114+
Margin="10 10 0 0"
115+
Content="{DynamicResource plugin_explorer_folder}"
116+
GroupName="PathType"
117+
IsChecked="{Binding IsFolderSelected}" />
118+
</StackPanel>
119+
<!-- Path -->
120+
<TextBlock
121+
Grid.Row="2"
122+
Grid.Column="0"
123+
Margin="0 10 0 0"
88124
VerticalAlignment="Center"
89125
FontSize="14"
90126
Text="{DynamicResource plugin_explorer_path}" />
91-
92-
93127
<TextBox
94-
Margin="10 0 0 0"
128+
Grid.Row="2"
129+
Grid.Column="1"
130+
Width="250"
131+
Margin="10 10 0 0"
95132
VerticalAlignment="Center"
96133
FontSize="12"
97-
Width="250"
98-
Text="{Binding SelectedPath, Mode=TwoWay}"
99-
IsReadOnly="True" />
134+
IsReadOnly="True"
135+
Text="{Binding SelectedPath, Mode=TwoWay}" />
100136
<Button
101-
Width="80"
137+
Grid.Row="2"
138+
Grid.Column="2"
102139
Height="Auto"
103-
Margin="10 0 0 0"
140+
MinWidth="80"
141+
Margin="10 10 0 0"
104142
HorizontalAlignment="Left"
105143
VerticalAlignment="Center"
106-
Content="{DynamicResource select}"
107-
Click="SelectPath_OnClick" />
108-
</StackPanel>
109-
144+
Click="SelectPath_OnClick"
145+
Content="{DynamicResource select}" />
146+
</Grid>
110147
</StackPanel>
111148
</StackPanel>
112149
<Border
@@ -118,20 +155,20 @@
118155
<Button
119156
x:Name="btnCancel"
120157
Width="145"
121-
Height="30"
122-
Margin="0 0 5 0"
158+
Height="34"
159+
Margin="0 0 5 1"
123160
Click="BtnCancel_OnClick"
124161
Content="{DynamicResource cancel}" />
125162
<Button
126163
Name="DownButton"
127164
Width="145"
128-
Height="30"
129-
Margin="5 0 0 0"
165+
Height="34"
166+
Margin="5 0 0 1"
130167
Click="OnDoneButtonClick"
131168
Style="{StaticResource AccentButtonStyle}">
132169
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
133170
</Button>
134171
</StackPanel>
135172
</Border>
136173
</Grid>
137-
</Window>
174+
</Window>

0 commit comments

Comments
 (0)