Skip to content

Commit 366a351

Browse files
authored
Merge branch 'dev' into improve-calculator
2 parents 9d447ca + 3184f8d commit 366a351

File tree

22 files changed

+336
-139
lines changed

22 files changed

+336
-139
lines changed

Plugins/Wox.Plugin.PluginIndicator/Main.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public List<Result> Query(Query query)
1313
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
1414
where keyword.StartsWith(query.Terms[0])
1515
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
16-
let disabled = PluginManager.Settings.Plugins[metadata.ID].Disabled
17-
where !disabled
16+
where !metadata.Disabled
1817
select new Result
1918
{
2019
Title = keyword,
22.7 KB
Loading

Plugins/Wox.Plugin.Sys/Main.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ private List<Result> Commands()
234234
context.API.GetTranslation("wox_plugin_sys_dlgtext_all_applicableplugins_reloaded"));
235235
return true;
236236
}
237+
},
238+
new Result
239+
{
240+
Title = "Check For Update",
241+
SubTitle = "Check for new Wox update",
242+
IcoPath = "Images\\checkupdate.png",
243+
Action = c =>
244+
{
245+
Application.Current.MainWindow.Hide();
246+
context.API.CheckForNewUpdate();
247+
context.API.ShowMsg("Please wait...",
248+
"Checking for new update");
249+
return true;
250+
}
237251
}
238252
});
239253
return results;

Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,15 @@
7171
</ProjectReference>
7272
</ItemGroup>
7373
<ItemGroup>
74+
<None Include="Images\checkupdate.png">
75+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
76+
</None>
7477
<Content Include="Images\recyclebin.png">
7578
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7679
</Content>
80+
<None Include="Images\shutdown.png">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</None>
7783
<Content Include="Images\sleep.png">
7884
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7985
</Content>

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ Features
1919
- Search for everything—applications, **uwp**, folders, files and more.
2020
- Use *pinyin* to search for programs / 支持用 **拼音** 搜索程序
2121
- wyy / wangyiyun → 网易云音乐
22-
- Keyword plugin search
23-
- search google with `g search_term`
22+
- Keyword plugin search `g search_term`
23+
- Search youtube, google, twitter and many more
2424
- Build custom themes at http://www.wox.one/theme/builder
2525
- Install plugins from http://www.wox.one/plugin
2626

27+
**New from this fork:**
28+
- Portable mode
29+
- Drastically improved search experience
30+
- Search all subfolders and files
31+
- Option to always run CMD or Powershell as administrator
32+
- Run CMD, Powershell and programs as a different user
33+
- Manage what programs should be loaded
34+
- Highlighting of how results are matched during query search
35+
- Open web search result as a tab or a new window
36+
- Automatic update
37+
- Reload/update plugin data
2738

2839
Installation
2940
------------
@@ -42,8 +53,8 @@ Versions marked as **pre-release** are unstable pre-release versions.
4253

4354
- Requirements:
4455
- .net >= 4.5.2
45-
- [everything](https://www.voidtools.com/): `.exe` installer + use x64 if your windows is x64 + everything service is running
46-
- [python3](https://www.python.org/downloads/): `.exe` installer + add it to `%PATH%` or set it in WoX settings
56+
- If you want to integrate with [everything](https://www.voidtools.com/): `.exe` installer + use x64 if your windows is x64 + everything service is running. Supported version is 1.3.4.686
57+
- If you use python plugins, install [python3](https://www.python.org/downloads/): `.exe` installer + add it to `%PATH%` or set it in WoX settings
4758

4859
Usage
4960
-----

Wox.Core/Plugin/PluginManager.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static void InitializePlugins(IPublicAPI api)
120120
catch (Exception e)
121121
{
122122
Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e);
123-
pair.Metadata.Disabled = true; // TODO: not sure this really disable it later on
123+
pair.Metadata.Disabled = true;
124124
failedPlugins.Enqueue(pair);
125125
}
126126
});
@@ -149,35 +149,6 @@ public static void InstallPlugin(string path)
149149
PluginInstaller.Install(path);
150150
}
151151

