33using System . Diagnostics ;
44using System . Globalization ;
55using System . IO ;
6+ using System . Linq ;
67using System . Runtime . InteropServices ;
78using System . Windows ;
89using Flow . Launcher . Infrastructure ;
@@ -73,19 +74,15 @@ public List<Result> Query(Query query)
7374 var results = new List < Result > ( ) ;
7475 foreach ( var c in commands )
7576 {
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 ;
7780
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 ;
8282 if ( score > 0 )
8383 {
8484 c . Score = score ;
8585
86- if ( score == titleMatch . Score )
87- c . TitleHighlightData = titleMatch . MatchData ;
88-
8986 results . Add ( c ) ;
9087 }
9188 }
@@ -115,33 +112,6 @@ private string GetDescription(string key)
115112 return _context . API . GetTranslation ( translationKey ) ;
116113 }
117114
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-
145115 public void Init ( PluginInitContext context )
146116 {
147117 _context = context ;
@@ -216,7 +186,6 @@ private List<Result> Commands()
216186 new Result
217187 {
218188 Title = "Shutdown" ,
219- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_shutdown_computer" ) ,
220189 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7e8 " ) ,
221190 IcoPath = "Images\\ shutdown.png" ,
222191 Action = c =>
@@ -238,7 +207,6 @@ private List<Result> Commands()
238207 new Result
239208 {
240209 Title = "Restart" ,
241- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_computer" ) ,
242210 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe777 " ) ,
243211 IcoPath = "Images\\ restart.png" ,
244212 Action = c =>
@@ -260,7 +228,6 @@ private List<Result> Commands()
260228 new Result
261229 {
262230 Title = "Restart With Advanced Boot Options" ,
263- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_advanced" ) ,
264231 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xecc5 " ) ,
265232 IcoPath = "Images\\ restart_advanced.png" ,
266233 Action = c =>
@@ -282,7 +249,6 @@ private List<Result> Commands()
282249 new Result
283250 {
284251 Title = "Log Off/Sign Out" ,
285- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_log_off" ) ,
286252 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe77b " ) ,
287253 IcoPath = "Images\\ logoff.png" ,
288254 Action = c =>
@@ -301,7 +267,6 @@ private List<Result> Commands()
301267 new Result
302268 {
303269 Title = "Lock" ,
304- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_lock" ) ,
305270 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe72e " ) ,
306271 IcoPath = "Images\\ lock.png" ,
307272 Action = c =>
@@ -313,7 +278,6 @@ private List<Result> Commands()
313278 new Result
314279 {
315280 Title = "Sleep" ,
316- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_sleep" ) ,
317281 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xec46 " ) ,
318282 IcoPath = "Images\\ sleep.png" ,
319283 Action = c =>
@@ -325,7 +289,6 @@ private List<Result> Commands()
325289 new Result
326290 {
327291 Title = "Hibernate" ,
328- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_hibernate" ) ,
329292 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe945 " ) ,
330293 IcoPath = "Images\\ hibernate.png" ,
331294 Action = c =>
@@ -337,7 +300,6 @@ private List<Result> Commands()
337300 new Result
338301 {
339302 Title = "Index Option" ,
340- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_indexoption" ) ,
341303 IcoPath = "Images\\ indexoption.png" ,
342304 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe773 " ) ,
343305 Action = c =>
@@ -349,7 +311,6 @@ private List<Result> Commands()
349311 new Result
350312 {
351313 Title = "Empty Recycle Bin" ,
352- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_emptyrecyclebin" ) ,
353314 IcoPath = "Images\\ recyclebin.png" ,
354315 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d " ) ,
355316 Action = c =>
@@ -374,7 +335,6 @@ private List<Result> Commands()
374335 new Result
375336 {
376337 Title = "Open Recycle Bin" ,
377- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_openrecyclebin" ) ,
378338 IcoPath = "Images\\ openrecyclebin.png" ,
379339 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d " ) ,
380340 CopyText = recycleBinFolder ,
@@ -387,7 +347,6 @@ private List<Result> Commands()
387347 new Result
388348 {
389349 Title = "Exit" ,
390- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_exit" ) ,
391350 IcoPath = "Images\\ app.png" ,
392351 Action = c =>
393352 {
@@ -398,7 +357,6 @@ private List<Result> Commands()
398357 new Result
399358 {
400359 Title = "Save Settings" ,
401- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_save_all_settings" ) ,
402360 IcoPath = "Images\\ app.png" ,
403361 Action = c =>
404362 {
@@ -411,7 +369,6 @@ private List<Result> Commands()
411369 new Result
412370 {
413371 Title = "Restart Flow Launcher" ,
414- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_restart" ) ,
415372 IcoPath = "Images\\ app.png" ,
416373 Action = c =>
417374 {
@@ -422,7 +379,6 @@ private List<Result> Commands()
422379 new Result
423380 {
424381 Title = "Settings" ,
425- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_setting" ) ,
426382 IcoPath = "Images\\ app.png" ,
427383 Action = c =>
428384 {
@@ -433,7 +389,6 @@ private List<Result> Commands()
433389 new Result
434390 {
435391 Title = "Reload Plugin Data" ,
436- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_reload_plugin_data" ) ,
437392 IcoPath = "Images\\ app.png" ,
438393 Action = c =>
439394 {
@@ -453,7 +408,6 @@ private List<Result> Commands()
453408 new Result
454409 {
455410 Title = "Check For Update" ,
456- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_check_for_update" ) ,
457411 IcoPath = "Images\\ checkupdate.png" ,
458412 Action = c =>
459413 {
@@ -465,7 +419,6 @@ private List<Result> Commands()
465419 new Result
466420 {
467421 Title = "Open Log Location" ,
468- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_log_location" ) ,
469422 IcoPath = "Images\\ app.png" ,
470423 CopyText = logPath ,
471424 AutoCompleteText = logPath ,
@@ -478,7 +431,6 @@ private List<Result> Commands()
478431 new Result
479432 {
480433 Title = "Flow Launcher Tips" ,
481- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_docs_tips" ) ,
482434 IcoPath = "Images\\ app.png" ,
483435 CopyText = Constant . Documentation ,
484436 AutoCompleteText = Constant . Documentation ,
@@ -491,7 +443,6 @@ private List<Result> Commands()
491443 new Result
492444 {
493445 Title = "Flow Launcher UserData Folder" ,
494- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_open_userdata_location" ) ,
495446 IcoPath = "Images\\ app.png" ,
496447 CopyText = userDataPath ,
497448 AutoCompleteText = userDataPath ,
@@ -504,7 +455,6 @@ private List<Result> Commands()
504455 new Result
505456 {
506457 Title = "Toggle Game Mode" ,
507- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_toggle_game_mode" ) ,
508458 IcoPath = "Images\\ app.png" ,
509459 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc " ) ,
510460 Action = c =>
@@ -516,7 +466,6 @@ private List<Result> Commands()
516466 new Result
517467 {
518468 Title = "Set Flow Launcher Theme" ,
519- SubTitle = _context . API . GetTranslation ( "flowlauncher_plugin_sys_theme_selector" ) ,
520469 IcoPath = "Images\\ app.png" ,
521470 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc " ) ,
522471 Action = c =>
0 commit comments