Skip to content

Commit 6604710

Browse files
committed
Fix inputWithFileBtn not working in SettingsTemplate.yml
1 parent 943425b commit 6604710

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
using System.Windows;
55
using System.Windows.Controls;
66
using System.Windows.Documents;
7+
using System.Windows.Forms;
78
using Flow.Launcher.Infrastructure.Storage;
89
using Flow.Launcher.Plugin;
10+
using CheckBox = System.Windows.Controls.CheckBox;
11+
using ComboBox = System.Windows.Controls.ComboBox;
12+
using Control = System.Windows.Controls.Control;
13+
using Orientation = System.Windows.Controls.Orientation;
14+
using TextBox = System.Windows.Controls.TextBox;
15+
using UserControl = System.Windows.Controls.UserControl;
916

1017
namespace Flow.Launcher.Core.Plugin
1118
{
@@ -224,6 +231,7 @@ public Control CreateSettingPanel()
224231
break;
225232
}
226233
case "inputWithFileBtn":
234+
case "inputWithFolderBtn":
227235
{
228236
var textBox = new TextBox()
229237
{
@@ -243,6 +251,24 @@ public Control CreateSettingPanel()
243251
Margin = new Thickness(10, 0, 0, 0), Content = "Browse"
244252
};
245253

254+
Btn.Click += (_, _) =>
255+
{
256+
CommonDialog dialog = type switch
257+
{
258+
"inputWithFolderBtn" => new FolderBrowserDialog(),
259+
_ => new OpenFileDialog(),
260+
};
261+
if (dialog.ShowDialog() != DialogResult.OK) return;
262+
263+
var path = dialog switch
264+
{
265+
FolderBrowserDialog folderDialog => folderDialog.SelectedPath,
266+
OpenFileDialog fileDialog => fileDialog.FileName,
267+
};
268+
textBox.Text = path;
269+
Settings[attribute.Name] = path;
270+
};
271+
246272
var dockPanel = new DockPanel() { Margin = settingControlMargin };
247273

248274
DockPanel.SetDock(Btn, Dock.Right);

0 commit comments

Comments
 (0)