diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
index 9230eb06254..39d5f8a4e19 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
@@ -5,12 +5,12 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource flowlauncher_plugin_program_directory}"
- Width="400"
+ Width="530"
Background="{DynamicResource PopuBGColor}"
Foreground="{DynamicResource PopupTextColor}"
+ ResizeMode="NoResize"
SizeToContent="Height"
- WindowStartupLocation="CenterScreen"
- mc:Ignorable="d">
+ WindowStartupLocation="CenterScreen">
@@ -19,7 +19,6 @@
-
@@ -53,33 +52,78 @@
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -87,19 +131,17 @@
-
-
-
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
index 045d363b3fe..e5ea2eda267 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
@@ -9,11 +9,12 @@ namespace Flow.Launcher.Plugin.Program
///
/// Interaction logic for AddProgramSource.xaml
///
- public partial class AddProgramSource
+ public partial class AddProgramSource : Window
{
private PluginInitContext _context;
- private Settings.ProgramSource _editing;
+ private Settings.ProgramSource _updating;
private Settings _settings;
+ private bool update;
public AddProgramSource(PluginInitContext context, Settings settings)
{
@@ -21,15 +22,19 @@ public AddProgramSource(PluginInitContext context, Settings settings)
_context = context;
_settings = settings;
Directory.Focus();
+ Chkbox.IsChecked = true;
+ update = false;
+ btnAdd.Content = _context.API.GetTranslation("flowlauncher_plugin_program_add");
}
- public AddProgramSource(Settings.ProgramSource edit, Settings settings)
+ public AddProgramSource(Settings.ProgramSource source, Settings settings)
{
- _editing = edit;
- _settings = settings;
-
InitializeComponent();
- Directory.Text = _editing.Location;
+ _updating = source;
+ _settings = settings;
+ update = true;
+ Chkbox.IsChecked = _updating.Enabled;
+ Directory.Text = _updating.Location;
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
@@ -47,22 +52,23 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
Close();
}
- private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
+ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
{
- string s = Directory.Text;
- if (!System.IO.Directory.Exists(s))
+ string path = Directory.Text;
+ if (!System.IO.Directory.Exists(path))
{
System.Windows.MessageBox.Show(_context.API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
return;
}
- if (_editing == null)
+ if (!update)
{
- if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text))
+ if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == path))
{
var source = new ProgramSource
{
- Location = Directory.Text,
- UniqueIdentifier = Directory.Text
+ Location = path,
+ UniqueIdentifier = path,
+ Enabled = Chkbox.IsChecked ?? true
};
_settings.ProgramSources.Insert(0, source);
@@ -71,7 +77,8 @@ private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
}
else
{
- _editing.Location = Directory.Text;
+ _updating.Location = path;
+ _updating.Enabled = Chkbox.IsChecked ?? true; // Fixme, need to add to disabled source if not custom source
}
DialogResult = true;
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
index 8d8cae02c9f..74315be7eed 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
@@ -9,6 +9,7 @@
Add
Name
Enable
+ Enabled
Disable
Location
All Programs
@@ -34,7 +35,10 @@
Please select a program source
Are you sure you want to delete the selected program sources?
- OK
+ Program Source
+ Edit directory and status of this program source.
+
+ Update
Flow Launcher will only index files that end with the following suffixes. (Each suffix should split by ';' )
Successfully updated file suffixes
File suffixes can't be empty
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
index f0a53ed7758..ed7cc627f38 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
@@ -196,12 +196,17 @@ private void DisableProgram(IProgram programToDelete)
return;
if (_uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ {
_uwps.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
.Enabled = false;
-
- if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ Task.Run(IndexUwpPrograms);
+ }
+ else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ {
_win32s.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
.Enabled = false;
+ Task.Run(IndexWin32Programs);
+ }
_settings.DisabledProgramSources
.Add(
@@ -213,6 +218,7 @@ private void DisableProgram(IProgram programToDelete)
Enabled = false
}
);
+ _settings.LastIndexTime = DateTime.Today;
}
public static void StartProcess(Func runProcess, ProcessStartInfo info)
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs
index d97ddd9932a..d61ecd2a3f9 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs
@@ -9,7 +9,7 @@ public class Settings
public DateTime LastIndexTime { get; set; }
public List ProgramSources { get; set; } = new List();
public List DisabledProgramSources { get; set; } = new List();
- public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"};
+ public string[] ProgramSuffixes { get; set; } = { "appref-ms", "exe", "lnk" };
public bool EnableStartMenuSource { get; set; } = true;
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
index f078794654b..171f6081bab 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
@@ -116,6 +116,8 @@
Drop="programSourceView_Drop"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
+ MouseDoubleClick="programSourceView_MouseDoubleClick"
+ SelectionChanged="programSourceView_SelectionChanged"
SelectionMode="Extended">
@@ -126,7 +128,7 @@
-
+
_settings.HideAppsPath;
@@ -235,18 +236,14 @@ private void btnProgramSourceStatus_OnClick(object sender, RoutedEventArgs e)
.SelectedItems.Cast()
.ToList();
- if (selectedItems.Count() == 0)
+ if (selectedItems.Count == 0)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBox.Show(msg);
return;
}
- if (selectedItems
- .Where(t1 => !_settings
- .ProgramSources
- .Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
- .Count() == 0)
+ if (IsAllItemsUserAdded(selectedItems))
{
var msg = string.Format(context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"));
@@ -257,7 +254,7 @@ private void btnProgramSourceStatus_OnClick(object sender, RoutedEventArgs e)
DeleteProgramSources(selectedItems);
}
- else if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
+ else if (HasMoreOrEqualEnabledItems(selectedItems))
{
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, false);
@@ -329,35 +326,47 @@ private void Sort(string sortBy, ListSortDirection direction)
dataView.Refresh();
}
- private bool IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(List selectedItems)
+ private static bool HasMoreOrEqualEnabledItems(List items)
{
- return selectedItems.Where(x => x.Enabled).Count() >= selectedItems.Where(x => !x.Enabled).Count();
+ return items.Where(x => x.Enabled).Count() >= items.Count / 2;
}
- private void Row_OnClick(object sender, RoutedEventArgs e)
+ private void programSourceView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedItems = programSourceView
.SelectedItems.Cast()
.ToList();
- if (selectedItems
- .Where(t1 => !_settings
- .ProgramSources
- .Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
- .Count() == 0)
+ if (IsAllItemsUserAdded(selectedItems))
{
btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_delete");
- return;
}
-
- if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
+ else if (HasMoreOrEqualEnabledItems(selectedItems))
{
- btnProgramSourceStatus.Content = "Disable";
+ btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_disable");
}
else
{
- btnProgramSourceStatus.Content = "Enable";
+ btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_enable");
}
}
+
+ private void programSourceView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ var selectedProgramSource = programSourceView.SelectedItem as Settings.ProgramSource;
+ if (selectedProgramSource != null)
+ {
+ var add = new AddProgramSource(selectedProgramSource, _settings);
+ if (add.ShowDialog() ?? false)
+ {
+ ReIndexing();
+ }
+ }
+ }
+
+ private bool IsAllItemsUserAdded(List items)
+ {
+ return items.All(x => _settings.ProgramSources.Any(y => y.UniqueIdentifier == x.UniqueIdentifier));
+ }
}
-}
\ No newline at end of file
+}