Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
2021-07-03 00:20:33 +08:00

77 lines
No EOL
3.5 KiB
C#

using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
using System;
using System.Collections.Generic;
using System.IO;
namespace Flow.Launcher.Plugin.Explorer
{
public class Settings
{
public int MaxResult { get; set; } = 100;
public List<AccessLink> QuickAccessLinks { get; set; } = new List<AccessLink>();
// as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards.
public List<AccessLink> QuickFolderAccessLinks { get; set; } = new List<AccessLink>();
public bool UseWindowsIndexForDirectorySearch { get; set; } = true;
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnabledSearchActionKeyword { get; set; } = true;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnabledPathSearchKeyword { get; set; }
public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool EnabledIndexOnlySearchKeyword { get; set; }
internal enum ActionKeyword
{
SearchActionKeyword,
PathSearchActionKeyword,
FileContentSearchActionKeyword,
IndexSearchActionKeyword
}
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
{
ActionKeyword.SearchActionKeyword => SearchActionKeyword,
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword
};
internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
{
ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword,
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
};
internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
{
ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword,
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword,
_ => null
};
internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
{
ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword = enable,
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
};
}
}