diff --git a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs index cf75e4aa3..e937779a1 100644 --- a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs +++ b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs @@ -93,4 +93,4 @@ namespace Flow.Launcher.Core.Plugin public Dictionary SettingsChange { get; set; } } -} \ No newline at end of file +} diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index e0c6fe941..205abcd34 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -85,10 +85,13 @@ namespace Flow.Launcher.Core.Resource Settings.Theme = theme; + // reload all resources even if the theme itself hasn't changed in order to pickup changes + // to things like fonts + UpdateResourceDictionary(GetResourceDictionary()); + //always allow re-loading default theme, in case of failure of switching to a new theme from default theme if (_oldTheme != theme || theme == defaultTheme) { - UpdateResourceDictionary(GetResourceDictionary()); _oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath); } diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 4ebff16a9..8c970eddd 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Text; using System.Threading.Tasks; @@ -104,14 +104,22 @@ namespace Flow.Launcher }); } - private void AutoStartup() { - if (_settings.StartFlowLauncherOnSystemStartup) + // we try to enable auto-startup on first launch, or reenable if it was removed + // but the user still has the setting set + if (_settings.StartFlowLauncherOnSystemStartup && !Helper.AutoStartup.IsEnabled) { - if (!SettingWindow.StartupSet()) + try { - SettingWindow.SetStartup(); + Helper.AutoStartup.Enable(); + } + catch (Exception e) + { + // but if it fails (permissions, etc) then don't keep retrying + // this also gives the user a visual indication in the Settings widget + _settings.StartFlowLauncherOnSystemStartup = false; + Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message); } } } diff --git a/Flow.Launcher/Helper/AutoStartup.cs b/Flow.Launcher/Helper/AutoStartup.cs new file mode 100644 index 000000000..956324020 --- /dev/null +++ b/Flow.Launcher/Helper/AutoStartup.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Flow.Launcher.Infrastructure; +using Flow.Launcher.Infrastructure.Logger; +using Microsoft.Win32; + +namespace Flow.Launcher.Helper +{ + public class AutoStartup + { + private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; + + public static bool IsEnabled + { + get + { + try + { + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); + var path = key?.GetValue(Constant.FlowLauncher) as string; + return path == Constant.ExecutablePath; + } + catch (Exception e) + { + Log.Error("AutoStartup", $"Ignoring non-critical registry error (querying if enabled): {e}"); + } + + return false; + } + } + + public static void Disable() + { + try + { + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); + key?.DeleteValue(Constant.FlowLauncher, false); + } + catch (Exception e) + { + Log.Error("AutoStartup", $"Failed to disable auto-startup: {e}"); + throw; + } + } + + internal static void Enable() + { + try + { + using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true); + key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath); + } + catch (Exception e) + { + Log.Error("AutoStartup", $"Failed to enable auto-startup: {e}"); + throw; + } + } + } +} diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 6ec3bb4ef..bdf745052 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -30,6 +30,7 @@ Portable Mode Store all settings and user data in one folder (Useful when used with removable drives or cloud services). Start Flow Launcher on system startup + Error setting launch on startup Hide Flow Launcher when focus is lost Do not show new version notifications Remember last launch location diff --git a/Flow.Launcher/Notification.cs b/Flow.Launcher/Notification.cs index 3f5565eeb..57c1e88f2 100644 --- a/Flow.Launcher/Notification.cs +++ b/Flow.Launcher/Notification.cs @@ -18,7 +18,7 @@ namespace Flow.Launcher } [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "")] - public static void Show(string title, string subTitle, string iconPath) + public static void Show(string title, string subTitle, string iconPath = null) { // Handle notification for win7/8/early win10 if (legacy) @@ -45,4 +45,4 @@ namespace Flow.Launcher msg.Show(title, subTitle, iconPath); } } -} \ No newline at end of file +} diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 7201f75b2..7af435639 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -285,4 +285,4 @@ namespace Flow.Launcher #endregion } -} \ No newline at end of file +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 652977686..06c9549e2 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -598,10 +598,8 @@ + IsChecked="{Binding StartFlowLauncherOnSystemStartup}" + Style="{DynamicResource SideControlCheckBox}" /> @@ -917,6 +915,7 @@ Padding="0,0,0,0" Background="{DynamicResource Color01B}"> + SnapsToDevicePixels="True"> @@ -1118,8 +1116,8 @@ Margin="0" Padding="1" VerticalAlignment="Stretch" - Content="{Binding SettingControl}" - SizeChanged="ItemSizeChanged"/> + Content="{Binding SettingControl}" + SizeChanged="ItemSizeChanged" /> @@ -1129,8 +1127,7 @@ VerticalAlignment="Center" BorderThickness="0,1,0,0" CornerRadius="0" - Style="{DynamicResource SettingGroupBox}" - Visibility="{Binding ActionKeywordsVisibility}"> + Style="{DynamicResource SettingGroupBox}"> Settings.StartFlowLauncherOnSystemStartup; + set + { + Settings.StartFlowLauncherOnSystemStartup = value; + + try + { + if (value) + AutoStartup.Enable(); + else + AutoStartup.Disable(); + } + catch (Exception e) + { + Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message); + } } } diff --git a/README.md b/README.md index 35e438864..7b8d15830 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,13 @@ Dedicated to making your workflow flow more seamless. Search everything from app

- Getting StartedFeaturesPlugins • - Hotkeys • - Questions/Suggestions • - Development • + Getting Started • + Features • + Plugins • + Hotkeys • + Sponsors • + Questions/Suggestions • + DevelopmentDocs

@@ -262,10 +265,28 @@ And you can download +## Sponsors + +

+ + + +

+ +

+ + :sparkles:Why I Chose to Support Flow-Launcher:sparkles: + +

+ + + ## ❔ Questions/Suggestions Yes please, let us know in the [Q&A](https://github.com/Flow-Launcher/Flow.Launcher/discussions/categories/q-a) section. **Join our community on [Discord](https://discord.gg/AvgAQgh)!** + + ## Development ### Contributing