2020-07-18 14:12:11 +00:00
|
|
|
|
using Flow.Launcher.Core.Plugin;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.Storage;
|
2020-06-08 08:41:59 +00:00
|
|
|
|
using Flow.Launcher.Plugin.Explorer.Search;
|
2021-01-26 09:48:06 +00:00
|
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
2020-06-08 08:41:59 +00:00
|
|
|
|
using System.Diagnostics;
|
2021-01-02 14:01:15 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SettingsViewModel
|
|
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
|
private readonly PluginJsonStorage<Settings> storage;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
|
internal Settings Settings { get; set; }
|
2020-05-11 13:15:15 +00:00
|
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
|
internal PluginInitContext Context { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public SettingsViewModel(PluginInitContext context)
|
2020-05-11 13:15:15 +00:00
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
|
Context = context;
|
|
|
|
|
|
storage = new PluginJsonStorage<Settings>();
|
|
|
|
|
|
Settings = storage.Load();
|
2020-05-11 13:15:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-02 14:01:15 +00:00
|
|
|
|
public Task LoadStorage()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Task.Run(() => Settings = storage.Load());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-11 13:15:15 +00:00
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
|
storage.Save();
|
2020-05-11 13:15:15 +00:00
|
|
|
|
}
|
2020-06-08 04:20:22 +00:00
|
|
|
|
|
2021-01-26 10:29:56 +00:00
|
|
|
|
internal void RemoveLinkFromQuickAccess(AccessLink selectedRow) => Settings.QuickAccessLinks.Remove(selectedRow);
|
2020-06-08 04:20:22 +00:00
|
|
|
|
|
2021-01-26 10:29:56 +00:00
|
|
|
|
internal void RemoveAccessLinkFromExcludedIndexPaths(AccessLink selectedRow) => Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
|
2020-06-08 08:41:59 +00:00
|
|
|
|
|
|
|
|
|
|
internal void OpenWindowsIndexingOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
var psi = new ProcessStartInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
FileName = "control.exe",
|
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
|
Arguments = Constants.WindowsIndexingOptions
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Process.Start(psi);
|
|
|
|
|
|
}
|
2020-07-18 14:12:11 +00:00
|
|
|
|
|
|
|
|
|
|
internal void UpdateActionKeyword(string newActionKeyword, string oldActionKeyword)
|
|
|
|
|
|
{
|
|
|
|
|
|
PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
|
|
|
|
|
|
|
|
|
|
|
|
if (Settings.FileContentSearchActionKeyword == oldActionKeyword)
|
|
|
|
|
|
Settings.FileContentSearchActionKeyword = newActionKeyword;
|
|
|
|
|
|
|
|
|
|
|
|
if (Settings.SearchActionKeyword == oldActionKeyword)
|
|
|
|
|
|
Settings.SearchActionKeyword = newActionKeyword;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
|
2020-08-25 22:06:10 +00:00
|
|
|
|
|
|
|
|
|
|
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|