2020-11-08 21:24:52 +00:00
|
|
|
|
using System;
|
2019-10-17 20:53:00 +00:00
|
|
|
|
using System.Collections.Generic;
|
2022-10-23 09:29:37 +00:00
|
|
|
|
using System.Linq;
|
2022-10-23 10:50:38 +00:00
|
|
|
|
using System.Text.Json.Serialization;
|
2022-10-20 08:15:56 +00:00
|
|
|
|
using Flow.Launcher.Plugin.Program.Views.Models;
|
2015-01-05 14:41:17 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.Plugin.Program
|
2015-01-05 14:41:17 +00:00
|
|
|
|
{
|
2016-04-21 00:53:21 +00:00
|
|
|
|
public class Settings
|
2015-01-05 14:41:17 +00:00
|
|
|
|
{
|
2019-10-17 21:16:07 +00:00
|
|
|
|
public DateTime LastIndexTime { get; set; }
|
2022-11-03 10:38:36 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// User-added program sources' directories
|
|
|
|
|
|
/// </summary>
|
2016-08-20 00:17:28 +00:00
|
|
|
|
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
|
2022-11-03 10:38:36 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Disabled single programs, not including User-added directories
|
|
|
|
|
|
/// </summary>
|
2022-11-02 05:58:56 +00:00
|
|
|
|
public List<ProgramSource> DisabledProgramSources { get; set; } = new List<ProgramSource>();
|
2015-01-05 14:41:17 +00:00
|
|
|
|
|
2022-11-03 16:47:52 +00:00
|
|
|
|
[Obsolete("Should use GetSuffixes() instead."), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2022-11-02 04:17:51 +00:00
|
|
|
|
public string[] ProgramSuffixes { get; set; } = null;
|
|
|
|
|
|
public string[] CustomSuffixes { get; set; } = Array.Empty<string>(); // Custom suffixes only
|
2022-10-23 12:01:18 +00:00
|
|
|
|
public string[] CustomProtocols { get; set; } = Array.Empty<string>();
|
2022-10-23 09:29:37 +00:00
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, bool> BuiltinSuffixesStatus { get; set; } = new Dictionary<string, bool>{
|
|
|
|
|
|
{ "exe", true }, { "appref-ms", true }, { "lnk", true }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-10-23 12:01:18 +00:00
|
|
|
|
public Dictionary<string, bool> BuiltinProtocolsStatus { get; set; } = new Dictionary<string, bool>{
|
2022-11-01 12:02:21 +00:00
|
|
|
|
{ "steam", true }, { "epic", true }, { "http", false }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public Dictionary<string, string> BuiltinProtocols { get; set; } = new Dictionary<string, string>{
|
|
|
|
|
|
{ "steam", $"steam://run/{SuffixSeparator}steam://rungameid/" }, { "epic", "com.epicgames.launcher://apps/" }, { "http", $"http://{SuffixSeparator}https://"}
|
2022-10-23 12:01:18 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-10-23 14:09:22 +00:00
|
|
|
|
public bool UseCustomSuffixes { get; set; } = false;
|
|
|
|
|
|
public bool UseCustomProtocols { get; set; } = false;
|
2022-10-23 09:29:37 +00:00
|
|
|
|
|
2022-10-23 12:01:18 +00:00
|
|
|
|
public string[] GetSuffixes()
|
2022-10-23 09:29:37 +00:00
|
|
|
|
{
|
2022-11-02 04:17:51 +00:00
|
|
|
|
RemoveRedundantSuffixes();
|
2022-10-23 09:29:37 +00:00
|
|
|
|
List<string> extensions = new List<string>();
|
2022-11-01 12:02:21 +00:00
|
|
|
|
foreach (var item in BuiltinSuffixesStatus)
|
2022-10-23 09:29:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (item.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
extensions.Add(item.Key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-03-28 02:09:57 +00:00
|
|
|
|
|
2022-10-23 12:01:18 +00:00
|
|
|
|
if (BuiltinProtocolsStatus.Values.Any(x => x == true) || UseCustomProtocols)
|
|
|
|
|
|
{
|
|
|
|
|
|
extensions.Add("url");
|
|
|
|
|
|
}
|
2022-10-23 10:50:38 +00:00
|
|
|
|
|
|
|
|
|
|
if (UseCustomSuffixes)
|
|
|
|
|
|
{
|
|
|
|
|
|
return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-10-23 12:01:18 +00:00
|
|
|
|
return extensions.DistinctBy(x => x.ToLower()).ToArray();
|
2022-10-23 10:50:38 +00:00
|
|
|
|
}
|
2022-10-23 09:29:37 +00:00
|
|
|
|
}
|
2015-01-05 14:41:17 +00:00
|
|
|
|
|
2022-10-23 12:01:18 +00:00
|
|
|
|
public string[] GetProtocols()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> protocols = new List<string>();
|
|
|
|
|
|
foreach (var item in BuiltinProtocolsStatus)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Value)
|
|
|
|
|
|
{
|
2022-11-01 12:02:21 +00:00
|
|
|
|
if (BuiltinProtocols.TryGetValue(item.Key, out string ps))
|
2022-10-23 12:01:18 +00:00
|
|
|
|
{
|
2022-11-01 12:02:21 +00:00
|
|
|
|
var tmp = ps.Split(SuffixSeparator, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
foreach (var protocol in tmp)
|
|
|
|
|
|
{
|
|
|
|
|
|
protocols.Add(protocol);
|
|
|
|
|
|
}
|
2022-10-23 12:01:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (UseCustomProtocols)
|
|
|
|
|
|
{
|
|
|
|
|
|
return protocols.Concat(CustomProtocols).DistinctBy(x => x.ToLower()).ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return protocols.DistinctBy(x => x.ToLower()).ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-03-28 02:09:57 +00:00
|
|
|
|
|
2022-11-02 04:17:51 +00:00
|
|
|
|
private void RemoveRedundantSuffixes()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Migrate to new settings
|
|
|
|
|
|
// CustomSuffixes no longer contains custom suffixes
|
|
|
|
|
|
// users has tweaked the settings
|
|
|
|
|
|
// or this function has been executed once
|
2024-05-26 10:01:29 +00:00
|
|
|
|
if (UseCustomSuffixes == true || ProgramSuffixes == null)
|
2022-11-02 04:17:51 +00:00
|
|
|
|
return;
|
|
|
|
|
|
var suffixes = ProgramSuffixes.ToList();
|
|
|
|
|
|
foreach(var item in BuiltinSuffixesStatus)
|
|
|
|
|
|
{
|
|
|
|
|
|
suffixes.Remove(item.Key);
|
|
|
|
|
|
}
|
|
|
|
|
|
CustomSuffixes = suffixes.ToArray(); // Custom suffixes
|
|
|
|
|
|
UseCustomSuffixes = CustomSuffixes.Length != 0; // Search custom suffixes or not
|
|
|
|
|
|
ProgramSuffixes = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-23 12:01:18 +00:00
|
|
|
|
public bool EnableStartMenuSource { get; set; } = true;
|
2021-11-27 20:05:25 +00:00
|
|
|
|
public bool EnableDescription { get; set; } = false;
|
2021-11-30 00:31:48 +00:00
|
|
|
|
public bool HideAppsPath { get; set; } = true;
|
2024-05-26 10:01:29 +00:00
|
|
|
|
public bool HideUninstallers { get; set; } = false;
|
2016-04-21 00:53:21 +00:00
|
|
|
|
public bool EnableRegistrySource { get; set; } = true;
|
2022-12-17 13:29:25 +00:00
|
|
|
|
public bool EnablePathSource { get; set; } = false;
|
2022-12-17 14:00:04 +00:00
|
|
|
|
public bool EnableUWP { get; set; } = true;
|
2025-02-21 01:29:43 +00:00
|
|
|
|
public bool HideDuplicatedWindowsApp { get; set; } = false;
|
2022-10-15 13:24:02 +00:00
|
|
|
|
|
2022-10-23 14:09:22 +00:00
|
|
|
|
internal const char SuffixSeparator = ';';
|
2015-01-05 14:41:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|