Skip to content

Add private mode option to WebSearch plugin items #3891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="flowlauncher_plugin_websearch_edit">Edit</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_add">Add</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_enabled_label">Enabled</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_private_mode_label">Private Mode</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_true">Enabled</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_false">Disabled</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_confirm">Confirm</system:String>
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
var title = keyword;
string subtitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_search") + " " + searchSource.Title;

// Action Keyword match apear on top

Check warning on line 47 in Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`apear` is not a recognized word. (unrecognized-spelling)
var score = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreStandard : scoreStandard + 1;

// This populates the associated action keyword search entry
Expand All @@ -71,7 +71,7 @@
Score = score,
Action = c =>
{
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)), searchSource.IsPrivateMode);

return true;
},
Expand Down Expand Up @@ -135,7 +135,7 @@
ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword,
Action = c =>
{
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
_context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)), searchSource.IsPrivateMode);

return true;
},
Expand All @@ -152,7 +152,7 @@
{
Title = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_title"),
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_subtitle"),
IcoPath = "Images/copylink.png",

Check warning on line 155 in Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`copylink` is not a recognized word. (unrecognized-spelling)
Action = c =>
{
_context.API.CopyToClipboard(selected.ContextData as string);
Expand Down
19 changes: 9 additions & 10 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Flow.Launcher.Plugin.WebSearch
public class SearchSource : BaseModel
{
public string Title { get; set; }

public string ActionKeyword { get; set; }

[NotNull]
Expand All @@ -19,21 +20,17 @@ public class SearchSource : BaseModel
/// Custom icons are placed in the user data directory
/// </summary>
[JsonIgnore]
public string IconPath
{
get
{
if (CustomIcon)
return Path.Combine(Main.CustomImagesDirectory, Icon);

return Path.Combine(Main.DefaultImagesDirectory, Icon);
}
}
public string IconPath => CustomIcon
? Path.Combine(Main.CustomImagesDirectory, Icon)
: Path.Combine(Main.DefaultImagesDirectory, Icon);

public string Url { get; set; }

[JsonIgnore]
public bool Status => Enabled;

public bool IsPrivateMode { get; set; }

public bool Enabled { get; set; }

public SearchSource DeepCopy()
Expand All @@ -45,8 +42,10 @@ public SearchSource DeepCopy()
Url = Url,
Icon = Icon,
CustomIcon = CustomIcon,
IsPrivateMode = IsPrivateMode,
Enabled = Enabled
};

return webSearch;
}
}
Expand Down
17 changes: 16 additions & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Expand Down Expand Up @@ -181,12 +182,26 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
Text="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}" />
<CheckBox
Grid.Row="4"
Grid.Column="1"
Margin="10 10 10 15"
VerticalAlignment="Center"
IsChecked="{Binding SearchSource.IsPrivateMode}" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
Margin="10 0 10 10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_websearch_enabled_label}" />
<CheckBox
Grid.Row="5"
Grid.Column="1"
Margin="10 0 10 10"
VerticalAlignment="Center"
IsChecked="{Binding SearchSource.Enabled}" />
</Grid>
</StackPanel>
Expand Down
14 changes: 14 additions & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
Width="120"
Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsPrivateMode}"
IsEnabled="False"
/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Expand Down
Loading