152-
public static Query QueryInit(string text) //todo is that possible to move it into type Query?
153-
{
154-
// replace multiple white spaces with one white space
155-
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries);
156-
var rawQuery = string.Join(Query.TermSeperater, terms);
157-
var actionKeyword = string.Empty;
158-
var search = rawQuery;
159-
var actionParameters = terms.ToList();
160-
if (terms.Length == 0) return null;
161-
if (NonGlobalPlugins.ContainsKey(terms[0]) &&
162-
!Settings.Plugins[NonGlobalPlugins[terms[0]].Metadata.ID].Disabled)
163-
{
164-
actionKeyword = terms[0];
165-
actionParameters = terms.Skip(1).ToList();
166-
search = string.Join(Query.TermSeperater, actionParameters.ToArray());
167-
}
168-
var query = new Query
169-
{
170-
Terms = terms,
171-
RawQuery = rawQuery,
172-
ActionKeyword = actionKeyword,
173-
Search = search,
174-
// Obsolete value initialisation
175-
ActionName = actionKeyword,
176-
ActionParameters = actionParameters
177-
};
178-
return query;
179-
}
180-
181152
public static List<PluginPair> ValidPluginsForQuery(Query query)
182153
{
183154
if (NonGlobalPlugins.ContainsKey(query.ActionKeyword))

Wox.Core/Plugin/QueryBuilder.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Wox.Plugin;
5+
6+
namespace Wox.Core.Plugin
7+
{
8+
public static class QueryBuilder
9+
{
10+
public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalPlugins)
11+
{
12+
// replace multiple white spaces with one white space
13+
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries);
14+
if (terms.Length == 0)
15+
{ // nothing was typed
16+
return null;
17+
}
18+
19+
var rawQuery = string.Join(Query.TermSeperater, terms);
20+
string actionKeyword, search;
21+
string possibleActionKeyword = terms[0];
22+
List<string> actionParameters;
23+
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled)
24+
{ // use non global plugin for query
25+
actionKeyword = possibleActionKeyword;
26+
actionParameters = terms.Skip(1).ToList();
27+
search = actionParameters.Count > 0 ? rawQuery.Substring(actionKeyword.Length + 1) : string.Empty;
28+
}
29+
else
30+
{ // non action keyword
31+
actionKeyword = string.Empty;
32+
actionParameters = terms.ToList();
33+
search = rawQuery;
34+
}
35+
36+
var query = new Query
37+
{
38+
Terms = terms,
39+
RawQuery = rawQuery,
40+
ActionKeyword = actionKeyword,
41+
Search = search,
42+
// Obsolete value initialisation
43+
ActionName = actionKeyword,
44+
ActionParameters = actionParameters
45+
};
46+
47+
return query;
48+
}
49+
}
50+
}

Wox.Core/Updater.cs

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Net;
44
using System.Net.Http;
@@ -10,9 +10,11 @@
1010
using Squirrel;
1111
using Newtonsoft.Json;
1212
using Wox.Core.Resource;
13+
using Wox.Plugin.SharedCommands;
1314
using Wox.Infrastructure;
1415
using Wox.Infrastructure.Http;
1516
using Wox.Infrastructure.Logger;
17+
using System.IO;
1618

1719
namespace Wox.Core
1820
{
@@ -25,14 +27,14 @@ public Updater(string gitHubRepository)
2527
GitHubRepository = gitHubRepository;
2628
}
2729

