mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Refactor
This commit is contained in:
parent
8a4ff3bada
commit
cb295bbd90
2 changed files with 16 additions and 23 deletions
|
|
@ -9,24 +9,17 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
|
|||
{
|
||||
internal static class ProgramSettingDisplay
|
||||
{
|
||||
internal static List<ProgramSource> LoadProgramSources(this List<ProgramSource> programSources)
|
||||
internal static List<ProgramSource> LoadProgramSources()
|
||||
{
|
||||
var list = new List<ProgramSource>(programSources);
|
||||
|
||||
// Even though these are disabled, we still want to display them so users can enable later on
|
||||
Main._settings
|
||||
.DisabledProgramSources
|
||||
.Where(t1 => !Main._settings
|
||||
.ProgramSources // program sourcces added above already, so exlcude
|
||||
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
|
||||
.Select(x => x)
|
||||
.ToList()
|
||||
.ForEach(x => list.Add(new ProgramSource(x)));
|
||||
|
||||
return list;
|
||||
return Main._settings
|
||||
.DisabledProgramSources
|
||||
.Select(s => new ProgramSource(s))
|
||||
.Union(Main._settings.ProgramSources)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
internal static void LoadAllApplications(this List<ProgramSource> list)
|
||||
internal static void DisplayAllPrograms()
|
||||
{
|
||||
Main._win32s
|
||||
.Where(t1 => !ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
|
||||
|
|
@ -39,7 +32,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
|
|||
.ForEach(t1 => ProgramSetting.ProgramSettingDisplayList.Add(new ProgramSource(t1)));
|
||||
}
|
||||
|
||||
internal static void SetProgramSourcesStatus(this List<ProgramSource> list, List<ProgramSource> selectedProgramSourcesToDisable, bool status)
|
||||
internal static void SetProgramSourcesStatus(List<ProgramSource> selectedProgramSourcesToDisable, bool status)
|
||||
{
|
||||
ProgramSetting.ProgramSettingDisplayList
|
||||
.Where(t1 => selectedProgramSourcesToDisable.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && t1.Enabled != status))
|
||||
|
|
@ -57,7 +50,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
|
|||
.ForEach(t1 => t1.Enabled = status);
|
||||
}
|
||||
|
||||
internal static void StoreDisabledInSettings(this List<ProgramSource> list)
|
||||
internal static void StoreDisabledInSettings()
|
||||
{
|
||||
Main._settings.ProgramSources
|
||||
.Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && !x.Enabled))
|
||||
|
|
@ -72,7 +65,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
|
|||
.Add(new DisabledProgramSource(x)));
|
||||
}
|
||||
|
||||
internal static void RemoveDisabledFromSettings(this List<ProgramSource> list)
|
||||
internal static void RemoveDisabledFromSettings()
|
||||
{
|
||||
Main._settings.ProgramSources
|
||||
.Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled))
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSettingDisplayList = _settings.ProgramSources.LoadProgramSources();
|
||||
ProgramSettingDisplayList = ProgramSettingDisplay.LoadProgramSources();
|
||||
programSourceView.ItemsSource = ProgramSettingDisplayList;
|
||||
|
||||
ViewRefresh();
|
||||
|
|
@ -221,7 +221,7 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
|
||||
private void btnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramSettingDisplayList.LoadAllApplications();
|
||||
ProgramSettingDisplay.DisplayAllPrograms();
|
||||
|
||||
ViewRefresh();
|
||||
}
|
||||
|
|
@ -256,15 +256,15 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
}
|
||||
else if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
|
||||
{
|
||||
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, false);
|
||||
ProgramSettingDisplay.SetProgramSourcesStatus(selectedItems, false);
|
||||
|
||||
ProgramSettingDisplayList.StoreDisabledInSettings();
|
||||
ProgramSettingDisplay.StoreDisabledInSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true);
|
||||
ProgramSettingDisplay.SetProgramSourcesStatus(selectedItems, true);
|
||||
|
||||
ProgramSettingDisplayList.RemoveDisabledFromSettings();
|
||||
ProgramSettingDisplay.RemoveDisabledFromSettings();
|
||||
}
|
||||
|
||||
if (selectedItems.IsReindexRequired())
|
||||
|
|
|
|||
Loading…
Reference in a new issue