Skip to content

Commit

Permalink
Merge pull request #2679 from Wox-launcher/dev
Browse files Browse the repository at this point in the history
2019 update
  • Loading branch information
bao-qian authored Dec 19, 2019
2 parents 9de8b16 + 6c555d1 commit 623cea6
Show file tree
Hide file tree
Showing 49 changed files with 923 additions and 230 deletions.
1 change: 1 addition & 0 deletions .leu

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Plugins/HelloWorldPython/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Author":"happlebao",
"Version":"1.0",
"Language":"python",
"Website":"https://github.com/Wox-launche/Wox",
"Website":"https://github.com/Wox-launcher/Wox",
"IcoPath":"Images\\app.png",
"ExecuteFileName":"main.py"
}
4 changes: 2 additions & 2 deletions Plugins/Wox.Plugin.ControlPanel/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ private int Score(ControlPanelItem item, string query)
var scores = new List<int> {0};
if (string.IsNullOrEmpty(item.LocalizedString))
{
var score1 = StringMatcher.Score(item.LocalizedString, query);
var score1 = StringMatcher.FuzzySearch(query, item.LocalizedString).ScoreAfterSearchPrecisionFilter();
var score2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
scores.Add(score1);
scores.Add(score2);
}
if (!string.IsNullOrEmpty(item.InfoTip))
{
var score1 = StringMatcher.Score(item.InfoTip, query);
var score1 = StringMatcher.FuzzySearch(query, item.InfoTip).ScoreAfterSearchPrecisionFilter();
var score2 = StringMatcher.ScoreForPinyin(item.InfoTip, query);
scores.Add(score1);
scores.Add(score2);
Expand Down
4 changes: 4 additions & 0 deletions Plugins/Wox.Plugin.Everything/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<system:String x:Key="wox_plugin_everything_open_containing_folder">Open parent folder</system:String>
<system:String x:Key="wox_plugin_everything_open_with_editor">Open with {0}</system:String>
<system:String x:Key="wox_plugin_everything_editor_path">Editor Path</system:String>
<system:String x:Key="wox_plugin_everything_copy_path">Copy path</system:String>
<system:String x:Key="wox_plugin_everything_copy">Copy</system:String>
<system:String x:Key="wox_plugin_everything_delete">Delete</system:String>
<system:String x:Key="wox_plugin_everything_canot_delete">Can't delete {0}</system:String>

<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">Search on-disk files using Everything</system:String>
Expand Down
4 changes: 4 additions & 0 deletions Plugins/Wox.Plugin.Everything/Languages/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<system:String x:Key="wox_plugin_everything_open_containing_folder">打开所属文件夹</system:String>
<system:String x:Key="wox_plugin_everything_open_with_editor">使用{0}打开</system:String>
<system:String x:Key="wox_plugin_everything_editor_path">编辑器路径</system:String>
<system:String x:Key="wox_plugin_everything_copy_path">拷贝路径</system:String>
<system:String x:Key="wox_plugin_everything_copy">拷贝</system:String>
<system:String x:Key="wox_plugin_everything_delete">删除</system:String>
<system:String x:Key="wox_plugin_everything_canot_delete">无法删除 {0}</system:String>

<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">利用 Everything 搜索磁盘文件</system:String>
Expand Down
47 changes: 47 additions & 0 deletions Plugins/Wox.Plugin.Everything/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,53 @@ public List<Result> LoadContextMenus(Result selectedResult)
}
}

var icoPath = (record.Type == ResultType.File) ? "Images\\file.png" : "Images\\folder.png";
contextMenus.Add(new Result
{
Title = _context.API.GetTranslation("wox_plugin_everything_copy_path"),
Action = (context) =>
{
Clipboard.SetText(record.FullPath);
return true;
},
IcoPath = icoPath
});

contextMenus.Add(new Result
{
Title = _context.API.GetTranslation("wox_plugin_everything_copy"),
Action = (context) =>
{
Clipboard.SetFileDropList(new System.Collections.Specialized.StringCollection { record.FullPath });
return true;
},
IcoPath = icoPath
});