28-
public async Task UpdateApp()
30+
public async Task UpdateApp(bool silentIfLatestVersion = true)
2931
{
30-
UpdateManager m;
31-
UpdateInfo u;
32+
UpdateManager updateManager;
33+
UpdateInfo newUpdateInfo;
3234

3335
try
3436
{
35-
m = await GitHubUpdateManager(GitHubRepository);
37+
updateManager = await GitHubUpdateManager(GitHubRepository);
3638
}
3739
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
3840
{
@@ -43,42 +45,61 @@ public async Task UpdateApp()
4345
try
4446
{
4547
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
46-
u = await m.CheckForUpdate().NonNull();
48+
newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
4749
}
4850
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
4951
{
5052
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to api.github.com.", e);
51-
m.Dispose();
53+
updateManager.Dispose();
5254
return;
5355
}
5456

55-
var fr = u.FutureReleaseEntry;
56-
var cr = u.CurrentlyInstalledVersion;
57-
Log.Info($"|Updater.UpdateApp|Future Release <{fr.Formatted()}>");
58-
if (fr.Version > cr.Version)
57+
var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
58+
var currentVersion = Version.Parse(Constant.Version);
59+
60+
Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");
61+
62+
if (newReleaseVersion <= currentVersion)
5963
{
60-
try
61-
{
62-
await m.DownloadReleases(u.ReleasesToApply);
63-
}
64-
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
65-
{
66-
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
67-
m.Dispose();
68-
return;
69-
}
70-
71-
await m.ApplyReleases(u);
72-
await m.CreateUninstallerRegistryEntry();
73-
74-
var newVersionTips = this.NewVersinoTips(fr.Version.ToString());
75-
76-
MessageBox.Show(newVersionTips);
77-
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
64+
if (!silentIfLatestVersion)
65+
MessageBox.Show("You already have the latest Wox version");
66+
updateManager.Dispose();
67+
return;
7868
}
7969

70+
try
71+
{
72+
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
73+
}
74+
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
75+
{
76+
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
77+
updateManager.Dispose();
78+
return;
79+
}
80+
81+
await updateManager.ApplyReleases(newUpdateInfo);
82+
83+
if (Constant.IsPortableMode)
84+
{
85+
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{Constant.PortableFolderName}";
86+
FilesFolders.Copy(Constant.PortableDataPath, targetDestination);
87+
if (!FilesFolders.VerifyBothFolderFilesEqual(Constant.PortableDataPath, targetDestination))
88+
MessageBox.Show(string.Format("Wox was not able to move your user profile data to the new update version. Please manually" +
89+
"move your profile data folder from {0} to {1}", Constant.PortableDataPath, targetDestination));
90+
}
91+
else
92+
{
93+
await updateManager.CreateUninstallerRegistryEntry();
94+
}
95+
96+
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
97+
98+
MessageBox.Show(newVersionTips);
99+
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
100+
80101
// always dispose UpdateManager
81-
m.Dispose();
102+
updateManager.Dispose();
82103
}
83104

84105
[UsedImplicitly]

Wox.Core/Wox.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="Plugin\PluginsLoader.cs" />
5656
<Compile Include="Resource\LocalizationConverter.cs" />
5757
<Compile Include="Resource\LocalizedDescriptionAttribute.cs" />
58+
<Compile Include="Plugin\QueryBuilder.cs" />
5859
<Compile Include="Updater.cs" />
5960
<Compile Include="Resource\AvailableLanguages.cs" />
6061
<Compile Include="Resource\Internationalization.cs" />

Wox.Infrastructure/UserSettings/PluginSettings.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
2828
{
2929
ID = metadata.ID,
3030
Name = metadata.Name,
31-
ActionKeywords = metadata.ActionKeywords,
31+
ActionKeywords = metadata.ActionKeywords,
3232
Disabled = metadata.Disabled
3333
};
3434
}
@@ -39,7 +39,11 @@ public class Plugin
3939
{
4040
public string ID { get; set; }
4141
public string Name { get; set; }
42-
public List<string> ActionKeywords { get; set; }
42+
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
43+
44+
/// <summary>
45+
/// Used only to save the state of the plugin in settings
46+
/// </summary>
4347
public bool Disabled { get; set; }
4448
}
4549
}

0 commit comments

Comments
 (0)