feat: add sort for in a profile/not in a profile

This commit is contained in:
goat 2023-07-18 20:28:48 +02:00
parent 8c57f26a18
commit ea8b7ed0b3
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -184,6 +184,7 @@ internal class PluginInstallerWindow : Window, IDisposable
NewOrNot,
NotInstalled,
EnabledDisabled,
ProfileOrNot,
}
private bool AnyOperationInProgress => this.installStatus == OperationStatus.InProgress ||
@ -505,6 +506,7 @@ internal class PluginInstallerWindow : Window, IDisposable
(Locs.SortBy_NewOrNot, PluginSortKind.NewOrNot),
(Locs.SortBy_NotInstalled, PluginSortKind.NotInstalled),
(Locs.SortBy_EnabledDisabled, PluginSortKind.EnabledDisabled),
(Locs.SortBy_ProfileOrNot, PluginSortKind.ProfileOrNot),
};
var longestSelectableWidth = sortSelectables.Select(t => ImGui.CalcTextSize(t.Localization).X).Max();
var selectableWidth = longestSelectableWidth + (style.FramePadding.X * 2); // This does not include the label
@ -2984,6 +2986,12 @@ internal class PluginInstallerWindow : Window, IDisposable
});
this.pluginListInstalled.Sort((p1, p2) => (p2.State == PluginState.Loaded).CompareTo(p1.State == PluginState.Loaded));
break;
case PluginSortKind.ProfileOrNot:
this.pluginListAvailable.Sort((p1, p2) => p1.Name.CompareTo(p2.Name));
var profman = Service<ProfileManager>.Get();
this.pluginListInstalled.Sort((p1, p2) => profman.IsInDefaultProfile(p1.InternalName).CompareTo(profman.IsInDefaultProfile(p2.InternalName)));
break;
default:
throw new InvalidEnumArgumentException("Unknown plugin sort type.");
}
@ -3062,6 +3070,8 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string SortBy_EnabledDisabled => Loc.Localize("InstallerEnabledDisabled", "Enabled/Disabled");
public static string SortBy_ProfileOrNot => Loc.Localize("InstallerProfileOrNot", "In a collection");
public static string SortBy_Label => Loc.Localize("InstallerSortBy", "Sort By");
#endregion