mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Introduce viewmodel for settingwindow
This commit is contained in:
@@ -38,7 +38,6 @@ namespace Wox.ViewModel
|
||||
private string _queryTextBeforeLoadContextMenu;
|
||||
private string _queryText;
|
||||
|
||||
private readonly JsonStrorage<Settings> _settingsStorage;
|
||||
private readonly JsonStrorage<QueryHistory> _queryHistoryStorage;
|
||||
private readonly JsonStrorage<UserSelectedRecord> _userSelectedRecordStorage;
|
||||
private readonly JsonStrorage<TopMostRecord> _topMostRecordStorage;
|
||||
@@ -55,14 +54,13 @@ namespace Wox.ViewModel
|
||||
|
||||
#region Constructor
|
||||
|
||||
public MainViewModel(Settings settings, JsonStrorage<Settings> storage)
|
||||
public MainViewModel(Settings settings)
|
||||
{
|
||||
_saved = false;
|
||||
_queryTextBeforeLoadContextMenu = "";
|
||||
_queryText = "";
|
||||
_lastQuery = new Query();
|
||||
|
||||
_settingsStorage = storage;
|
||||
_settings = settings;
|
||||
|
||||
// happlebao todo temp fix for instance code logic
|
||||
@@ -659,7 +657,6 @@ namespace Wox.ViewModel
|
||||
{
|
||||
if (!_saved)
|
||||
{
|
||||
_settingsStorage.Save();
|
||||
_queryHistoryStorage.Save();
|
||||
_userSelectedRecordStorage.Save();
|
||||
_topMostRecordStorage.Save();
|
||||
|
||||
29
Wox/ViewModel/SettingWindowViewModel.cs
Normal file
29
Wox/ViewModel/SettingWindowViewModel.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Wox.ViewModel
|
||||
{
|
||||
public class SettingWindowViewModel
|
||||
{
|
||||
private readonly JsonStrorage<Settings> _storage;
|
||||
public Settings Settings { get; set; }
|
||||
public List<Language> Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
|
||||
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
||||
public SettingWindowViewModel()
|
||||
{
|
||||
_storage = new JsonStrorage<Settings>();
|
||||
Settings = _storage.Load();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_storage.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user