@@ -14,6 +14,7 @@ public partial class SearchSourceSettingWindow
1414 private PluginInitContext _context ;
1515 private IPublicAPI _api ;
1616 private SearchSourceViewModel _viewModel ;
17+ private string selectedNewIconImageFullPath ;
1718
1819
1920 public SearchSourceSettingWindow ( IList < SearchSource > sources , PluginInitContext context , SearchSource old )
@@ -40,6 +41,8 @@ private void Initilize(IList<SearchSource> sources, PluginInitContext context, A
4041 _api = _context . API ;
4142
4243 _viewModel . SetupCustomImagesDirectory ( ) ;
44+
45+ imgPreviewIcon . Source = _viewModel . LoadPreviewIcon ( _searchSource . IconPath ) ;
4346 }
4447
4548 private void OnCancelButtonClick ( object sender , RoutedEventArgs e )
@@ -112,6 +115,14 @@ private void EditSearchSource()
112115 var warning = _api . GetTranslation ( "newActionKeywordsHasBeenAssigned" ) ;
113116 MessageBox . Show ( warning ) ;
114117 }
118+
119+ if ( ! string . IsNullOrEmpty ( selectedNewIconImageFullPath ) )
120+ {
121+ _viewModel . UpdateIconAttributes ( _searchSource , selectedNewIconImageFullPath ) ;
122+
123+ _viewModel . CopyNewImageToUserDataDirectoryIfRequired (
124+ _searchSource , selectedNewIconImageFullPath , _oldSearchSource . IconPath ) ;
125+ }
115126 }
116127
117128 private void OnSelectIconClick ( object sender , RoutedEventArgs e )
@@ -122,17 +133,14 @@ private void OnSelectIconClick(object sender, RoutedEventArgs e)
122133 var result = dialog . ShowDialog ( ) ;
123134 if ( result == true )
124135 {
125- var fullpathToSelectedImage = dialog . FileName ;
126-
127- if ( _viewModel . ShouldProvideHint ( fullpathToSelectedImage ) )
128- MessageBox . Show ( _api . GetTranslation ( "flowlauncher_plugin_websearch_iconpath_hint" ) ) ;
136+ selectedNewIconImageFullPath = dialog . FileName ;
129137
130- if ( ! string . IsNullOrEmpty ( fullpathToSelectedImage ) )
138+ if ( ! string . IsNullOrEmpty ( selectedNewIconImageFullPath ) )
131139 {
132- var fullPathToOriginalImage = _searchSource . IconPath ;
133- _viewModel . UpdateIconAttributes ( _searchSource , fullpathToSelectedImage ) ;
134- _viewModel . CopyNewImageToUserDataDirectoryIfRequired (
135- _searchSource , fullpathToSelectedImage , fullPathToOriginalImage ) ;
140+ if ( _viewModel . ShouldProvideHint ( selectedNewIconImageFullPath ) )
141+ MessageBox . Show ( _api . GetTranslation ( "flowlauncher_plugin_websearch_iconpath_hint" ) ) ;
142+
143+ imgPreviewIcon . Source = _viewModel . LoadPreviewIcon ( selectedNewIconImageFullPath ) ;
136144 }
137145 }
138146 }
0 commit comments