@@ -14,6 +14,7 @@ public partial class SearchSourceSettingWindow
14
14
private PluginInitContext _context ;
15
15
private IPublicAPI _api ;
16
16
private SearchSourceViewModel _viewModel ;
17
+ private string selectedNewIconImageFullPath ;
17
18
18
19
19
20
public SearchSourceSettingWindow ( IList < SearchSource > sources , PluginInitContext context , SearchSource old )
@@ -40,6 +41,8 @@ private void Initilize(IList<SearchSource> sources, PluginInitContext context, A
40
41
_api = _context . API ;
41
42
42
43
_viewModel . SetupCustomImagesDirectory ( ) ;
44
+
45
+ imgPreviewIcon . Source = _viewModel . LoadPreviewIcon ( _searchSource . IconPath ) ;
43
46
}
44
47
45
48
private void OnCancelButtonClick ( object sender , RoutedEventArgs e )
@@ -112,6 +115,14 @@ private void EditSearchSource()
112
115
var warning = _api . GetTranslation ( "newActionKeywordsHasBeenAssigned" ) ;
113
116
MessageBox . Show ( warning ) ;
114
117
}
118
+
119
+ if ( ! string . IsNullOrEmpty ( selectedNewIconImageFullPath ) )
120
+ {
121
+ _viewModel . UpdateIconAttributes ( _searchSource , selectedNewIconImageFullPath ) ;
122
+
123
+ _viewModel . CopyNewImageToUserDataDirectoryIfRequired (
124
+ _searchSource , selectedNewIconImageFullPath , _oldSearchSource . IconPath ) ;
125
+ }
115
126
}
116
127
117
128
private void OnSelectIconClick ( object sender , RoutedEventArgs e )
@@ -122,17 +133,14 @@ private void OnSelectIconClick(object sender, RoutedEventArgs e)
122
133
var result = dialog . ShowDialog ( ) ;
123
134
if ( result == true )
124
135
{
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 ;
129
137
130
- if ( ! string . IsNullOrEmpty ( fullpathToSelectedImage ) )
138
+ if ( ! string . IsNullOrEmpty ( selectedNewIconImageFullPath ) )
131
139
{
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 ) ;
136
144
}
137
145
}
138
146
}
0 commit comments