diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index ed74cbb2d..4d73e0730 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -13,7 +13,6 @@ using Flow.Launcher.Plugin.SharedModels; namespace Flow.Launcher.SettingPages.ViewModels; -// TODO: _updater, _portable public partial class SettingsPaneGeneralViewModel { private static Internationalization Translator => InternationalizationManager.Instance; @@ -22,9 +21,12 @@ public partial class SettingsPaneGeneralViewModel private readonly Updater _updater; private readonly IPortable _portable; - public SettingsPaneGeneralViewModel(Settings settings) + public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortable portable) { Settings = settings; + _updater = updater; + _portable = portable; + UpdateLastQueryModeDisplay(); } public class SearchWindowScreen : DropdownDataGeneric { } @@ -181,6 +183,25 @@ public partial class SettingsPaneGeneralViewModel }; } + private void UpdateApp() + { + _ = _updater.UpdateAppAsync(App.API, false); + } + + public bool AutoUpdates + { + get => Settings.AutoUpdates; + set + { + Settings.AutoUpdates = value; + + if (value) + { + UpdateApp(); + } + } + } + [RelayCommand] private void SelectPython() { diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs index 42fbdc5f0..f95015b2e 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs @@ -13,9 +13,9 @@ public partial class SettingsPaneGeneral { if (!IsInitialized) { - if (e.ExtraData is not Settings settings) - throw new ArgumentException("Settings is not passed to General page"); - _viewModel = new SettingsPaneGeneralViewModel(settings); + if (e.ExtraData is not SettingWindow.PaneData { Settings: { } settings, Updater: {} updater, Portable: {} portable }) + throw new ArgumentException("Settings, Updater and Portable are required for SettingsPaneGeneral."); + _viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable); DataContext = _viewModel; InitializeComponent(); } diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 08d175d76..cd85014f2 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -17,6 +17,8 @@ using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Navigation; +using Flow.Launcher.Core; +using Flow.Launcher.Core.Configuration; using NHotkey; using Button = System.Windows.Controls.Button; using Control = System.Windows.Controls.Control; @@ -531,8 +533,9 @@ namespace Flow.Launcher nameof(About) => typeof(SettingsPaneAbout), _ => typeof(SettingsPaneGeneral) }; - ContentFrame.Navigate(pageType, settings); + ContentFrame.Navigate(pageType, new PaneData(settings, viewModel.Updater, viewModel.Portable)); } } + public record PaneData(Settings Settings, Updater Updater, IPortable Portable); } } diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 67d605a11..aadd88287 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -34,7 +34,10 @@ namespace Flow.Launcher.ViewModel private readonly IPortable _portable; private readonly FlowLauncherJsonStorage _storage; - /* For Navigation View */ + public Updater Updater => _updater; + public IPortable Portable => _portable; + + /* For Navigation View */ private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromBottom @@ -152,7 +155,7 @@ namespace Flow.Launcher.ViewModel } } - + public string TestProxy() { var proxyServer = Settings.Proxy.Server;