Merge pull request #13 from Flow-Launcher/fix_settings_openurl

Fix Process.Start on urls and directories
This commit is contained in:
Jeremy Wu 2020-04-25 13:37:54 +10:00 committed by GitHub
commit 21bf506bf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 20 deletions

View file

@ -7,6 +7,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
{
public static class FilesFolders
{
private const string FileExplorerProgramName = "explorer";
public static void Copy(this string sourcePath, string targetPath)
{
// Get the subdirectories for the specified directory.
@ -111,10 +112,11 @@ namespace Flow.Launcher.Plugin.SharedCommands
public static void OpenLocationInExporer(string location)
{
var psi = new ProcessStartInfo { FileName = FileExplorerProgramName, UseShellExecute = true, Arguments = location };
try
{
if (LocationExists(location))
Process.Start(location);
Process.Start(psi);
}
catch (Exception e)
{

View file

@ -9,6 +9,7 @@ using System.Windows.Documents;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands;
namespace Flow.Launcher
{
@ -51,8 +52,8 @@ namespace Flow.Launcher
var link = new Hyperlink { IsEnabled = true };
link.Inlines.Add(url);
link.NavigateUri = new Uri(url);
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());
link.Click += (s, e) => Process.Start(url);
link.RequestNavigate += (s, e) => SearchWeb.NewBrowserWindow(e.Uri.ToString());
link.Click += (s, e) => SearchWeb.NewBrowserWindow(url);
paragraph.Inlines.Add(textBeforeUrl);
paragraph.Inlines.Add(link);

View file

@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using Microsoft.Win32;
using NHotkey;
using NHotkey.Wpf;
using Flow.Launcher.Core;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.ViewModel;
namespace Flow.Launcher
@ -233,7 +229,7 @@ namespace Flow.Launcher
var uri = new Uri(website);
if (Uri.CheckSchemeName(uri.Scheme))
{
Process.Start(website);
SearchWeb.NewBrowserWindow(website);
}
}
}
@ -244,10 +240,8 @@ namespace Flow.Launcher
if (e.ChangedButton == MouseButton.Left)
{
var directory = _viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory))
{
Process.Start(directory);
}
if (!string.IsNullOrEmpty(directory))
FilesFolders.OpenLocationInExporer(directory);
}
}
#endregion
@ -269,7 +263,7 @@ namespace Flow.Launcher
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
SearchWeb.NewBrowserWindow(e.Uri.AbsoluteUri);
e.Handled = true;
}

View file

@ -17,6 +17,7 @@ using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Storage;
namespace Flow.Launcher.ViewModel
@ -130,7 +131,7 @@ namespace Flow.Launcher.ViewModel
StartHelpCommand = new RelayCommand(_ =>
{
Process.Start("http://doc.wox.one/");
SearchWeb.NewBrowserWindow("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/");
});
OpenResultCommand = new RelayCommand(index =>

View file

@ -7,6 +7,7 @@ using System.Windows;
using System.Windows.Controls;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin.SharedCommands;
namespace Flow.Launcher.Plugin.Folder
{
@ -18,8 +19,7 @@ namespace Flow.Launcher.Plugin.Folder
public const string CopyImagePath = "Images\\copy.png";
private string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
private const string _fileExplorerProgramName = "explorer";
private static List<string> _driverNames;
private PluginInitContext _context;
@ -103,7 +103,7 @@ namespace Flow.Launcher.Plugin.Folder
{
try
{
Process.Start(_fileExplorerProgramName, path);
FilesFolders.OpenLocationInExporer(path);
return true;
}
catch (Exception ex)
@ -255,7 +255,7 @@ namespace Flow.Launcher.Plugin.Folder
{
try
{
Process.Start(_fileExplorerProgramName, filePath);
FilesFolders.OpenLocationInExporer(filePath);
}
catch (Exception ex)
{
@ -286,7 +286,7 @@ namespace Flow.Launcher.Plugin.Folder
Score = 500,
Action = c =>
{
Process.Start(_fileExplorerProgramName, search);
FilesFolders.OpenLocationInExporer(search);
return true;
}
};