Fully functional General pane in the settings window

This commit is contained in:
Yusyuriv 2024-04-29 13:06:17 +06:00
parent 2285040857
commit 3c54114bc9
No known key found for this signature in database
GPG key ID: A91C52E6F73148E0
4 changed files with 35 additions and 8 deletions

View file

@ -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<SearchWindowScreens> { }
@ -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()
{

View file

@ -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();
}

View file

@ -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);
}
}

View file

@ -34,7 +34,10 @@ namespace Flow.Launcher.ViewModel
private readonly IPortable _portable;
private readonly FlowLauncherJsonStorage<Settings> _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;