diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs
index de83cfad5..c7ccb4d51 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSource.cs
@@ -34,11 +34,6 @@ namespace Flow.Launcher.Plugin.WebSearch
}
}
- [JsonIgnore]
- public ImageSource Image => ImageLoader.Load(IconPath);
-
- internal void NotifyImageChange() => OnPropertyChanged(nameof(Image));
-
public string Url { get; set; }
public bool Enabled { get; set; }
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
index 0f17d21f5..02809be3a 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
@@ -47,7 +47,7 @@
-
+
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
index 7a8996943..fd0701c01 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
@@ -14,6 +14,7 @@ namespace Flow.Launcher.Plugin.WebSearch
private PluginInitContext _context;
private IPublicAPI _api;
private SearchSourceViewModel _viewModel;
+ private string selectedNewIconImageFullPath;
public SearchSourceSettingWindow(IList sources, PluginInitContext context, SearchSource old)
@@ -40,6 +41,8 @@ namespace Flow.Launcher.Plugin.WebSearch
_api = _context.API;
_viewModel.SetupCustomImagesDirectory();
+
+ imgPreviewIcon.Source = _viewModel.LoadPreviewIcon(_searchSource.IconPath);
}
private void OnCancelButtonClick(object sender, RoutedEventArgs e)
@@ -112,6 +115,14 @@ namespace Flow.Launcher.Plugin.WebSearch
var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBox.Show(warning);
}
+
+ if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
+ {
+ _viewModel.UpdateIconAttributes(_searchSource, selectedNewIconImageFullPath);
+
+ _viewModel.CopyNewImageToUserDataDirectoryIfRequired(
+ _searchSource, selectedNewIconImageFullPath, _oldSearchSource.IconPath);
+ }
}
private void OnSelectIconClick(object sender, RoutedEventArgs e)
@@ -122,17 +133,14 @@ namespace Flow.Launcher.Plugin.WebSearch
var result = dialog.ShowDialog();
if (result == true)
{
- var fullpathToSelectedImage = dialog.FileName;
+ selectedNewIconImageFullPath = dialog.FileName;
- if (_viewModel.ShouldProvideHint(fullpathToSelectedImage))
- MessageBox.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint"));
-
- if (!string.IsNullOrEmpty(fullpathToSelectedImage))
+ if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
{
- var fullPathToOriginalImage = _searchSource.IconPath;
- _viewModel.UpdateIconAttributes(_searchSource, fullpathToSelectedImage);
- _viewModel.CopyNewImageToUserDataDirectoryIfRequired(
- _searchSource, fullpathToSelectedImage, fullPathToOriginalImage);
+ if (_viewModel.ShouldProvideHint(selectedNewIconImageFullPath))
+ MessageBox.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint"));
+
+ imgPreviewIcon.Source = _viewModel.LoadPreviewIcon(selectedNewIconImageFullPath);
}
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs
index 17bbc2ab1..31c5faf88 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs
@@ -1,5 +1,8 @@
+using Flow.Launcher.Infrastructure.Image;
using System;
+using System.Drawing;
using System.IO;
+using System.Windows.Media;
namespace Flow.Launcher.Plugin.WebSearch
{
@@ -40,8 +43,6 @@ namespace Flow.Launcher.Plugin.WebSearch
#endif
}
}
-
- selectedSearchSource.NotifyImageChange();
}
internal void SetupCustomImagesDirectory()
@@ -54,5 +55,10 @@ namespace Flow.Launcher.Plugin.WebSearch
{
return Directory.GetParent(fullPathToSelectedImage).ToString() == Main.DefaultImagesDirectory;
}
+
+ internal ImageSource LoadPreviewIcon(string pathToPreviewIconImage)
+ {
+ return ImageLoader.Load(pathToPreviewIconImage);
+ }
}
}
\ No newline at end of file