Skip to content

Commit c5d24c4

Browse files
authored
Merge branch 'dev' into SpecialCtrl
2 parents cb9262b + 86598b5 commit c5d24c4

File tree

39 files changed

+348
-103
lines changed

39 files changed

+348
-103
lines changed

Flow.Launcher.Infrastructure/Storage/JsonStorage.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Flow.Launcher.Infrastructure.Storage
1111
/// </summary>
1212
public class JsonStrorage<T> where T : new()
1313
{
14-
private readonly JsonSerializerOptions _serializerSettings;
1514
protected T _data;
1615
// need a new directory name
1716
public const string DirectoryName = "Settings";
@@ -20,16 +19,6 @@ namespace Flow.Launcher.Infrastructure.Storage
2019
public string DirectoryPath { get; set; }
2120

2221

23-
internal JsonStrorage()
24-
{
25-
// use property initialization instead of DefaultValueAttribute
26-
// easier and flexible for default value of object
27-
_serializerSettings = new JsonSerializerOptions
28-
{
29-
IgnoreNullValues = false
30-
};
31-
}
32-
3322
public T Load()
3423
{
3524
if (File.Exists(FilePath))
@@ -55,7 +44,7 @@ private void Deserialize(string searlized)
5544
{
5645
try
5746
{
58-
_data = JsonSerializer.Deserialize<T>(searlized, _serializerSettings);
47+
_data = JsonSerializer.Deserialize<T>(searlized);
5948
}
6049
catch (JsonException e)
6150
{

Flow.Launcher.Plugin/IPublicAPI.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ public interface IPublicAPI
4747
/// </summary>
4848
void CheckForNewUpdate();
4949

50+
/// <summary>
51+
/// Show the error message using Flow's standard error icon.
52+
/// </summary>
53+
/// <param name="title">Message title</param>
54+
/// <param name="subTitle">Optional message subtitle</param>
55+
void ShowMsgError(string title, string subTitle = "");
56+
5057
/// <summary>
5158
/// Show message box
5259
/// </summary>

Flow.Launcher/Languages/sk.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<system:String x:Key="hideNotifyIcon">Schovať ikonu z oblasti oznámení</system:String>
3737
<system:String x:Key="querySearchPrecision">Presnosť vyhľadávania</system:String>
3838
<system:String x:Key="ShouldUsePinyin">Použiť Pinyin</system:String>
39+
<system:String x:Key="ShouldUsePinyinToolTip">Umožňuje vyhľadávanie pomocou Pinyin. Pinyin je štandardný systém romanizovaného pravopisu pre transliteráciu čínštiny</system:String>
3940

4041
<!--Setting Plugin-->
4142
<system:String x:Key="plugin">Plugin</system:String>
@@ -107,7 +108,7 @@
107108
alebo prejdite na https://github.com/Flow-Launcher/Flow.Launcher/releases pre manuálne stiahnutie aktualizácie.
108109
</system:String>
109110
<system:String x:Key="releaseNotes">Poznámky k vydaniu</system:String>
110-
<system:String x:Key="documentation">Tipy na používanie:</system:String>
111+
<system:String x:Key="documentation">Tipy na používanie:</system:String>
111112

112113
<!--Priority Setting Dialog-->
113114
<system:String x:Key="priority_tips">Vyššie číslo znamená, že výsledok bude vyššie. Skúste nastaviť napr. 5. Ak chcete, aby boli výsledky nižšie ako ktorékoľvek iné doplnky, zadajte záporné číslo</system:String>
@@ -122,7 +123,7 @@
122123
<system:String x:Key="newActionKeywordsCannotBeEmpty">Nová skratka pre akciu nemôže byť prázdna</system:String>
123124
<system:String x:Key="newActionKeywordsHasBeenAssigned">Nová skratka pre akciu bola priradená pre iný plugin, prosím, zvoľte inú skratku</system:String>
124125
<system:String x:Key="success">Úspešné</system:String>
125-
<system:String x:Key="completedSuccessfully">Úspešne dokončené</system:String>
126+
<system:String x:Key="completedSuccessfully">Úspešne dokončené</system:String>
126127
<system:String x:Key="actionkeyword_tips">Použite * ak nechcete určiť skratku pre akciu</system:String>
127128

128129
<!--Custom Query Hotkey Dialog-->
@@ -160,7 +161,7 @@
160161
<system:String x:Key="update_flowlauncher_update_found">Bola nájdená aktualizácia</system:String>
161162
<system:String x:Key="update_flowlauncher_updating">Aktualizuje sa…</system:String>
162163
<system:String x:Key="update_flowlauncher_fail_moving_portable_user_profile_data">Flow Launcher nedokázal presunúť používateľské údaje do aktualizovanej verzie.
163-
Prosím, presuňte profilový priečinok data z {0} do {1}</system:String>
164+
Prosím, presuňte profilový priečinok data z {0} do {1}</system:String>
164165
<system:String x:Key="update_flowlauncher_new_update">Nová aktualizácia</system:String>
165166
<system:String x:Key="update_flowlauncher_update_new_version_available">Je dostupná nová verzia Flow Launchera {0}</system:String>
166167
<system:String x:Key="update_flowlauncher_update_error">Počas inštalácie aktualizácií došlo k chybe</system:String>

Flow.Launcher/Languages/zh-cn.xaml

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!--主窗体-->
55
<system:String x:Key="registerHotkeyFailed">注册热键:{0} 失败</system:String>
66
<system:String x:Key="couldnotStartCmd">启动命令 {0} 失败</system:String>
7-
<system:String x:Key="invalidFlowLauncherPluginFileFormat">不是合法的Flow Launcher插件格式</system:String>
7+
<system:String x:Key="invalidFlowLauncherPluginFileFormat">Flow Launcher插件格式错误</system:String>
88
<system:String x:Key="setAsTopMostInThisQuery">在当前查询中置顶</system:String>
99
<system:String x:Key="cancelTopMostInThisQuery">取消置顶</system:String>
1010
<system:String x:Key="executeQuery">执行查询:{0}</system:String>
@@ -17,28 +17,37 @@
1717
<!--设置,通用-->
1818
<system:String x:Key="flowlauncher_settings">Flow Launcher设置</system:String>
1919
<system:String x:Key="general">通用</system:String>
20-
<system:String x:Key="startFlowLauncherOnSystemStartup">开机启动</system:String>
20+
<system:String x:Key="portableMode">便携模式</system:String>
21+
<system:String x:Key="startFlowLauncherOnSystemStartup">开机自动启动</system:String>
2122
<system:String x:Key="hideFlowLauncherWhenLoseFocus">失去焦点时自动隐藏Flow Launcher</system:String>
2223
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
2324
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>
2425
<system:String x:Key="language">语言</system:String>
2526
<system:String x:Key="lastQueryMode">上次搜索关键字模式</system:String>
2627
<system:String x:Key="LastQueryPreserved">保留上次搜索关键字</system:String>
27-
<system:String x:Key="LastQuerySelected">全选上次搜索关键字</system:String>
28+
<system:String x:Key="LastQuerySelected">选择上次搜索关键字</system:String>
2829
<system:String x:Key="LastQueryEmpty">清空上次搜索关键字</system:String>
2930
<system:String x:Key="maxShowResults">最大结果显示个数</system:String>
3031
<system:String x:Key="ignoreHotkeysOnFullscreen">全屏模式下忽略热键</system:String>
3132
<system:String x:Key="pythonDirectory">Python 路径</system:String>
3233
<system:String x:Key="autoUpdates">自动更新</system:String>
33-
<system:String x:Key="selectPythonDirectory">Select</system:String>
34+
<system:String x:Key="selectPythonDirectory">选择</system:String>
3435
<system:String x:Key="hideOnStartup">启动时不显示主窗口</system:String>
3536
<system:String x:Key="hideNotifyIcon">隐藏任务栏图标</system:String>
37+
<system:String x:Key="querySearchPrecision">查询搜索精度</system:String>
38+
<system:String x:Key="ShouldUsePinyin">启动拼音搜索</system:String>
39+
<system:String x:Key="ShouldUsePinyinToolTip">允许使用拼音进行搜索。</system:String>
3640

3741
<!--设置,插件-->
3842
<system:String x:Key="plugin">插件</system:String>
3943
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
44+
<system:String x:Key="enable">启用</system:String>
4045
<system:String x:Key="disable">禁用</system:String>
4146
<system:String x:Key="actionKeywords">触发关键字</system:String>
47+
<system:String x:Key="currentActionKeywords">当前操作关键字:</system:String>
48+
<system:String x:Key="newActionKeyword">新动作关键字:</system:String>
49+
<system:String x:Key="currentPriority">当前优先级:</system:String>
50+
<system:String x:Key="newPriority">新优先级:</system:String>
4251
<system:String x:Key="pluginDirectory">插件目录</system:String>
4352
<system:String x:Key="author">作者</system:String>
4453
<system:String x:Key="plugin_init_time">加载耗时</system:String>
@@ -47,6 +56,7 @@
4756
<!--设置,主题-->
4857
<system:String x:Key="theme">主题</system:String>
4958
<system:String x:Key="browserMoreThemes">浏览更多主题</system:String>
59+
<system:String x:Key="hiThere">在这里输入</system:String>
5060
<system:String x:Key="queryBoxFont">查询框字体</system:String>
5161
<system:String x:Key="resultItemFont">结果项字体</system:String>
5262
<system:String x:Key="windowMode">窗口模式</system:String>
@@ -65,6 +75,9 @@
6575
<system:String x:Key="add">增加</system:String>
6676
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
6777
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
78+
<system:String x:Key="queryWindowShadowEffect">查询窗口阴影效果</system:String>
79+
<system:String x:Key="shadowEffectCPUUsage">阴影效果将占用大量的GPU资源。</system:String>
80+
<system:String x:Key="shadowEffectPerformance">如果您的计算机性能有限,则不建议使用。</system:String>
6881

6982
<!--设置,代理-->
7083
<system:String x:Key="proxy">HTTP 代理</system:String>
@@ -88,8 +101,18 @@
88101
<system:String x:Key="version">版本</system:String>
89102
<system:String x:Key="about_activate_times">你已经激活了Flow Launcher {0} 次</system:String>
90103
<system:String x:Key="checkUpdates">检查更新</system:String>
91-
<system:String x:Key="newVersionTips">发现新版本 {0} , 请重启 flowlauncher。</system:String>
104+
<system:String x:Key="newVersionTips">发现新版本 {0} , 请重启 Flow Launcher。</system:String>
105+
<system:String x:Key="checkUpdatesFailed">下载更新失败,请检查您与 api.github.com 的连接状态或检查代理设置。</system:String>
106+
<system:String x:Key="downloadUpdatesFailed">
107+
下载更新失败,请检查您与 github-cloud.s3.amazonaws.com 的连接状态或检查代理设置,
108+
或访问 https://github.com/Flow-Launcher/Flow.Launcher/releases 手动下载更新。
109+
</system:String>
92110
<system:String x:Key="releaseNotes">更新说明:</system:String>
111+
<system:String x:Key="documentation">使用技巧:</system:String>
112+
113+
<!--优先级设置对话框-->
114+
<system:String x:Key="priority_tips">数字越大,结果排名越高。如果你想要结果比任何其他插件的低,请使用负数</system:String>
115+
<system:String x:Key="invalidPriority">请提供有效的整数作为优先级设置值!</system:String>
93116

94117
<!--Action Keyword 设置对话框-->
95118
<system:String x:Key="oldActionKeywords">旧触发关键字</system:String>
@@ -98,11 +121,13 @@
98121
<system:String x:Key="done">确定</system:String>
99122
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
100123
<system:String x:Key="newActionKeywordsCannotBeEmpty">新触发关键字不能为空</system:String>
101-
<system:String x:Key="newActionKeywordsHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
124+
<system:String x:Key="newActionKeywordsHasBeenAssigned">新触发关键字已经被指派给其他插件了,请换一个关键字</system:String>
102125
<system:String x:Key="success">成功</system:String>
126+
<system:String x:Key="completedSuccessfully">成功完成</system:String>
103127
<system:String x:Key="actionkeyword_tips">如果你不想设置触发关键字,可以使用*代替</system:String>
104128

105129
<!--Custom Query Hotkey 对话框-->
130+
<system:String x:Key="customeQueryHotkeyTitle">自定义插件热键</system:String>
106131
<system:String x:Key="preview">预览</system:String>
107132
<system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String>
108133
<system:String x:Key="invalidPluginHotkey">插件热键不合法</system:String>
@@ -127,12 +152,24 @@
127152
<system:String x:Key="reportWindow_report_failed">发送失败</system:String>
128153
<system:String x:Key="reportWindow_flowlauncher_got_an_error">Flow Launcher出错啦</system:String>
129154

155+
<!--General Notice-->
156+
<system:String x:Key="pleaseWait">请稍等...</system:String>
157+
130158
<!--更新-->
159+
<system:String x:Key="update_flowlauncher_update_check">检查新的更新</system:String>
160+
<system:String x:Key="update_flowlauncher_already_on_latest">您已经拥有最新的Flow Launcher版本</system:String>
161+
<system:String x:Key="update_flowlauncher_update_found">检查到更新</system:String>
162+
<system:String x:Key="update_flowlauncher_updating">更新中...</system:String>
163+
<system:String x:Key="update_flowlauncher_fail_moving_portable_user_profile_data">Flow Launcher无法将您的用户配置文件数据移动到新的更新版本中。
164+
请手动将您的用户配置文件数据文件夹从 {0} 到 {1}</system:String>
165+
<system:String x:Key="update_flowlauncher_new_update">新的更新</system:String>
131166
<system:String x:Key="update_flowlauncher_update_new_version_available">发现Flow Launcher新版本 V{0}</system:String>
132-
<system:String x:Key="update_flowlauncher_update_error">更新Flow Launcher出错</system:String>
167+
<system:String x:Key="update_flowlauncher_update_error">尝试安装软件更新时发生错误</system:String>
133168
<system:String x:Key="update_flowlauncher_update">更新</system:String>
134169
<system:String x:Key="update_flowlauncher_update_cancel">取消</system:String>
135-
<system:String x:Key="update_flowlauncher_update_restart_flowlauncher_tip">此更新需要重启Flow Launcher</system:String>
170+
<system:String x:Key="update_flowlauncher_fail">更新错误</system:String>
171+
<system:String x:Key="update_flowlauncher_check_connection">检查网络是否可以连接至github-cloud.s3.amazonaws.com.</system:String>
172+
<system:String x:Key="update_flowlauncher_update_restart_flowlauncher_tip">此次更新需要重启Flow Launcher</system:String>
136173
<system:String x:Key="update_flowlauncher_update_upadte_files">下列文件会被更新</system:String>
137174
<system:String x:Key="update_flowlauncher_update_files">更新文件</system:String>
138175
<system:String x:Key="update_flowlauncher_update_upadte_description">更新日志</system:String>

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public void SaveAppAllSettings()
8484

8585
public Task ReloadAllPluginData() => PluginManager.ReloadData();
8686

87+
public void ShowMsgError(string title, string subTitle = "") => ShowMsg(title, subTitle, Constant.ErrorIcon, true);
88+
8789
public void ShowMsg(string title, string subTitle = "", string iconPath = "") => ShowMsg(title, subTitle, iconPath, true);
8890

8991
public void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true)

Flow.Launcher/Storage/UserSelectedRecord.cs

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Flow.Launcher.Infrastructure;
66
using Flow.Launcher.Infrastructure.Storage;
77
using Flow.Launcher.Plugin;
8+
using Flow.Launcher.ViewModel;
89

910
namespace Flow.Launcher.Storage
1011
{
@@ -14,72 +15,90 @@ public class UserSelectedRecord
1415
private const int HASH_INITIAL = 23;
1516

1617
[JsonInclude]
17-
public Dictionary<int, int> records { get; private set; }
18+
public Dictionary<int, int> recordsWithQuery { get; private set; }
19+
20+
[JsonInclude, JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
21+
public Dictionary<string, int> records { get; private set; }
22+
1823

1924
public UserSelectedRecord()
2025
{
21-
records = new Dictionary<int, int>();
26+
recordsWithQuery = new Dictionary<int, int>();
2227
}
2328

24-
private static int GenerateCustomHashCode(Query query, Result result)
29+
private static int GenerateStaticHashCode(string s, int start = HASH_INITIAL)
2530
{
26-
int hashcode = HASH_INITIAL;
27-
2831
unchecked
2932
{
3033
// skip the empty space
3134
// https://stackoverflow.com/a/5155015 31 prime and is 2^5 - 1 which allows fast
3235
// optimization without information lost when int overflow
33-
34-
for (int i = 0; i < query.ActionKeyword.Length; i++)
35-
{
36-
char item = query.ActionKeyword[i];
37-
hashcode = hashcode * HASH_MULTIPLIER + item;
38-
}
39-
40-
for (int i = 0; i < query.Search.Length; i++)
41-
{
42-
char item = query.Search[i];
43-
hashcode = hashcode * HASH_MULTIPLIER + item;
44-
}
4536

46-
for (int i = 0; i < result.Title.Length; i++)
37+
for (int i = 0; i < s.Length; i++)
4738
{
48-
char item = result.Title[i];
49-
hashcode = hashcode * HASH_MULTIPLIER + item;
39+
start = start * HASH_MULTIPLIER + s[i];
5040
}
5141

52-
for (int i = 0; i < result.SubTitle.Length; i++)
42+
return start;
43+
}
44+
}
45+
46+
private static int GenerateResultHashCode(Result result)
47+
{
48+
int hashcode = GenerateStaticHashCode(result.Title);
49+
return GenerateStaticHashCode(result.SubTitle, hashcode);
50+
}
51+
52+
private static int GenerateQueryAndResultHashCode(Query query, Result result)
53+
{
54+
int hashcode = GenerateStaticHashCode(query.ActionKeyword);
55+
hashcode = GenerateStaticHashCode(query.Search, hashcode);
56+
hashcode = GenerateStaticHashCode(result.Title, hashcode);
57+
hashcode = GenerateStaticHashCode(result.SubTitle, hashcode);
58+
59+
return hashcode;
60+
}
61+
62+
private void TransformOldRecords()
63+
{
64+
if (records != null)
65+
{
66+
var localRecords = records;
67+
records = null;
68+
69+
foreach (var pair in localRecords)
5370
{
54-
char item = result.SubTitle[i];
55-
hashcode = hashcode * HASH_MULTIPLIER + item;
71+
recordsWithQuery.TryAdd(GenerateStaticHashCode(pair.Key), pair.Value);
5672
}
57-
return hashcode;
58-
5973
}
6074
}
6175

6276
public void Add(Result result)
6377
{
64-
var key = GenerateCustomHashCode(result.OriginQuery, result);
65-
if (records.ContainsKey(key))
66-
{
67-
records[key]++;
68-
}
69-
else
70-
{
71-
records.Add(key, 1);
78+
TransformOldRecords();
7279

73-
}
80+
var keyWithQuery = GenerateQueryAndResultHashCode(result.OriginQuery, result);
81+
82+
if (!recordsWithQuery.TryAdd(keyWithQuery, 1))
83+
recordsWithQuery[keyWithQuery]++;
84+
85+
var keyWithoutQuery = GenerateResultHashCode(result);
86+
87+
if (!recordsWithQuery.TryAdd(keyWithoutQuery, 1))
88+
recordsWithQuery[keyWithoutQuery]++;
7489
}
7590

7691
public int GetSelectedCount(Result result)
7792
{
78-
if (records.TryGetValue(GenerateCustomHashCode(result.OriginQuery, result), out int value))
79-
{
80-
return value;
81-
}
82-
return 0;
93+
var selectedCount = 0;
94+
95+
recordsWithQuery.TryGetValue(GenerateQueryAndResultHashCode(result.OriginQuery, result), out int value);
96+
selectedCount += value * 5;
97+
98+
recordsWithQuery.TryGetValue(GenerateResultHashCode(result), out value);
99+
selectedCount += value;
100+
101+
return selectedCount;
83102
}
84103
}
85104
}

0 commit comments

Comments
 (0)