Fix disabled source

This commit is contained in:
Vic 2022-11-15 00:07:12 +08:00
parent e2427cef81
commit 5c62c5ac9b
3 changed files with 18 additions and 17 deletions

View file

@ -277,7 +277,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
[Serializable]
public class Application : IProgram
{
public string UniqueIdentifier { get; set; }
private string _uid = string.Empty;
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); }
public string DisplayName { get; set; }
public string Description { get; set; }
public string UserModelId { get; set; }

View file

@ -23,7 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
public class Win32 : IProgram, IEquatable<Win32>
{
public string Name { get; set; }
public string UniqueIdentifier { get => _uid; set => _uid = value.ToLowerInvariant(); } // For path comparison
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison
public string IcoPath { get; set; }
public string FullPath { get; set; }
public string LnkResolvedPath { get; set; }

View file

@ -16,36 +16,36 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
public class ProgramSource
{
private string name;
private string loc = string.Empty;
private string uniqueIdentifier = string.Empty;
private string loc;
public string Location
{
get => loc;
set
{
loc = value;
UniqueIdentifier = value.ToLowerInvariant();
loc = value ?? string.Empty;
UniqueIdentifier = value;
}
}
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
public bool Enabled { get; set; } = true;
public string UniqueIdentifier { get; private set; }
public string UniqueIdentifier { get => uniqueIdentifier;
private set
{
uniqueIdentifier = value == null ? string.Empty : value.ToLowerInvariant();
}
}
[JsonConstructor]
public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier)
{
loc = location;
loc = location ?? string.Empty;
this.name = name;
Enabled = enabled;
if (location.Equals(uniqueIdentifier, StringComparison.OrdinalIgnoreCase))
{
UniqueIdentifier = location.ToLowerInvariant(); // To make sure old config can be reset to case-insensitive
}
else
{
UniqueIdentifier = uniqueIdentifier; // For uwp apps
}
UniqueIdentifier = uniqueIdentifier;
}
/// <summary>
@ -55,9 +55,9 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
/// <param name="enabled">enabled</param>
public ProgramSource(string location, bool enabled = true)
{
loc = location;
loc = location ?? string.Empty;
Enabled = enabled;
UniqueIdentifier = location.ToLowerInvariant(); // For path comparison
UniqueIdentifier = location; // For path comparison
}
public ProgramSource(IProgram source)