Skip to content

Commit 43ac9b4

Browse files
authored
Release 1.9.5 (#1386)
* Merge pull request #1061 from Flow-Launcher/remove_winget_ci * Merge pull request #991 from Flow-Launcher/context_menu_plugin_site * Merge pull request #1080 from gissehel/caret-position-fix * Caret position fix : Include PR #1074 * Merge pull request #1283 from nachmore/dev * Merge pull request #1296 from nachmore/bug_1284 * Merge pull request #1294 from Flow-Launcher/pluginInfoMultipleActionKeyword * Merge pull request #1299 from nachmore/bug_1269 * Plugin Exception Draft (#1147) * Merge pull request #1355 from onesounds/LimitWidth * Merge pull request #1088 from Flow-Launcher/add_spanish_latin_america * Merge pull request #1387 from Flow-Launcher/fix_exception_duplicate_url_opening * Merge pull request #1390 from Flow-Launcher/issue_1371 * Merge pull request #1391 from Flow-Launcher/issue_1366
1 parent 6dedb4f commit 43ac9b4

File tree

53 files changed

+1499
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1499
-120
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Flow.Launcher.Plugin;
2+
using System;
3+
4+
namespace Flow.Launcher.Core.ExternalPlugins
5+
{
6+
public class FlowPluginException : Exception
7+
{
8+
public PluginMetadata Metadata { get; set; }
9+
10+
public FlowPluginException(PluginMetadata metadata, Exception e) : base(e.Message, e)
11+
{
12+
Metadata = metadata;
13+
}
14+
15+
public override string ToString()
16+
{
17+
return $@"{Metadata.Name} Exception:
18+
Websites: {Metadata.Website}
19+
Author: {Metadata.Author}
20+
Version: {Metadata.Version}
21+
{base.ToString()}";
22+
}
23+
}
24+
}

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Flow.Launcher.Core.ExternalPlugins;
2+
using System;
23
using System.Collections.Concurrent;
34
using System.Collections.Generic;
45
using System.IO;
@@ -165,30 +166,28 @@ public static async Task InitializePlugins(IPublicAPI api)
165166

166167
public static ICollection<PluginPair> ValidPluginsForQuery(Query query)
167168
{
168-
if (NonGlobalPlugins.ContainsKey(query.ActionKeyword))
169-
{
170-
var plugin = NonGlobalPlugins[query.ActionKeyword];
171-
return new List<PluginPair>
172-
{
173-
plugin
174-
};
175-
}
176-
else
177-
{
169+
if (query is null)
170+
return Array.Empty<PluginPair>();
171+
172+
if (!NonGlobalPlugins.ContainsKey(query.ActionKeyword))
178173
return GlobalPlugins;
179-
}
174+
175+
176+
var plugin = NonGlobalPlugins[query.ActionKeyword];
177+
return new List<PluginPair>
178+
{
179+
plugin
180+
};
180181
}
181182

182183
public static async Task<List<Result>> QueryForPluginAsync(PluginPair pair, Query query, CancellationToken token)
183184
{
184185
var results = new List<Result>();
186+
var metadata = pair.Metadata;
187+
185188
try
186189
{
187-
var metadata = pair.Metadata;
188-
189-
long milliseconds = -1L;
190-
191-
milliseconds = await Stopwatch.DebugAsync($"|PluginManager.QueryForPlugin|Cost for {metadata.Name}",
190+
var milliseconds = await Stopwatch.DebugAsync($"|PluginManager.QueryForPlugin|Cost for {metadata.Name}",
192191
async () => results = await pair.Plugin.QueryAsync(query, token).ConfigureAwait(false));
193192

194193
token.ThrowIfCancellationRequested();
@@ -206,7 +205,10 @@ public static async Task<List<Result>> QueryForPluginAsync(PluginPair pair, Quer
206205
// null will be fine since the results will only be added into queue if the token hasn't been cancelled
207206
return null;
208207
}
209-
208+
catch (Exception e)
209+
{
210+
throw new FlowPluginException(metadata, e);
211+
}
210212
return results;
211213
}
212214

Flow.Launcher.Core/Resource/AvailableLanguages.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ internal static class AvailableLanguages
1919
public static Language Serbian = new Language("sr", "Srpski");
2020
public static Language Portuguese_Portugal = new Language("pt-pt", "Português");
2121
public static Language Portuguese_Brazil = new Language("pt-br", "Português (Brasil)");
22+
public static Language Spanish = new Language("es", "Spanish");
23+
public static Language Spanish_LatinAmerica = new Language("es-419", "Spanish (Latin America)");
2224
public static Language Italian = new Language("it", "Italiano");
2325
public static Language Norwegian_Bokmal = new Language("nb-NO", "Norsk Bokmål");
2426
public static Language Slovak = new Language("sk", "Slovenský");
@@ -43,6 +45,8 @@ public static List<Language> GetAvailableLanguages()
4345
Serbian,
4446
Portuguese_Portugal,
4547
Portuguese_Brazil,
48+
Spanish,
49+
Spanish_LatinAmerica,
4650
Italian,
4751
Norwegian_Bokmal,
4852
Slovak,

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ public bool ChangeTheme(string theme)
8585

8686
Settings.Theme = theme;
8787

88+
// reload all resources even if the theme itself hasn't changed in order to pickup changes
89+
// to things like fonts
90+
UpdateResourceDictionary(GetResourceDictionary());
91+
8892
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
8993
if (_oldTheme != theme || theme == defaultTheme)
9094
{
91-
UpdateResourceDictionary(GetResourceDictionary());
9295
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
9396
}
9497

Flow.Launcher/App.xaml.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Diagnostics;
33
using System.Text;
44
using System.Threading.Tasks;
@@ -104,14 +104,22 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
104104
});
105105
}
106106

