Skip to content

Commit 740b3dc

Browse files
committed
Merge branch 'dev' of https://github.com/Zeroto521/Flow.Launcher into dev
2 parents 42f8bbe + 2e9d364 commit 740b3dc

39 files changed

+698
-696
lines changed

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
<ItemGroup>
5656
<PackageReference Include="FSharp.Core" Version="4.7.1" />
5757
<PackageReference Include="squirrel.windows" Version="1.5.2" />
58-
<PackageReference Include="SharpZipLib" Version="1.2.0" />
5958
</ItemGroup>
6059

6160
<ItemGroup>

Flow.Launcher.Core/Plugin/PluginInstaller.cs

Lines changed: 0 additions & 169 deletions
This file was deleted.

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ public static void InitializePlugins(IPublicAPI api)
133133
}
134134
}
135135

136-
public static void InstallPlugin(string path)
137-
{
138-
PluginInstaller.Install(path);
139-
}
140-
141136
public static List<PluginPair> ValidPluginsForQuery(Query query)
142137
{
143138
if (NonGlobalPlugins.ContainsKey(query.ActionKeyword))

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public void ChangeLanguage(Language language)
8888
{
8989
language = language.NonNull();
9090

91-
Settings.Language = language.LanguageCode;
9291

9392
RemoveOldLanguageFiles();
9493
if (language != AvailableLanguages.English)
9594
{
9695
LoadLanguage(language);
9796
}
9897
UpdatePluginMetadataTranslations();
98+
Settings.Language = language.LanguageCode;
9999

100100
}
101101

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,12 @@ public static async Task<string> Get([NotNull] string url, string encoding = "UT
6666
response = response.NonNull();
6767
var stream = response.GetResponseStream().NonNull();
6868

69-
using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding)))
70-
{
71-
var content = await reader.ReadToEndAsync();
72-
if (response.StatusCode == HttpStatusCode.OK)
73-
{
74-
return content;
75-
}
76-
else
77-
{
78-
throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
79-
}
80-
}
69+
using var reader = new StreamReader(stream, Encoding.GetEncoding(encoding));
70+
var content = await reader.ReadToEndAsync();
71+
if (response.StatusCode != HttpStatusCode.OK)
72+
throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
73+
74+
return content;
8175
}
8276
}
8377
}

Flow.Launcher.Infrastructure/PinyinAlphabet.cs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
using System;
22
using System.Collections.Concurrent;
3-
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;
65
using JetBrains.Annotations;
7-
using Flow.Launcher.Infrastructure.Logger;
8-
using Flow.Launcher.Infrastructure.Storage;
96
using Flow.Launcher.Infrastructure.UserSettings;
107
using ToolGood.Words.Pinyin;
11-
using System.Threading.Tasks;
128

139
namespace Flow.Launcher.Infrastructure
1410
{
@@ -27,7 +23,6 @@ public void Initialize([NotNull] Settings settings)
2723
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
2824
}
2925

30-
3126
public string Translate(string content)
3227
{
3328
if (_settings.ShouldUsePinyin)
@@ -36,10 +31,40 @@ public string Translate(string content)
3631
{
3732
if (WordsHelper.HasChinese(content))
3833
{
39-
var result = WordsHelper.GetPinyin(content, ";");
40-
result = GetFirstPinyinChar(result) + result.Replace(";", "");
41-
_pinyinCache[content] = result;
42-
return result;
34+
var resultList = WordsHelper.GetPinyinList(content);
35+
36+
StringBuilder resultBuilder = new StringBuilder();
37+
38+
for (int i = 0; i < resultList.Length; i++)
39+
{
40+
if (content[i] >= 0x3400 && content[i] <= 0x9FD5)
41+
resultBuilder.Append(resultList[i].First());
42+
}
43+
44+
resultBuilder.Append(' ');
45+
46+
bool pre = false;
47+
48+
for (int i = 0; i < resultList.Length; i++)
49+
{
50+
if (content[i] >= 0x3400 && content[i] <= 0x9FD5)
51+
{
52+
resultBuilder.Append(' ');
53+
resultBuilder.Append(resultList[i]);
54+
pre = true;
55+
}
56+
else
57+
{
58+
if (pre)
59+
{
60+
pre = false;
61+
resultBuilder.Append(' ');
62+
}
63+
resultBuilder.Append(resultList[i]);
64+
}
65+
}
66+
67+
return _pinyinCache[content] = resultBuilder.ToString();
4368
}
4469
else
4570
{
@@ -56,10 +81,5 @@ public string Translate(string content)
5681
return content;
5782
}
5883
}
59-
60-
private string GetFirstPinyinChar(string content)
61-
{
62-
return string.Concat(content.Split(';').Select(x => x.First()));
63-
}
6484
}
6585
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
99
{
1010
public class Settings : BaseModel
1111
{
12+
private string language = "en";
13+
1214
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
1315
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
1416
public bool ShowOpenResultHotkey { get; set; } = true;
15-
public string Language { get; set; } = "en";
17+
public string Language
18+
{
19+
get => language; set {
20+
language = value;
21+
OnPropertyChanged();
22+
}
23+
}
1624
public string Theme { get; set; } = Constant.DefaultTheme;
1725
public bool UseDropShadowEffect { get; set; } = false;
1826
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;

Flow.Launcher.Plugin/IPublicAPI.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ public interface IPublicAPI
6363
/// </summary>
6464
void OpenSettingDialog();
6565

66-
/// <summary>
67-
/// Install Flow Launcher plugin
68-
/// </summary>
69-
/// <param name="path">Plugin path (ends with .flowlauncher)</param>
70-
void InstallPlugin(string path);
71-
7266
/// <summary>
7367
/// Get translation of current language
7468
/// You need to implement IPluginI18n if you want to support multiple languages for your plugin

0 commit comments

Comments
 (0)