mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Catch exception when creating setting panel
This commit is contained in:
parent
51df66e362
commit
e204daa844
1 changed files with 35 additions and 1 deletions
|
|
@ -131,11 +131,45 @@ namespace Flow.Launcher.ViewModel
|
||||||
=> IsExpanded
|
=> IsExpanded
|
||||||
? _settingControl
|
? _settingControl
|
||||||
??= HasSettingControl
|
??= HasSettingControl
|
||||||
? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel()
|
? TryCreateSettingPanel(PluginPair)
|
||||||
: null
|
: null
|
||||||
: null;
|
: null;
|
||||||
private ImageSource _image = ImageLoader.MissingImage;
|
private ImageSource _image = ImageLoader.MissingImage;
|
||||||
|
|
||||||
|
private static readonly Thickness SettingPanelMargin = (Thickness)Application.Current.FindResource("SettingPanelMargin");
|
||||||
|
private static readonly Thickness SettingPanelItemTopBottomMargin = (Thickness)Application.Current.FindResource("SettingPanelItemTopBottomMargin");
|
||||||
|
private static Control TryCreateSettingPanel(PluginPair pair)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// We can safely cast here as we already check this in HasSettingControl
|
||||||
|
return ((ISettingProvider)pair.Plugin).CreateSettingPanel();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
var errorMsg = $"Error creating setting panel for plugin {pair.Metadata}\n{e.Message}";
|
||||||
|
var grid = new Grid()
|
||||||
|
{
|
||||||
|
Margin = SettingPanelMargin
|
||||||
|
};
|
||||||
|
var textBox = new TextBox
|
||||||
|
{
|
||||||
|
Text = errorMsg,
|
||||||
|
IsReadOnly = true,
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||||
|
VerticalAlignment = VerticalAlignment.Top,
|
||||||
|
TextWrapping = TextWrapping.Wrap,
|
||||||
|
Margin = SettingPanelItemTopBottomMargin
|
||||||
|
};
|
||||||
|
textBox.SetResourceReference(TextBlock.ForegroundProperty, "Color04B");
|
||||||
|
grid.Children.Add(textBox);
|
||||||
|
return new UserControl
|
||||||
|
{
|
||||||
|
Content = grid
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Visibility ActionKeywordsVisibility => PluginPair.Metadata.HideActionKeywordPanel ?
|
public Visibility ActionKeywordsVisibility => PluginPair.Metadata.HideActionKeywordPanel ?
|
||||||
Visibility.Collapsed : Visibility.Visible;
|
Visibility.Collapsed : Visibility.Visible;
|
||||||
public string InitializeTime => PluginPair.Metadata.InitTime + "ms";
|
public string InitializeTime => PluginPair.Metadata.InitTime + "ms";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue