2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00

don't save empty fileinfo settings

This commit is contained in:
Xjph 2021-10-23 13:03:22 -02:30
parent 5e8891c75f
commit 08a8aa3156

View File

@ -854,7 +854,7 @@ namespace Observatory.UI.Views
settingsGrid.AddControl(label, settingsGrid.RowDefinitions.Count - 1, 0); settingsGrid.AddControl(label, settingsGrid.RowDefinitions.Count - 1, 0);
settingsGrid.AddControl(intControl, settingsGrid.RowDefinitions.Count - 1, 1); settingsGrid.AddControl(intControl, settingsGrid.RowDefinitions.Count - 1, 1);
break; break;
case System.IO.FileInfo fileSetting: case FileInfo fileSetting:
label.Text += ": "; label.Text += ": ";
TextBox settingPath = new() TextBox settingPath = new()
@ -887,7 +887,7 @@ namespace Observatory.UI.Views
{ {
string path = browseTask.Result[0]; string path = browseTask.Result[0];
Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => { settingPath.Text = path; }); Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => { settingPath.Text = path; });
setting.Key.SetValue(plugin.Settings, new System.IO.FileInfo(path)); setting.Key.SetValue(plugin.Settings, new FileInfo(path));
PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings); PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
} }
@ -896,20 +896,23 @@ namespace Observatory.UI.Views
}; };
settingPath.LostFocus += (object sender, RoutedEventArgs e) => settingPath.LostFocus += (object sender, RoutedEventArgs e) =>
{
if (settingPath.Text.Trim() != string.Empty)
{ {
string fullPath; string fullPath;
try try
{ {
fullPath = System.IO.Path.GetFullPath(settingPath.Text); fullPath = Path.GetFullPath(settingPath.Text);
} }
catch catch
{ {
fullPath = string.Empty; fullPath = string.Empty;
} }
setting.Key.SetValue(plugin.Settings, new System.IO.FileInfo(fullPath)); setting.Key.SetValue(plugin.Settings, new FileInfo(fullPath));
PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings); PluginManagement.PluginManager.GetInstance.SaveSettings(plugin, plugin.Settings);
}
}; };
StackPanel stackPanel = new() { Orientation = Avalonia.Layout.Orientation.Horizontal }; StackPanel stackPanel = new() { Orientation = Avalonia.Layout.Orientation.Horizontal };