2025-01-12 11:45:36 +00:00
|
|
|
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
|
|
|
|
|
using Flow.Launcher.Core;
|
2020-04-21 09:12:17 +00:00
|
|
|
|
using Flow.Launcher.Core.Configuration;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
|
|
|
|
using Flow.Launcher.Plugin;
|
2016-05-21 21:44:27 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
namespace Flow.Launcher.ViewModel;
|
2022-11-18 16:47:04 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
public class SettingWindowViewModel : BaseModel
|
|
|
|
|
|
{
|
2025-01-12 12:04:44 +00:00
|
|
|
|
public Updater Updater { get; private set; }
|
2022-09-27 06:44:00 +00:00
|
|
|
|
|
2025-01-12 12:04:44 +00:00
|
|
|
|
public IPortable Portable { get; private set; }
|
2023-01-01 15:22:16 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
public Settings Settings { get; }
|
2023-01-01 15:22:16 +00:00
|
|
|
|
|
2025-01-12 11:45:36 +00:00
|
|
|
|
public SettingWindowViewModel()
|
2024-05-20 03:05:22 +00:00
|
|
|
|
{
|
2025-01-12 11:45:36 +00:00
|
|
|
|
Settings = Ioc.Default.GetRequiredService<Settings>();
|
2025-01-12 12:04:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
// We don not initialize Updater and Portable in the constructor because we want to avoid
|
|
|
|
|
|
// recrusive dependency injection
|
2025-01-12 11:45:36 +00:00
|
|
|
|
Updater = Ioc.Default.GetRequiredService<Updater>();
|
|
|
|
|
|
Portable = Ioc.Default.GetRequiredService<Portable>();
|
2024-05-20 03:05:22 +00:00
|
|
|
|
}
|
2023-01-01 15:22:16 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
public async void UpdateApp()
|
|
|
|
|
|
{
|
|
|
|
|
|
await Updater.UpdateAppAsync(App.API, false);
|
|
|
|
|
|
}
|
2023-01-01 15:22:16 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save Flow settings. Plugins settings are not included.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
2025-01-12 10:44:52 +00:00
|
|
|
|
Settings.Save();
|
2024-05-20 03:05:22 +00:00
|
|
|
|
}
|
2022-09-27 06:44:00 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
public double SettingWindowWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowWidth;
|
|
|
|
|
|
set => Settings.SettingWindowWidth = value;
|
|
|
|
|
|
}
|
2022-09-27 06:44:00 +00:00
|
|
|
|
|
2024-05-20 03:05:22 +00:00
|
|
|
|
public double SettingWindowHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowHeight;
|
|
|
|
|
|
set => Settings.SettingWindowHeight = value;
|
|
|
|
|
|
}
|
2024-04-12 16:10:25 +00:00
|
|
|
|
|
2024-05-29 09:16:35 +00:00
|
|
|
|
public double? SettingWindowTop
|
2024-05-20 03:05:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowTop;
|
|
|
|
|
|
set => Settings.SettingWindowTop = value;
|
|
|
|
|
|
}
|
2022-11-19 22:16:11 +00:00
|
|
|
|
|
2024-05-29 09:16:35 +00:00
|
|
|
|
public double? SettingWindowLeft
|
2024-05-20 03:05:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowLeft;
|
|
|
|
|
|
set => Settings.SettingWindowLeft = value;
|
2016-05-21 21:44:27 +00:00
|
|
|
|
}
|
2016-11-20 20:01:47 +00:00
|
|
|
|
}
|