Skip to content

Commit f244812

Browse files
authored
Merge pull request #3891 from zoltanvi/feature/web_search_private_mode
Add private mode option to WebSearch plugin items
2 parents cc42cd6 + db84dff commit f244812

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<system:String x:Key="flowlauncher_plugin_websearch_edit">Edit</system:String>
1414
<system:String x:Key="flowlauncher_plugin_websearch_add">Add</system:String>
1515
<system:String x:Key="flowlauncher_plugin_websearch_enabled_label">Enabled</system:String>
16+
<system:String x:Key="flowlauncher_plugin_websearch_private_mode_label">Private Mode</system:String>
1617
<system:String x:Key="flowlauncher_plugin_websearch_true">Enabled</system:String>
1718
<system:String x:Key="flowlauncher_plugin_websearch_false">Disabled</system:String>
1819
<system:String x:Key="flowlauncher_plugin_websearch_confirm">Confirm</system:String>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
7171
Score = score,
7272
Action = c =>
7373
{
74-
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));
74+
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)), searchSource.IsPrivateMode);
7575

7676
return true;
7777
},
@@ -135,7 +135,7 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
135135
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
136136
Action = c =>
137137
{
138-
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
138+
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)), searchSource.IsPrivateMode);
139139

140140
return true;
141141
},

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Flow.Launcher.Plugin.WebSearch
77
public class SearchSource : BaseModel
88
{
99
public string Title { get; set; }
10+
1011
public string ActionKeyword { get; set; }
1112

1213
[NotNull]
@@ -19,21 +20,17 @@ public class SearchSource : BaseModel
1920
/// Custom icons are placed in the user data directory
2021
/// </summary>
2122
[JsonIgnore]
22-
public string IconPath
23-
{
24-
get
25-
{
26-
if (CustomIcon)
27-
return Path.Combine(Main.CustomImagesDirectory, Icon);
28-
29-
return Path.Combine(Main.DefaultImagesDirectory, Icon);
30-
}
31-
}
23+
public string IconPath => CustomIcon
24+
? Path.Combine(Main.CustomImagesDirectory, Icon)
25+
: Path.Combine(Main.DefaultImagesDirectory, Icon);
3226

3327
public string Url { get; set; }
3428

3529
[JsonIgnore]
3630
public bool Status => Enabled;
31+
32+
public bool IsPrivateMode { get; set; }
33+
3734
public bool Enabled { get; set; }
3835

3936
public SearchSource DeepCopy()
@@ -45,8 +42,10 @@ public SearchSource DeepCopy()
4542
Url = Url,
4643
Icon = Icon,
4744
CustomIcon = CustomIcon,
45+
IsPrivateMode = IsPrivateMode,
4846
Enabled = Enabled
4947
};
48+
5049
return webSearch;
5150
}
5251
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<RowDefinition />
102102
<RowDefinition />
103103
<RowDefinition />
104+
<RowDefinition />
104105
</Grid.RowDefinitions>
105106
<TextBlock
106107
Grid.Row="0"
@@ -181,12 +182,26 @@
181182
HorizontalAlignment="Left"
182183
VerticalAlignment="Center"
183184
FontSize="14"
184-
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
185+
Text="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}" />
185186
<CheckBox
186187
Grid.Row="4"
187188
Grid.Column="1"
188189
Margin="10 10 10 15"
189190
VerticalAlignment="Center"
191+
IsChecked="{Binding SearchSource.IsPrivateMode}" />
192+
<TextBlock
193+
Grid.Row="5"
194+
Grid.Column="0"
195+
Margin="10 0 10 10"
196+
HorizontalAlignment="Left"
197+
VerticalAlignment="Center"
198+
FontSize="14"
199+
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
200+
<CheckBox
201+
Grid.Row="5"
202+
Grid.Column="1"
203+
Margin="10 0 10 10"
204+
VerticalAlignment="Center"
190205
IsChecked="{Binding SearchSource.Enabled}" />
191206
</Grid>
192207
</StackPanel>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@
9292
</DataTemplate>
9393
</GridViewColumn.CellTemplate>
9494
</GridViewColumn>
95+
<GridViewColumn
96+
Width="120"
97+
Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
98+
<GridViewColumn.CellTemplate>
99+
<DataTemplate>
100+
<CheckBox
101+
HorizontalAlignment="Center"
102+
VerticalAlignment="Center"
103+
IsChecked="{Binding IsPrivateMode}"
104+
IsEnabled="False"
105+
/>
106+
</DataTemplate>
107+
</GridViewColumn.CellTemplate>
108+
</GridViewColumn>
95109
</GridView>
96110
</ListView.View>
97111
</ListView>

0 commit comments

Comments
 (0)