Skip to content

Commit 21bf506

Browse files
authored
Merge pull request #13 from Flow-Launcher/fix_settings_openurl
Fix Process.Start on urls and directories
2 parents 0f298ec + e3fca3a commit 21bf506

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
77
{
88
public static class FilesFolders
99
{
10+
private const string FileExplorerProgramName = "explorer";
1011
public static void Copy(this string sourcePath, string targetPath)
1112
{
1213
// Get the subdirectories for the specified directory.
@@ -111,10 +112,11 @@ public static bool FileExits(this string filePath)
111112

112113
public static void OpenLocationInExporer(string location)
113114
{
115+
var psi = new ProcessStartInfo { FileName = FileExplorerProgramName, UseShellExecute = true, Arguments = location };
114116
try
115117
{
116118
if (LocationExists(location))
117-
Process.Start(location);
119+
Process.Start(psi);
118120
}
119121
catch (Exception e)
120122
{

Flow.Launcher/ReportWindow.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Flow.Launcher.Helper;
1010
using Flow.Launcher.Infrastructure;
1111
using Flow.Launcher.Infrastructure.Logger;
12+
using Flow.Launcher.Plugin.SharedCommands;
1213

1314
namespace Flow.Launcher
1415
{
@@ -51,8 +52,8 @@ private Paragraph Hyperlink(string textBeforeUrl, string url)
5152
var link = new Hyperlink { IsEnabled = true };
5253
link.Inlines.Add(url);
5354
link.NavigateUri = new Uri(url);
54-
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());
55-
link.Click += (s, e) => Process.Start(url);
55+
link.RequestNavigate += (s, e) => SearchWeb.NewBrowserWindow(e.Uri.ToString());
56+
link.Click += (s, e) => SearchWeb.NewBrowserWindow(url);
5657

5758
paragraph.Inlines.Add(textBeforeUrl);
5859
paragraph.Inlines.Add(link);

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Diagnostics;
43
using System.IO;
5-
using System.Linq;
6-
using System.Net;
74
using System.Windows;
8-
using System.Windows.Controls;
95
using System.Windows.Input;
106
using System.Windows.Navigation;
117
using Microsoft.Win32;
128
using NHotkey;
139
using NHotkey.Wpf;
14-
using Flow.Launcher.Core;
1510
using Flow.Launcher.Core.Plugin;
1611
using Flow.Launcher.Core.Resource;
1712
using Flow.Launcher.Infrastructure.Hotkey;
1813
using Flow.Launcher.Infrastructure.UserSettings;
1914
using Flow.Launcher.Plugin;
15+
using Flow.Launcher.Plugin.SharedCommands;
2016
using Flow.Launcher.ViewModel;
2117

2218
namespace Flow.Launcher
@@ -233,7 +229,7 @@ private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
233229
var uri = new Uri(website);
234230
if (Uri.CheckSchemeName(uri.Scheme))
235231
{
236-
Process.Start(website);
232+
SearchWeb.NewBrowserWindow(website);
237233
}
238234
}
239235
}
@@ -244,10 +240,8 @@ private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
244240
if (e.ChangedButton == MouseButton.Left)
245241
{
246242
var directory = _viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
247-
if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory))
248-
{
249-
Process.Start(directory);
250-
}
243+
if (!string.IsNullOrEmpty(directory))
244+
FilesFolders.OpenLocationInExporer(directory);
251245
}
252246
}
253247
#endregion
@@ -269,7 +263,7 @@ private async void OnCheckUpdates(object sender, RoutedEventArgs e)
269263

270264
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
271265
{
272-
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
266+
SearchWeb.NewBrowserWindow(e.Uri.AbsoluteUri);
273267
e.Handled = true;
274268
}
275269

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Flow.Launcher.Infrastructure.Storage;
1818
using Flow.Launcher.Infrastructure.UserSettings;
1919
using Flow.Launcher.Plugin;
20+
using Flow.Launcher.Plugin.SharedCommands;
2021
using Flow.Launcher.Storage;
2122

2223
namespace Flow.Launcher.ViewModel
@@ -130,7 +131,7 @@ private void InitializeKeyCommands()
130131

131132
StartHelpCommand = new RelayCommand(_ =>
132133
{
133-
Process.Start("http://doc.wox.one/");
134+
SearchWeb.NewBrowserWindow("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/");
134135
});
135136

136137
OpenResultCommand = new RelayCommand(index =>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Windows.Controls;
88
using Flow.Launcher.Infrastructure;
99
using Flow.Launcher.Infrastructure.Storage;
10+
using Flow.Launcher.Plugin.SharedCommands;
1011

1112
namespace Flow.Launcher.Plugin.Folder
1213
{
@@ -18,8 +19,7 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMe
1819
public const string CopyImagePath = "Images\\copy.png";
1920

2021
private string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
21-
22-
private const string _fileExplorerProgramName = "explorer";
22+
2323
private static List<string> _driverNames;
2424
private PluginInitContext _context;
2525

@@ -103,7 +103,7 @@ private Result CreateFolderResult(string title, string subtitle, string path, Qu
103103
{
104104
try
105105
{
106-
Process.Start(_fileExplorerProgramName, path);
106+
FilesFolders.OpenLocationInExporer(path);
107107
return true;
108108
}
109109
catch (Exception ex)
@@ -255,7 +255,7 @@ private static Result CreateFileResult(string filePath, Query query)
255255
{
256256
try
257257
{
258-
Process.Start(_fileExplorerProgramName, filePath);
258+
FilesFolders.OpenLocationInExporer(filePath);
259259
}
260260
catch (Exception ex)
261261
{
@@ -286,7 +286,7 @@ private static Result CreateOpenCurrentFolderResult(string incompleteName, strin
286286
Score = 500,
287287
Action = c =>
288288
{
289-
Process.Start(_fileExplorerProgramName, search);
289+
FilesFolders.OpenLocationInExporer(search);
290290
return true;
291291
}
292292
};

0 commit comments

Comments
 (0)