Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
78af09a
Add Browser Item Area
onesounds Nov 8, 2021
12b6f30
Merge Custom Control
onesounds Nov 8, 2021
fb97bc4
Add Browser Setting Popup
onesounds Nov 8, 2021
ae86daa
Merge Dev
onesounds Nov 16, 2021
6458c99
Fix Merge
onesounds Nov 16, 2021
a1af487
Add SelectBrowserWindow Binding
taooceros Nov 16, 2021
399c3c9
Finish the binding part of global browser
taooceros Nov 16, 2021
f97344c
Add NewTab option in viewmodel and partially implement the public api
taooceros Dec 5, 2021
a5e0d23
Merge Dev
onesounds Dec 5, 2021
e79f805
Fix dev Merge / Adjust Button Size
onesounds Dec 5, 2021
892a491
Merge branch 'GlobalBrowserSetting' of github.com:onesounds/Flow.Laun…
taooceros Dec 5, 2021
7a30367
Make private arg editable for default profile
taooceros Dec 5, 2021
47562ea
Edit default browser behavior
taooceros Dec 5, 2021
d8eef69
Use Global Browser Setting around flow
taooceros Dec 5, 2021
99a4a3c
Adjust arg position
taooceros Dec 5, 2021
9c86af7
Align Bookmark plugin into global browser
taooceros Dec 5, 2021
ef959d2
Remove BrowserSetting item in bookmark / Url / Websearch
onesounds Dec 5, 2021
1edcc85
Adjust Window Layout and Color
onesounds Dec 6, 2021
f2e284e
Merge Dev
onesounds Dec 6, 2021
6468b14
Merge remote-tracking branch 'origin/dev' into GlobalBrowserSetting
jjw24 Dec 6, 2021
00f514f
version bump plugins
jjw24 Dec 7, 2021
e84e5b1
remove obsolete new tab/window methods
jjw24 Dec 7, 2021
5c4cb7c
Fix Done Button (remove wrong disable state)
onesounds Dec 7, 2021
d2e689a
Merge branch 'GlobalBrowserSetting' of https://github.com/onesounds/F…
onesounds Dec 7, 2021
40d7baa
Add Chrome, Edge, Firefox Browser Profile
onesounds Dec 7, 2021
ba2853b
Fix Edge Private arg
onesounds Dec 7, 2021
b286762
Update Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs
taooceros Dec 8, 2021
8ba52ff
Update Flow.Launcher/SettingWindow.xaml.cs
taooceros Dec 8, 2021
1278881
Update Flow.Launcher/SelectBrowserWindow.xaml.cs
taooceros Dec 8, 2021
171a501
Update Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
taooceros Dec 8, 2021
d2bb1e8
Update Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewMod…
taooceros Dec 8, 2021
233a338
Update Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewMod…
taooceros Dec 8, 2021
cbd2337
Update Flow.Launcher/PublicAPIInstance.cs
taooceros Dec 8, 2021
d952950
remove comment
onesounds Dec 8, 2021
932dea0
Add Checkbox disable when no private arg
onesounds Dec 8, 2021
af2277d
add backwards compatibility for open in new browser tab/window
jjw24 Dec 8, 2021
05fd41a
fix new tab not save issue
taooceros Dec 8, 2021
38a9b9a
Update SelectBrowserWindow.xaml.cs
onesounds Dec 8, 2021
53f965f
remove group to make sure everything static
taooceros Dec 8, 2021
9369589
ignore openinnewwindow
taooceros Dec 8, 2021
721a658
Change Space Position for NewWindow
taooceros Dec 9, 2021
13ccd58
move url before options
taooceros Dec 9, 2021
581e842
Revert "move url before options"
taooceros Dec 9, 2021
dbab7b6
Optional Inprivate argument & Comment
taooceros Dec 9, 2021
27d1796
Fix Suggestion Result Action
taooceros Dec 9, 2021
b3b85c1
update comment
jjw24 Dec 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Flow.Launcher.Plugin;
using System.Text.Json.Serialization;

