-
-
Notifications
You must be signed in to change notification settings - Fork 442
Enhancement: Support Custom Browser Path & Open in window / tab & In private for URL Plugin #3944
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
Open
Jack251970
wants to merge
25
commits into
dev
Choose a base branch
from
url_open_enhancement
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
56bdfa7
Improve code quality
Jack251970 f848d1b
Improve code quality
Jack251970 c9ca9ad
Add more settings
Jack251970 2d5626b
Use more settings
Jack251970 5976dde
Add more strings
Jack251970 48e845c
Change language strings
Jack251970 1dc1643
Change language strings
Jack251970 33a9654
Add settings control
Jack251970 1303ae5
Update string resource
Jack251970 978b185
Add PrivateModeArgument & Add IPropertyChanged interface for some pro…
Jack251970 7ca3769
Use PrivateModeArgument & Implement new logic for browser openning
Jack251970 34a58bc
Add InverseBoolConverter
Jack251970 c17db8c
Use using statements
Jack251970 cdf3905
Use InverseBoolConverter
Jack251970 33aef7e
Add convert back implementation for InverseBoolConverter
Jack251970 4f49077
Add & Use BoolToVisibilityConverter
Jack251970 96d7d18
Change string resource names & Redesign setting panel
Jack251970 3f6bebd
Keep default value same as origin
Jack251970 45bb6e9
Merge branch 'dev' into url_open_enhancement
Jack251970 c2e7976
Improve code quality
Jack251970 3a8c64b
update wording
jjw24 d7d88a9
Merge branch 'dev' into url_open_enhancement
Jack251970 08bf147
Merge branch 'dev' into url_open_enhancement
Jack251970 64e9150
Fix build issue
Jack251970 ec41ec2
Improve code quality
Jack251970 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Plugins/Flow.Launcher.Plugin.Url/Converters/BoolToVisibilityConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace Flow.Launcher.Plugin.Url.Converters; | ||
|
||
[ValueConversion(typeof(bool), typeof(Visibility))] | ||
public class BoolToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is not bool) | ||
throw new ArgumentException("value should be boolean", nameof(value)); | ||
|
||
return (bool)value ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Plugins/Flow.Launcher.Plugin.Url/Converters/InverseBoolConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace Flow.Launcher.Plugin.Url.Converters; | ||
|
||
[ValueConversion(typeof(bool), typeof(bool))] | ||
public class InverseBoolConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is not bool) | ||
throw new ArgumentException("value should be boolean", nameof(value)); | ||
|
||
return !(bool)value; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is not bool) | ||
throw new ArgumentException("value should be boolean", nameof(value)); | ||
|
||
return !(bool)value; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib"> | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib"> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_open_search_in">Open search in:</system:String> | ||
<system:String x:Key="flowlauncher_plugin_new_window">New Window</system:String> | ||
<system:String x:Key="flowlauncher_plugin_new_tab">New Tab</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_open_url">Open url:{0}</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_cannot_open_url">Can't open url:{0}</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_plugin_name">URL</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_plugin_description">Open the typed URL from Flow Launcher</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Please set your browser path:</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Choose</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_use_custom_browser">Use custom instead of Flow's default web browser</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_browser_path">Browser path</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_new_tab">New tab</system:String> | ||
<system:String x:Key="flowlauncher_plugin_url_new_window">New window</system:String> | ||
|
||
<system:String x:Key="flowlauncher_plugin_url_private_mode">Private mode</system:String> | ||
</ResourceDictionary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,51 @@ | ||
namespace Flow.Launcher.Plugin.Url | ||
Jack251970 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public class Settings | ||
public class Settings : BaseModel | ||
{ | ||
public string BrowserPath { get; set; } | ||
private bool _useCustomBrowser = false; | ||
public bool UseCustomBrowser | ||
{ | ||
get => _useCustomBrowser; | ||
set | ||
{ | ||
if (_useCustomBrowser != value) | ||
{ | ||
_useCustomBrowser = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
|
||
public bool OpenInNewBrowserWindow { get; set; } = true; | ||
private string _browserPath = string.Empty; | ||
public string BrowserPath | ||
{ | ||
get => _browserPath; | ||
set | ||
{ | ||
if (_browserPath != value) | ||
{ | ||
_browserPath = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
|
||
private bool _openInNewBrowserWindow = true; | ||
public bool OpenInNewBrowserWindow | ||
{ | ||
get => _openInNewBrowserWindow; | ||
set | ||
{ | ||
if (_openInNewBrowserWindow != value) | ||
{ | ||
_openInNewBrowserWindow = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
|
||
public bool OpenInPrivateMode { get; set; } = false; | ||
Jack251970 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public string PrivateModeArgument { get; set; } = string.Empty; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<UserControl | ||
x:Class="Flow.Launcher.Plugin.Url.SettingsControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:converters="clr-namespace:Flow.Launcher.Plugin.Url.Converters" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Url" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
DataContext="{Binding RelativeSource={RelativeSource Self}}" | ||
mc:Ignorable="d"> | ||
<UserControl.Resources> | ||
<converters:InverseBoolConverter x:Key="InverseBoolConverter" /> | ||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> | ||
</UserControl.Resources> | ||
|
||
<Grid Margin="{StaticResource SettingPanelMargin}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="auto" /> | ||
<RowDefinition Height="auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<CheckBox | ||
Grid.Row="0" | ||
Margin="{StaticResource SettingPanelItemTopBottomMargin}" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Content="{DynamicResource flowlauncher_plugin_url_use_custom_browser}" | ||
IsChecked="{Binding Settings.UseCustomBrowser, Mode=TwoWay}" /> | ||
|
||
<Grid | ||
Grid.Row="1" | ||
HorizontalAlignment="Left" | ||
Visibility="{Binding Settings.UseCustomBrowser, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="auto" /> | ||
<RowDefinition Height="auto" /> | ||
<RowDefinition Height="auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBlock | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}" | ||
VerticalAlignment="Center" | ||
FontSize="14" | ||
Text="{DynamicResource flowlauncher_plugin_url_browser_path}" /> | ||
<Grid | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBox | ||
Grid.Column="0" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Center" | ||
IsReadOnly="True" | ||
Text="{Binding Settings.BrowserPath, Mode=OneWay}" /> | ||
<Button | ||
Grid.Column="1" | ||
Margin="{StaticResource SettingPanelItemLeftMargin}" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Click="SelectBrowserPath" | ||
Content="{DynamicResource flowlauncher_plugin_url_plugin_choose}" /> | ||
</Grid> | ||
|
||
<StackPanel | ||
Grid.Row="1" | ||
Grid.Column="1" | ||
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}" | ||
Orientation="Horizontal"> | ||
<RadioButton Content="{DynamicResource flowlauncher_plugin_url_new_tab}" IsChecked="{Binding Settings.OpenInNewBrowserWindow, Converter={StaticResource InverseBoolConverter}, Mode=TwoWay}" /> | ||
<RadioButton Content="{DynamicResource flowlauncher_plugin_url_new_window}" IsChecked="{Binding Settings.OpenInNewBrowserWindow, Mode=TwoWay}" /> | ||
</StackPanel> | ||
|
||
<TextBlock | ||
Grid.Row="2" | ||
Grid.Column="0" | ||
Margin="{StaticResource SettingPanelItemTopBottomMargin}" | ||
VerticalAlignment="Center" | ||
FontSize="14" | ||
Text="{DynamicResource flowlauncher_plugin_url_private_mode}" /> | ||
<Grid | ||
Grid.Row="2" | ||
Grid.Column="1" | ||
Margin="{StaticResource SettingPanelItemLeftTopBottomMargin}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBox | ||
Grid.Column="0" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Center" | ||
Text="{Binding Settings.PrivateModeArgument, Mode=TwoWay}" /> | ||
<CheckBox | ||
Grid.Column="1" | ||
Margin="{StaticResource SettingPanelItemLeftMargin}" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Content="" | ||
IsChecked="{Binding Settings.OpenInPrivateMode, Mode=TwoWay}" /> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we've got a same converter. Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in url project. We must need to keep it.