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 @@ -164,10 +164,11 @@ public interface IPublicAPI
164164
165165
166166 /// <summary>
167- /// Open plugin setting window for a specific plugin
167+ /// Open plugin setting window for a specific plugin.
168+ /// Reuses the existing window when that plugin's settings window is already open.
168169 /// </summary>
169170 /// <param name="pluginId">ID of the plugin whose settings window should be opened</param>
170- /// <returns>True if the plugin settings window was successfully opened; false otherwise</returns>
171+ /// <returns>True if the plugin settings window was successfully opened or reused ; false otherwise</returns>
171172 bool OpenPluginSettingsWindow ( string pluginId ) ;
172173
173174 /// <summary>
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public partial class PluginSettingsWindow
1313{
1414 private readonly Settings _settings ;
1515
16+ public string PluginId { get ; }
17+
1618 public PluginSettingsWindow ( string pluginId )
1719 {
1820 _settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
@@ -21,6 +23,8 @@ public PluginSettingsWindow(string pluginId)
2123 throw new ArgumentException ( "Plugin ID cannot be null or whitespace." , nameof ( pluginId ) ) ;
2224 }
2325
26+ PluginId = pluginId ;
27+
2428 var pluginPair = PluginManager . GetPluginForId ( pluginId ) ;
2529 if ( pluginPair == null )
2630 {
Original file line number Diff line number Diff line change 55using System . ComponentModel ;
66using System . Diagnostics ;
77using System . IO ;
8+ using System . Linq ;
89using System . Net ;
910using System . Runtime . CompilerServices ;
1011using System . Runtime . InteropServices ;
@@ -153,8 +154,27 @@ public bool OpenPluginSettingsWindow(string pluginId)
153154 {
154155 try
155156 {
156- var window = new PluginSettingsWindow ( pluginId ) ;
157- window . Show ( ) ;
157+ // get existing settings window for this plugin, or else create a new one
158+ var window = Application . Current . Windows
159+ . OfType < PluginSettingsWindow > ( )
160+ . FirstOrDefault ( existing => existing . PluginId == pluginId )
161+ ?? new PluginSettingsWindow ( pluginId ) ;
162+
163+ if ( window . WindowState == WindowState . Minimized )
164+ {
165+ window . WindowState = WindowState . Normal ;
166+ }
167+
168+ if ( ! window . IsVisible )
169+ {
170+ window . Show ( ) ;
171+ }
172+ else
173+ {
174+ window . Activate ( ) ;
175+ }
176+
177+ window . Focus ( ) ;
158178 return true ;
159179 }
160180 catch ( Exception e )
You can’t perform that action at this time.
0 commit comments