namespace Flow.Launcher.Infrastructure.UserSettings
{
public class CustomBrowserViewModel : BaseModel
{
public string Name { get; set; }
public string Path { get; set; }
public string PrivateArg { get; set; }
public bool EnablePrivate { get; set; }
public bool OpenInTab { get; set; } = true;
[JsonIgnore]
public bool OpenInNewWindow => !OpenInTab;
public bool Editable { get; set; } = true;

public CustomBrowserViewModel Copy()
{
return new CustomBrowserViewModel
{
Name = Name,
Path = Path,
OpenInTab = OpenInTab,
PrivateArg = PrivateArg,
EnablePrivate = EnablePrivate,
Editable = Editable
};
}
}
}



50 changes: 48 additions & 2 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public string Language
public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; }
public bool UseGlyphIcons { get; set; } = true;
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = true;
public bool FirstLaunch { get; set; } = true;

public int CustomExplorerIndex { get; set; } = 0;
Expand Down Expand Up @@ -84,8 +86,52 @@ public CustomExplorerViewModel CustomExplorer
}
};

public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = true;
public int CustomBrowserIndex { get; set; } = 0;

[JsonIgnore]
public CustomBrowserViewModel CustomBrowser
{
get => CustomBrowserList[CustomBrowserIndex];
set => CustomBrowserList[CustomBrowserIndex] = value;
}

public List<CustomBrowserViewModel> CustomBrowserList { get; set; } = new()
{
new()
{
Name = "Default",
Path = "*",
PrivateArg = "",
EnablePrivate = false,
Editable = false
},
new()
{
Name = "Google Chrome",
Path = "chrome",
PrivateArg = "-incognito",
EnablePrivate = false,
Editable = false
},
new()
{
Name = "Mozilla Firefox",
Path = "firefox",
PrivateArg = "-private",
EnablePrivate = false,
Editable = false
}
,
new()
{
Name = "MS Edge",
Path = "msedge",
PrivateArg = "-inPrivate",
EnablePrivate = false,
Editable = false
}
};


/// <summary>
/// when false Alphabet static service will always return empty results
Expand Down
5 changes: 5 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,10 @@ public interface IPublicAPI
/// <param name="DirectoryPath">Directory Path to open</param>
/// <param name="FileName">Extra FileName Info</param>
public void OpenDirectory(string DirectoryPath, string FileName = null);

/// <summary>
/// Open Url in the configured default browser for Flow's Settings.
/// </summary>
public void OpenUrl(string url, bool? inPrivate = null);
}
}
44 changes: 34 additions & 10 deletions Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@ private static string GetDefaultBrowserPath()
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome.
/// </summary>
public static void NewBrowserWindow(this string url, string browserPath = "")
public static void OpenInBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;

var browserExecutableName = browserPath?
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
.Last();
.Split(new[]
{
Path.DirectorySeparatorChar
}, StringSplitOptions.None)
.Last();

var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath;

// Internet Explorer will open url in new browser window, and does not take the --new-window parameter
var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url;
var browserArguements = (browserExecutableName == "iexplore.exe" ? "" : "--new-window ") + (inPrivate ? $"{privateArg} " : "") + url;

var psi = new ProcessStartInfo
{
Expand All @@ -61,24 +64,36 @@ public static void NewBrowserWindow(this string url, string browserPath = "")
}
catch (System.ComponentModel.Win32Exception)
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
Process.Start(new ProcessStartInfo
{
FileName = url, UseShellExecute = true
});
}
}

[Obsolete("This is provided for backwards compatibility after 1.9.0 release, e.g. GitHub plugin. Use the new method instead")]
public static void NewBrowserWindow(this string url, string browserPath = "")
{
OpenInBrowserWindow(url, browserPath);
}

/// <summary>
/// Opens search as a tab in the default browser chosen in Windows settings.
/// </summary>
public static void NewTabInBrowser(this string url, string browserPath = "")
public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;

