3
3
using System . Diagnostics ;
4
4
using System . Globalization ;
5
5
using System . IO ;
6
+ using System . Linq ;
6
7
using System . Runtime . InteropServices ;
7
8
using System . Windows ;
8
9
using Flow . Launcher . Infrastructure ;
@@ -73,19 +74,15 @@ public List<Result> Query(Query query)
73
74
var results = new List < Result > ( ) ;
74
75
foreach ( var c in commands )
75
76
{
76
- c . Title = GetDynamicTitle ( query , c ) ;
77
+ var command = _settings . Commands . First ( x => x . Key == c . Title ) ;
78
+ c . Title = command . Name ;
79
+ c . SubTitle = command . Description ;
77
80
78
- var titleMatch = StringMatcher . FuzzySearch ( query . Search , c . Title ) ;
79
- var subTitleMatch = StringMatcher . FuzzySearch ( query . Search , c . SubTitle ) ;
80
-
81
- var score = Math . Max ( titleMatch . Score , subTitleMatch . Score ) ;
81
+ var score = _context . API . FuzzySearch ( query . Search , command . Keyword ) . Score ;
82
82
if ( score > 0 )
83
83
{
84
84
c . Score = score ;
85
85
86
- if ( score == titleMatch . Score )
87
- c . TitleHighlightData = titleMatch . MatchData ;
88
-
89
86
results . Add ( c ) ;
90
87
}
91
88
}
@@ -115,33 +112,6 @@ private string GetDescription(string key)
115
112
return _context . API . GetTranslation ( translationKey ) ;
116
113
}
117
114
118
- [ Obsolete ]
119
- private string GetDynamicTitle ( Query query , Result result )
120
- {
121
- if ( ! KeywordTitleMappings . TryGetValue ( result . Title , out var translationKey ) )
122
- {
123
- Log . Error ( "Flow.Launcher.Plugin.Sys.Main" , $ "Dynamic Title not found for: { result . Title } ") ;
124
- return "Title Not Found" ;
125
- }
126
-
127
- var translatedTitle = _context . API . GetTranslation ( translationKey ) ;
128
-
129
- if ( query == null )
130
- {
131
- return translatedTitle ;
132
- }
133
-
134
- if ( result . Title == translatedTitle )
135
- {
136
- return result . Title ;
137
- }
138
-
139
- var englishTitleMatch = StringMatcher . FuzzySearch ( query . Search , result . Title ) ;
140
- var translatedTitleMatch = StringMatcher . FuzzySearch ( query . Search , translatedTitle ) ;
141
-
142
- return englishTitleMatch . Score >= translatedTitleMatch . Score ? result . Title : translatedTitle ;
143
- }
144
-
145
115
public void Init ( PluginInitContext context )
146
116
{
147
117
_context = context ;
@@ -216,7 +186,6 @@ private List<Result> Commands()
216
186
new Result
217
187
{
218
188
Title = "Shutdown" ,
219
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_shutdown_computer" ) ,
220
189
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7e8 " ) ,
221
190
IcoPath = "Images\\ shutdown.png" ,
222
191
Action = c =>
@@ -238,7 +207,6 @@ private List<Result> Commands()
238
207
new Result
239
208
{
240
209
Title = "Restart" ,
241
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_computer" ) ,
242
210
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe777 " ) ,
243
211
IcoPath = "Images\\ restart.png" ,
244
212
Action = c =>
@@ -260,7 +228,6 @@ private List<Result> Commands()
260
228
new Result
261
229
{
262
230
Title = "Restart With Advanced Boot Options" ,
263
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_advanced" ) ,
264
231
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xecc5 " ) ,
265
232
IcoPath = "Images\\ restart_advanced.png" ,
266
233
Action = c =>
@@ -282,7 +249,6 @@ private List<Result> Commands()
282
249
new Result
283
250
{
284
251
Title = "Log Off/Sign Out" ,
285
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_log_off" ) ,
286
252
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe77b " ) ,
287
253
IcoPath = "Images\\ logoff.png" ,
288
254
Action = c =>
@@ -301,7 +267,6 @@ private List<Result> Commands()
301
267
new Result
302
268
{
303
269
Title = "Lock" ,
304
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_lock" ) ,
305
270
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe72e " ) ,
306
271
IcoPath = "Images\\ lock.png" ,
307
272
Action = c =>
@@ -313,7 +278,6 @@ private List<Result> Commands()
313
278
new Result
314
279
{
315
280
Title = "Sleep" ,
316
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_sleep" ) ,
317
281
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xec46 " ) ,
318
282
IcoPath = "Images\\ sleep.png" ,
319
283
Action = c =>
@@ -325,7 +289,6 @@ private List<Result> Commands()
325
289
new Result
326
290
{
327
291
Title = "Hibernate" ,
328
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_hibernate" ) ,
329
292
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe945 " ) ,
330
293
IcoPath = "Images\\ hibernate.png" ,
331
294
Action = c =>
@@ -337,7 +300,6 @@ private List<Result> Commands()
337
300
new Result
338
301
{
339
302
Title = "Index Option" ,
340
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_indexoption" ) ,
341
303
IcoPath = "Images\\ indexoption.png" ,
342
304
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe773 " ) ,
343
305
Action = c =>
@@ -349,7 +311,6 @@ private List<Result> Commands()
349
311
new Result
350
312
{
351
313
Title = "Empty Recycle Bin" ,
352
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_emptyrecyclebin" ) ,
353
314
IcoPath = "Images\\ recyclebin.png" ,
354
315
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d " ) ,
355
316
Action = c =>
@@ -374,7 +335,6 @@ private List<Result> Commands()
374
335
new Result
375
336
{
376
337
Title = "Open Recycle Bin" ,
377
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_openrecyclebin" ) ,
378
338
IcoPath = "Images\\ openrecyclebin.png" ,
379
339
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d " ) ,
380
340
CopyText = recycleBinFolder ,
@@ -387,7 +347,6 @@ private List<Result> Commands()
387
347
new Result
388
348
{
389
349
Title = "Exit" ,
390
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_exit" ) ,
391
350
IcoPath = "Images\\ app.png" ,
392
351
Action = c =>
393
352
{
@@ -398,7 +357,6 @@ private List<Result> Commands()
398
357
new Result
399
358
{
400
359
Title = "Save Settings" ,
401
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_save_all_settings" ) ,
402
360
IcoPath = "Images\\ app.png" ,
403
361
Action = c =>
404
362
{
@@ -411,7 +369,6 @@ private List<Result> Commands()
411
369
new Result
412
370
{
413
371
Title = "Restart Flow Launcher" ,
414
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart" ) ,
415
372
IcoPath = "Images\\ app.png" ,
416
373
Action = c =>
417
374
{
@@ -422,7 +379,6 @@ private List<Result> Commands()
422
379
new Result
423
380
{
424
381
Title = "Settings" ,
425
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_setting" ) ,
426
382
IcoPath = "Images\\ app.png" ,
427
383
Action = c =>
428
384
{
@@ -433,7 +389,6 @@ private List<Result> Commands()
433
389
new Result
434
390
{
435
391
Title = "Reload Plugin Data" ,
436
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_reload_plugin_data" ) ,
437
392
IcoPath = "Images\\ app.png" ,
438
393
Action = c =>
439
394
{
@@ -453,7 +408,6 @@ private List<Result> Commands()
453
408
new Result
454
409
{
455
410
Title = "Check For Update" ,
456
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_check_for_update" ) ,
457
411
IcoPath = "Images\\ checkupdate.png" ,
458
412
Action = c =>
459
413
{
@@ -465,7 +419,6 @@ private List<Result> Commands()
465
419
new Result
466
420
{
467
421
Title = "Open Log Location" ,
468
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_log_location" ) ,
469
422
IcoPath = "Images\\ app.png" ,
470
423
CopyText = logPath ,
471
424
AutoCompleteText = logPath ,
@@ -478,7 +431,6 @@ private List<Result> Commands()
478
431
new Result
479
432
{
480
433
Title = "Flow Launcher Tips" ,
481
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_docs_tips" ) ,
482
434
IcoPath = "Images\\ app.png" ,
483
435
CopyText = Constant . Documentation ,
484
436
AutoCompleteText = Constant . Documentation ,
@@ -491,7 +443,6 @@ private List<Result> Commands()
491
443
new Result
492
444
{
493
445
Title = "Flow Launcher UserData Folder" ,
494
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_userdata_location" ) ,
495
446
IcoPath = "Images\\ app.png" ,
496
447
CopyText = userDataPath ,
497
448
AutoCompleteText = userDataPath ,
@@ -504,7 +455,6 @@ private List<Result> Commands()
504
455
new Result
505
456
{
506
457
Title = "Toggle Game Mode" ,
507
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_toggle_game_mode" ) ,
508
458
IcoPath = "Images\\ app.png" ,
509
459
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc " ) ,
510
460
Action = c =>
@@ -516,7 +466,6 @@ private List<Result> Commands()
516
466
new Result
517
467
{
518
468
Title = "Set Flow Launcher Theme" ,
519
- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_theme_selector" ) ,
520
469
IcoPath = "Images\\ app.png" ,
521
470
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc " ) ,
522
471
Action = c =>
0 commit comments