File tree Expand file tree Collapse file tree
Flow.Launcher.Plugin/Interfaces Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,7 +167,8 @@ public interface IPublicAPI
167167 /// Open plugin setting window for a specific plugin
168168 /// </summary>
169169 /// <param name="pluginId">ID of the plugin whose settings window should be opened</param>
170- void OpenPluginSettingsWindow ( string pluginId ) ;
170+ /// <returns>True if the plugin settings window was successfully opened; false otherwise</returns>
171+ bool OpenPluginSettingsWindow ( string pluginId ) ;
171172
172173 /// <summary>
173174 /// Get translation of current language
Original file line number Diff line number Diff line change 487487
488488 <!-- Plugin Settings Window -->
489489 <system : String x : Key =" pluginSettingsWindowTitle" >Settings: {0}</system : String >
490+ <system : String x : Key =" pluginSettingsWindowOpenFailed" >Failed to open plugin settings window</system : String >
490491
491492 <!-- Release Notes Window -->
492493 <system : String x : Key =" seeMoreReleaseNotes" >See more release notes on GitHub</system : String >
Original file line number Diff line number Diff line change @@ -17,24 +17,20 @@ public PluginSettingsWindow(string pluginId)
1717 {
1818 _settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
1919
20- if ( string . IsNullOrWhiteSpace ( pluginId ) )
21- {
22- App . API . ShowMsgError ( "Plugin settings" , "Invalid plugin id." ) ;
23- return ;
20+ if ( string . IsNullOrWhiteSpace ( pluginId ) ) {
21+ throw new ArgumentException ( "Plugin ID cannot be null or whitespace." , nameof ( pluginId ) ) ;
2422 }
2523
2624 var pluginPair = PluginManager . GetPluginForId ( pluginId ) ;
2725 if ( pluginPair == null )
2826 {
29- App . API . ShowMsgError ( "Plugin settings" , $ "Unable to find plugin: { pluginId } ") ;
30- return ;
27+ throw new InvalidOperationException ( $ "Unable to find plugin: { pluginId } ") ;
3128 }
3229
3330 var pluginSettings = _settings . PluginSettings . GetPluginSettings ( pluginId ) ;
3431 if ( pluginSettings == null )
3532 {
36- App . API . ShowMsgError ( "Plugin settings" , $ "Unable to load settings for plugin: { pluginPair . Metadata . Name } ") ;
37- return ;
33+ throw new InvalidOperationException ( $ "Unable to load settings for plugin: { pluginPair . Metadata . Name } ") ;
3834 }
3935
4036 var pluginViewModel = new PluginViewModel
Original file line number Diff line number Diff line change @@ -147,12 +147,22 @@ public void OpenSettingDialog()
147147 } ) ;
148148 }
149149
150- public void OpenPluginSettingsWindow ( string pluginId )
150+ public bool OpenPluginSettingsWindow ( string pluginId )
151151 {
152- Application . Current . Dispatcher . Invoke ( ( ) =>
152+ return Application . Current . Dispatcher . Invoke ( ( ) =>
153153 {
154- var window = new PluginSettingsWindow ( pluginId ) ;
155- window . Show ( ) ;
154+ try
155+ {
156+ var window = new PluginSettingsWindow ( pluginId ) ;
157+ window . Show ( ) ;
158+ return true ;
159+ }
160+ catch ( Exception e )
161+ {
162+ LogException ( ClassName , $ "Failed to open plugin settings window for plugin id '{ pluginId } '", e ) ;
163+ ShowMsgError ( Localize . pluginSettingsWindowOpenFailed ( ) ) ;
164+ return false ;
165+ }
156166 } ) ;
157167 }
158168
Original file line number Diff line number Diff line change @@ -1841,8 +1841,7 @@ private static Result ContextMenuPluginSettings(Result result)
18411841 PluginDirectory = Constant . ProgramDirectory ,
18421842 Action = _ =>
18431843 {
1844- App . API . OpenPluginSettingsWindow ( id ) ;
1845- return true ;
1844+ return App . API . OpenPluginSettingsWindow ( id ) ;
18461845 } ,
18471846 OriginQuery = result . OriginQuery
18481847 } ;
You can’t perform that action at this time.
0 commit comments