107-
108107
private void AutoStartup()
109108
{
110-
if (_settings.StartFlowLauncherOnSystemStartup)
109+
// we try to enable auto-startup on first launch, or reenable if it was removed
110+
// but the user still has the setting set
111+
if (_settings.StartFlowLauncherOnSystemStartup && !Helper.AutoStartup.IsEnabled)
111112
{
112-
if (!SettingWindow.StartupSet())
113+
try
114+
{
115+
Helper.AutoStartup.Enable();
116+
}
117+
catch (Exception e)
113118
{
114-
SettingWindow.SetStartup();
119+
// but if it fails (permissions, etc) then don't keep retrying
120+
// this also gives the user a visual indication in the Settings widget
121+
_settings.StartFlowLauncherOnSystemStartup = false;
122+
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message);
115123
}
116124
}
117125
}

Flow.Launcher/Helper/AutoStartup.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Flow.Launcher.Infrastructure;
7+
using Flow.Launcher.Infrastructure.Logger;
8+
using Microsoft.Win32;
9+
10+
namespace Flow.Launcher.Helper
11+
{
12+
public class AutoStartup
13+
{
14+
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
15+
16+
public static bool IsEnabled
17+
{
18+
get
19+
{
20+
try
21+
{
22+
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
23+
var path = key?.GetValue(Constant.FlowLauncher) as string;
24+
return path == Constant.ExecutablePath;
25+
}
26+
catch (Exception e)
27+
{
28+
Log.Error("AutoStartup", $"Ignoring non-critical registry error (querying if enabled): {e}");
29+
}
30+
31+
return false;
32+
}
33+
}
34+
35+
public static void Disable()
36+
{
37+
try
38+
{
39+
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
40+
key?.DeleteValue(Constant.FlowLauncher, false);
41+
}
42+
catch (Exception e)
43+
{
44+
Log.Error("AutoStartup", $"Failed to disable auto-startup: {e}");
45+
throw;
46+
}
47+
}
48+
49+
internal static void Enable()
50+
{
51+
try
52+
{
53+
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
54+
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
55+
}
56+
catch (Exception e)
57+
{
58+
Log.Error("AutoStartup", $"Failed to enable auto-startup: {e}");
59+
throw;
60+
}
61+
}
62+
}
63+
}

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<system:String x:Key="portableMode">Portable Mode</system:String>
2828
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
2929
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher on system startup</system:String>
30+
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
3031
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
3132
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
3233
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>

0 commit comments

Comments
 (0)