if (record.Type == ResultType.File || record.Type == ResultType.Folder)
contextMenus.Add(new Result
{
Title = _context.API.GetTranslation("wox_plugin_everything_delete"),
Action = (context) =>
{
try
{
if (record.Type == ResultType.File)
System.IO.File.Delete(record.FullPath);
else
System.IO.Directory.Delete(record.FullPath);
}
catch
{
_context.API.ShowMsg(string.Format(_context.API.GetTranslation("wox_plugin_everything_canot_delete"), record.FullPath), string.Empty, string.Empty);
return false;
}

return true;
},
IcoPath = icoPath
});

return contextMenus;
}

Expand Down
4 changes: 2 additions & 2 deletions Plugins/Wox.Plugin.Program/Programs/UWP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ public class Application : IProgram

private int Score(string query)
{
var score1 = StringMatcher.Score(DisplayName, query);
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
var score3 = StringMatcher.Score(Description, query);
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
var score4 = StringMatcher.ScoreForPinyin(Description, query);
var score = new[] { score1, score2, score3, score4 }.Max();
return score;
Expand Down
61 changes: 32 additions & 29 deletions Plugins/Wox.Plugin.Program/Programs/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public class Win32 : IProgram

private int Score(string query)
{
var score1 = StringMatcher.Score(Name, query);
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
var score2 = StringMatcher.ScoreForPinyin(Name, query);
var score3 = StringMatcher.Score(Description, query);
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
var score4 = StringMatcher.ScoreForPinyin(Description, query);
var score5 = StringMatcher.Score(ExecutableName, query);
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
var score = new[] { score1, score2, score3, score4, score5 }.Max();
return score;
}
Expand Down Expand Up @@ -145,26 +145,35 @@ private static Win32 LnkProgram(string path)
var hwnd = new _RemotableHandle();
link.Resolve(ref hwnd, 0);

const int MAX_PATH = 260;
StringBuilder buffer = new StringBuilder(MAX_PATH);

var data = new _WIN32_FIND_DATAW();
const uint SLGP_SHORTPATH = 1;
link.GetPath(buffer, buffer.Capacity, ref data, SLGP_SHORTPATH);
var target = buffer.ToString();
if (!string.IsNullOrEmpty(target))
const int MAX_DESCRIPTION = 150;
StringBuilder bufferDescription = new StringBuilder(MAX_DESCRIPTION);
String description = String.Empty;
try
{
link.GetDescription(bufferDescription, MAX_DESCRIPTION);
}
catch (COMException e)
{
Log.Error($"|Win32.LnkProgram|cannot get description <{path}>. HResult: <{e.HResult}>. Exception: <{e}>.");
bufferDescription.Clear();
}
description = bufferDescription.ToString();
if (!string.IsNullOrEmpty(description))
{
program.Description = description;
}
else
{
var extension = Extension(target);
if (extension == ExeExtension && File.Exists(target))
const int MAX_PATH = 260;
StringBuilder bufferPath = new StringBuilder(MAX_PATH);
var data = new _WIN32_FIND_DATAW();
const uint SLGP_SHORTPATH = 1;
link.GetPath(bufferPath, bufferPath.Capacity, ref data, SLGP_SHORTPATH);
var target = bufferPath.ToString();
if (!string.IsNullOrEmpty(target))
{
buffer = new StringBuilder(MAX_PATH);
link.GetDescription(buffer, MAX_PATH);
var description = buffer.ToString();
if (!string.IsNullOrEmpty(description))
{
program.Description = description;
}
else
var extension = Extension(target);
if (extension == ExeExtension && File.Exists(target))
{
var info = FileVersionInfo.GetVersionInfo(target);
if (!string.IsNullOrEmpty(info.FileDescription))
Expand All @@ -176,13 +185,7 @@ private static Win32 LnkProgram(string path)
}
return program;
}
catch (COMException e)
{
// C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\MiracastView.lnk always cause exception
Log.Exception($"|Win32.LnkProgram|COMException when parsing shortcut <{path}> with HResult <{e.HResult}>", e);
program.Valid = false;
return program;
}

catch (Exception e)
{
Log.Exception($"|Win32.LnkProgram|Exception when parsing shortcut <{path}>", e);
Expand Down Expand Up @@ -265,7 +268,7 @@ private static ParallelQuery<Win32> UnregisteredPrograms(List<Settings.ProgramSo
var paths = sources.Where(s => Directory.Exists(s.Location))
.SelectMany(s => ProgramPaths(s.Location, suffixes))
.ToArray();
var programs1 = paths.AsParallel().Where(p => Extension(p) == ExeExtension).Select(ExeProgram);
var programs1 = paths.AsParallel().Where(p => Extension(p) == ExeExtension).Select(LnkProgram);
var programs2 = paths.AsParallel().Where(p => Extension(p) == ShortcutExtension).Select(ExeProgram);
var programs3 = from p in paths.AsParallel()
let e = Extension(p)
Expand Down
22 changes: 17 additions & 5 deletions Plugins/Wox.Plugin.Sys/Languages/ja.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<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="wox_plugin_sys_command">コマンド</system:String>
<system:String x:Key="wox_plugin_sys_desc">説明</system:String>

<system:String x:Key="wox_plugin_sys_shutdown_computer_command">シャットダウン</system:String>
<system:String x:Key="wox_plugin_sys_restart_computer_command">再起動</system:String>
<system:String x:Key="wox_plugin_sys_log_off_command">ログオフ</system:String>
<system:String x:Key="wox_plugin_sys_lock_command">ロック</system:String>
<system:String x:Key="wox_plugin_sys_exit_command">終了</system:String>
<system:String x:Key="wox_plugin_sys_restart_command">Woxを再起動</system:String>
<system:String x:Key="wox_plugin_sys_setting_command">設定</system:String>
<system:String x:Key="wox_plugin_sys_sleep_command">スリープ</system:String>
<system:String x:Key="wox_plugin_sys_hibernate_command">休止状態</system:String>
<system:String x:Key="wox_plugin_sys_emptyrecyclebin_command">ゴミ箱を空にする</system:String>

<system:String x:Key="wox_plugin_sys_shutdown_computer">コンピュータをシャットダウンする</system:String>
<system:String x:Key="wox_plugin_sys_restart_computer">コンピュータを再起動する</system:String>
<system:String x:Key="wox_plugin_sys_log_off">ログオフ</system:String>
Expand All @@ -13,9 +21,13 @@
<system:String x:Key="wox_plugin_sys_restart">Woxを再起動する</system:String>
<system:String x:Key="wox_plugin_sys_setting">このアプリの設定</system:String>
<system:String x:Key="wox_plugin_sys_sleep">スリープ</system:String>
<system:String x:Key="wox_plugin_sys_hibernate">コンピュータを休止状態にする</system:String>
<system:String x:Key="wox_plugin_sys_emptyrecyclebin">ゴミ箱を空にする</system:String>

<system:String x:Key="wox_plugin_sys_confirm_shutdown">コンピュータをシャットダウンしますか?</system:String>
<system:String x:Key="wox_plugin_sys_confirm_restart">コンピュータを再起動しますか?</system:String>

<system:String x:Key="wox_plugin_sys_plugin_name">システムコマンド</system:String>
<system:String x:Key="wox_plugin_sys_plugin_description">システム関連のコマンドを提供します。例:シャットダウン、ロック、設定など</system:String>

</ResourceDictionary>
</ResourceDictionary>
6 changes: 3 additions & 3 deletions Plugins/Wox.Plugin.Sys/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -56,8 +56,8 @@ public List<Result> Query(Query query)
var results = new List<Result>();
foreach (var c in commands)
{
var titleScore = StringMatcher.Score(c.Title, query.Search);
var subTitleScore = StringMatcher.Score(c.SubTitle, query.Search);
var titleScore = StringMatcher.FuzzySearch(query.Search, c.Title).ScoreAfterSearchPrecisionFilter();
var subTitleScore = StringMatcher.FuzzySearch(query.Search, c.SubTitle).ScoreAfterSearchPrecisionFilter();
var score = Math.Max(titleScore, subTitleScore);
if (score > 0)
{
Expand Down
4 changes: 4 additions & 0 deletions Plugins/Wox.Plugin.Url/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<system:String x:Key="wox_plugin_url_plugin_name">URL</system:String>
<system:String x:Key="wox_plugin_url_plugin_description">Open the typed URL from Wox</system:String>

<system:String x:Key="wox_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">Choose</system:String>
<system:String x:Key="wox_plugin_url_plugin_apply">Apply</system:String>
<system:String x:Key="wox_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
</ResourceDictionary>
4 changes: 4 additions & 0 deletions Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<system:String x:Key="wox_plugin_url_plugin_name">URL</system:String>
<system:String x:Key="wox_plugin_url_plugin_description">从Wox打开链接</system:String>

<system:String x:Key="wox_plugin_url_plugin_set_tip">请设置你的浏览器路径:</system:String>
<system:String x:Key="wox_plugin_url_plugin_choose">选择</system:String>
<system:String x:Key="wox_plugin_url_plugin_apply">应用</system:String>
<system:String x:Key="wox_plugin_url_plugin_filter">程序文件(*.exe)|*.exe|所有文件|*.*</system:String>
</ResourceDictionary>
33 changes: 31 additions & 2 deletions Plugins/Wox.Plugin.Url/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows.Controls;
using Wox.Infrastructure.Storage;

namespace Wox.Plugin.Url
{
public class Main : IPlugin, IPluginI18n
public class Main : ISettingProvider,IPlugin, IPluginI18n, ISavable
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern = "^" +
Expand Down Expand Up @@ -42,6 +44,19 @@ public class Main : IPlugin, IPluginI18n
"$";
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
private PluginInitContext context;
private readonly Settings _settings;
private readonly PluginJsonStorage<Settings> _storage;

public Main()
{
_storage = new PluginJsonStorage<Settings>();
_settings = _storage.Load();
}

public void Save()
{
_storage.Save();
}

public List<Result> Query(Query query)
{
Expand All @@ -64,7 +79,15 @@ public List<Result> Query(Query query)
}
try
{
Process.Start(raw);
if (_settings.BrowserPath.Length == 0)
{
Process.Start(raw);
}
else
{
Process.Start(_settings.BrowserPath,raw);
}

return true;
}
catch(Exception ex)
Expand All @@ -79,6 +102,12 @@ public List<Result> Query(Query query)
return new List<Result>(0);
}


public Control CreateSettingPanel()
{
return new SettingsControl(context.API,_settings);
}

public bool IsURL(string raw)
{
raw = raw.ToLower();
Expand Down
13 changes: 13 additions & 0 deletions Plugins/Wox.Plugin.Url/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wox.Plugin.Url
{
public class Settings
{
public string BrowserPath { get; set; }
}
}
25 changes: 25 additions & 0 deletions Plugins/Wox.Plugin.Url/SettingsControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<UserControl x:Class="Wox.Plugin.Url.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wox.Plugin.Url"
mc:Ignorable="d" Height="300" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="0*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="0*"/>
</Grid.ColumnDefinitions>
<Label HorizontalAlignment="Left" Margin="99,22,0,0" VerticalAlignment="Top" Height="43" Width="318" FontSize="20" Content="{DynamicResource wox_plugin_url_plugin_set_tip}"/>
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Height="34" Margin="35,90,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="311"/>
<Button x:Name="setButton" HorizontalAlignment="Left" Margin="356,247,0,0" VerticalAlignment="Top" Width="110" Height="33" FontSize="20" Click="OnApplyBTClick" Content="{DynamicResource wox_plugin_url_plugin_apply}"/>
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="369,90,0,0" VerticalAlignment="Top" Width="86" Height="34" Click="OnChooseClick" FontSize="20" Content="{DynamicResource wox_plugin_url_plugin_choose}"/>

</Grid>
</UserControl>
Loading

0 comments on commit 623cea6

Please sign in to comment.