Skip to content

Commit 6869aee

Browse files
authored
Merge pull request #1959 from Flow-Launcher/search_source_sort
Remove Obsolete Property and use Status Property for Sorting
2 parents 6ad86f5 + 731c76d commit 6869aee

File tree

7 files changed

+33
-36
lines changed

7 files changed

+33
-36
lines changed

Flow.Launcher/Resources/Dark.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
<SolidColorBrush x:Key="ThemeHoverButton" Color="#3c3c3c" />
6161
<SolidColorBrush x:Key="PopuBGColor" Color="#202020" />
62+
<SolidColorBrush x:Key="PopupBGColor" Color="#202020" />
6263
<SolidColorBrush x:Key="PopupTextColor" Color="#cfcfcf" />
6364
<SolidColorBrush x:Key="PopupButtonAreaBGColor" Color="#2b2b2b" />
6465
<SolidColorBrush x:Key="PopupButtonAreaBorderColor" Color="#3f3f3f" />

Flow.Launcher/Resources/Light.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
<SolidColorBrush x:Key="BasicLabelColor" Color="#1b1b1b" />
5252

5353
<SolidColorBrush x:Key="ThemeHoverButton" Color="#f6f6f6" />
54+
<!-- Typo -->
5455
<SolidColorBrush x:Key="PopuBGColor" Color="#ffffff" />
56+
<SolidColorBrush x:Key="PopupBGColor" Color="#ffffff" />
5557
<SolidColorBrush x:Key="PopupTextColor" Color="#1b1b1b" />
5658
<SolidColorBrush x:Key="PopupButtonAreaBGColor" Color="#f3f3f3" />
5759
<SolidColorBrush x:Key="PopupButtonAreaBorderColor" Color="#e5e5e5" />

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<system:String x:Key="flowlauncher_plugin_websearch_delete">Delete</system:String>
1313
<system:String x:Key="flowlauncher_plugin_websearch_edit">Edit</system:String>
1414
<system:String x:Key="flowlauncher_plugin_websearch_add">Add</system:String>
15+
<system:String x:Key="flowlauncher_plugin_websearch_enabled_label">Enabled</system:String>
1516
<system:String x:Key="flowlauncher_plugin_websearch_true">Enabled</system:String>
1617
<system:String x:Key="flowlauncher_plugin_websearch_false">Disabled</system:String>
1718
<system:String x:Key="flowlauncher_plugin_websearch_confirm">Confirm</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public string IconPath
3535
}
3636

3737
public string Url { get; set; }
38+
39+
[JsonIgnore]
40+
public bool Status => Enabled;
3841
public bool Enabled { get; set; }
3942

4043
public SearchSource DeepCopy()

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Title="{DynamicResource flowlauncher_plugin_websearch_window_title}"
99
Width="550"
1010
d:DataContext="{d:DesignInstance vm:SearchSourceViewModel}"
11-
Background="{DynamicResource PopuBGColor}"
11+
Background="{DynamicResource PopupBGColor}"
1212
Foreground="{DynamicResource PopupTextColor}"
1313
ResizeMode="NoResize"
1414
SizeToContent="Height"
@@ -179,7 +179,7 @@
179179
HorizontalAlignment="Left"
180180
VerticalAlignment="Center"
181181
FontSize="14"
182-
Text="{DynamicResource flowlauncher_plugin_websearch_enabled}" />
182+
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
183183
<CheckBox
184184
Grid.Row="4"
185185
Grid.Column="1"

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,11 @@
6969
<GridViewColumn
7070
Width="130"
7171
DisplayMemberBinding="{Binding ActionKeyword}"
72-
Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}">
73-
<GridViewColumn.CellTemplate>
74-
<DataTemplate>
75-
<TextBlock Text="{Binding ActionKeyword}" />
76-
</DataTemplate>
77-
</GridViewColumn.CellTemplate>
78-
</GridViewColumn>
72+
Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}"/>
7973
<GridViewColumn
8074
Width="350"
8175
DisplayMemberBinding="{Binding Title}"
82-
Header="{DynamicResource flowlauncher_plugin_websearch_title}">
83-
<GridViewColumn.CellTemplate>
84-
<DataTemplate>
85-
<TextBlock Text="{Binding Title}" />
86-
</DataTemplate>
87-
</GridViewColumn.CellTemplate>
88-
</GridViewColumn>
76+
Header="{DynamicResource flowlauncher_plugin_websearch_title}"/>
8977
<GridViewColumn Width="140" Header="{DynamicResource flowlauncher_plugin_websearch_enable}">
9078
<GridViewColumn.CellTemplate>
9179
<DataTemplate>
@@ -94,7 +82,7 @@
9482
<Style TargetType="TextBlock">
9583
<Setter Property="Text" Value="{DynamicResource flowlauncher_plugin_websearch_false}" />
9684
<Style.Triggers>
97-
<DataTrigger Binding="{Binding Enabled, UpdateSourceTrigger=PropertyChanged}" Value="True">
85+
<DataTrigger Binding="{Binding Status, UpdateSourceTrigger=PropertyChanged}" Value="True">
9886
<Setter Property="Text" Value="{DynamicResource flowlauncher_plugin_websearch_true}" />
9987
</DataTrigger>
10088
</Style.Triggers>
@@ -158,7 +146,7 @@
158146
Margin="0,0,8,0"
159147
IsChecked="{Binding Settings.EnableSuggestion}" />
160148
</StackPanel>
161-
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working -->
149+
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSearchSuggestion is not working -->
162150
</DockPanel>
163151
</Border>
164152
</Grid>

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,29 @@ private void SortByColumn(object sender, RoutedEventArgs e)
9696
var columnBinding = headerClicked.Column.DisplayMemberBinding as Binding;
9797
var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string;
9898

99-
Sort(sortBy, direction);
99+
if(sortBy != null) {
100+
Sort(sortBy, direction);
100101

101-
if (direction == ListSortDirection.Ascending)
102-
{
103-
headerClicked.Column.HeaderTemplate =
104-
Resources["HeaderTemplateArrowUp"] as DataTemplate;
105-
}
106-
else
107-
{
108-
headerClicked.Column.HeaderTemplate =
109-
Resources["HeaderTemplateArrowDown"] as DataTemplate;
110-
}
102+
if (direction == ListSortDirection.Ascending)
103+
{
104+
headerClicked.Column.HeaderTemplate =
105+
Resources["HeaderTemplateArrowUp"] as DataTemplate;
106+
}
107+
else
108+
{
109+
headerClicked.Column.HeaderTemplate =
110+
Resources["HeaderTemplateArrowDown"] as DataTemplate;
111+
}
111112

112-
// Remove arrow from previously sorted header
113-
if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked)
114-
{
115-
_lastHeaderClicked.Column.HeaderTemplate = null;
116-
}
113+
// Remove arrow from previously sorted header
114+
if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked)
115+
{
116+
_lastHeaderClicked.Column.HeaderTemplate = null;
117+
}
117118

118-
_lastHeaderClicked = headerClicked;
119-
_lastDirection = direction;
119+
_lastHeaderClicked = headerClicked;
120+
_lastDirection = direction;
121+
}
120122
}
121123
private void Sort(string sortBy, ListSortDirection direction)
122124
{

0 commit comments

Comments
 (0)