var psi = new ProcessStartInfo() { UseShellExecute = true };
var psi = new ProcessStartInfo()
{
UseShellExecute = true
};
try
{
if (!string.IsNullOrEmpty(browserPath))
{
psi.FileName = browserPath;
psi.Arguments = url;
psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url;
}
else
{
Expand All @@ -90,8 +105,17 @@ public static void NewTabInBrowser(this string url, string browserPath = "")
// This error may be thrown if browser path is incorrect
catch (System.ComponentModel.Win32Exception)
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
Process.Start(new ProcessStartInfo
{
FileName = url, UseShellExecute = true
});
}
}

[Obsolete("This is provided for backwards compatibility after 1.9.0 release, e.g. GitHub plugin. Use the new method instead")]
public static void NewTabInBrowser(this string url, string browserPath = "")
{
OpenInBrowserTab(url, browserPath);
}
}
}
}
12 changes: 12 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<system:String x:Key="ignoreHotkeysOnFullscreenToolTip">Disable Flow Launcher activation when a full screen application is active (Recommended for games).</system:String>
<system:String x:Key="defaultFileManager">Default File Manager</system:String>
<system:String x:Key="defaultFileManagerToolTip">Select the file manager to use when opening the folder.</system:String>
<system:String x:Key="defaultBrowser">Default Web Browser</system:String>
<system:String x:Key="defaultBrowserToolTip">Setting for New Tab, New Window, Private Mode.</system:String>
<system:String x:Key="pythonDirectory">Python Directory</system:String>
<system:String x:Key="autoUpdates">Auto Update</system:String>
<system:String x:Key="selectPythonDirectory">Select</system:String>
Expand Down Expand Up @@ -164,6 +166,16 @@
<system:String x:Key="fileManager_directory_arg">Arg For Folder</system:String>
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>

<!-- DefaultBrowser Setting Dialog -->
<system:String x:Key="defaultBrowserTitle">Default Web Browser</system:String>
<system:String x:Key="defaultBrowser_tips">The default setting follows the OS default browser setting. If specified separately, flow uses that browser.</system:String>
<system:String x:Key="defaultBrowser_name">Browser</system:String>
<system:String x:Key="defaultBrowser_profile_name">Browser Name</system:String>
<system:String x:Key="defaultBrowser_path">Browser Path</system:String>
<system:String x:Key="defaultBrowser_newtab">New Window</system:String>
<system:String x:Key="defaultBrowser_newWindow">New Tab</system:String>
<system:String x:Key="defaultBrowser_parameter">Priviate Mode</system:String>

<!-- Priority Setting Dialog -->
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
<system:String x:Key="priority_tips">Greater the number, the higher the result will be ranked. Try setting it as 5. If you want the results to be lower than any other plugin's, provide a negative number</system:String>
Expand Down
21 changes: 19 additions & 2 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void ShellRun(string cmd, string filename = "cmd.exe")
var startInfo = ShellCommand.SetProcessStartInfo(filename, arguments: args, createNoWindow: true);
ShellCommand.Execute(startInfo);
}

public void CopyToClipboard(string text)
{
Clipboard.SetDataObject(text);
Expand Down Expand Up @@ -196,7 +196,7 @@ public void SavePluginSettings()

public void OpenDirectory(string DirectoryPath, string FileName = null)
{
using Process explorer = new Process();
using var explorer = new Process();
var explorerInfo = _settingsVM.Settings.CustomExplorer;
explorer.StartInfo = new ProcessStartInfo
{
Expand All @@ -209,6 +209,23 @@ public void OpenDirectory(string DirectoryPath, string FileName = null)
explorer.Start();
}

public void OpenUrl(string url, bool? inPrivate = null)
{
var browserInfo = _settingsVM.Settings.CustomBrowser;

var path = browserInfo.Path == "*" ? "" : browserInfo.Path;

if (browserInfo.OpenInTab)
{
url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
}
else
{
url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
}

}

public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;

#endregion
Expand Down
Loading