Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<system:String x:Key="restartToDisablePortableMode">Flow Launcher needs to restart to finish disabling portable mode, after the restart your portable data profile will be deleted and roaming data profile kept</system:String>
<system:String x:Key="restartToEnablePortableMode">Flow Launcher needs to restart to finish enabling portable mode, after the restart your roaming data profile will be deleted and portable data profile kept</system:String>
<system:String x:Key="moveToDifferentLocation">Flow Launcher has detected you enabled portable mode, would you like to move it to a different location?</system:String>
<system:String x:Key="shortcutsUninstallerCreated">Flow Launcher has detected you disabled portable mode, the relevant shortcuts and uninstaller entry have been created</system:String>

Check warning on line 25 in Flow.Launcher/Languages/en.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninstaller` is not a recognized word. (unrecognized-spelling)
<system:String x:Key="userDataDuplicated">Flow Launcher detected your user data exists both in {0} and {1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.</system:String>

<!-- Plugin Loader -->
Expand Down Expand Up @@ -219,6 +219,7 @@
<system:String x:Key="failedToUninstallPluginTitle">Fail to uninstall {0}</system:String>
<system:String x:Key="fileNotFoundMessage">Unable to find plugin.json from the extracted zip file, or this path {0} does not exist</system:String>
<system:String x:Key="pluginExistAlreadyMessage">A plugin with the same ID and version already exists, or the version is greater than this downloaded plugin</system:String>
<system:String x:Key="errorCreatingSettingPanel">Error creating setting panel for plugin {0}:{1}{2}</system:String>

<!-- Setting Plugin Store -->
<system:String x:Key="pluginStore">Plugin Store</system:String>
Expand Down
46 changes: 44 additions & 2 deletions Flow.Launcher/ViewModel/PluginViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand All @@ -14,6 +15,8 @@ namespace Flow.Launcher.ViewModel
{
public partial class PluginViewModel : BaseModel
{
private static readonly string ClassName = nameof(PluginViewModel);

private static readonly Settings Settings = Ioc.Default.GetRequiredService<Settings>();

private readonly PluginPair _pluginPair;
Expand Down Expand Up @@ -131,11 +134,50 @@ public Control SettingControl
=> IsExpanded
? _settingControl
??= HasSettingControl
? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel()
? TryCreateSettingPanel(PluginPair)
: null
: null;
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 (Exception e)
{
// Log exception
App.API.LogException(ClassName, $"Failed to create setting panel for {pair.Metadata.Name}", e);

// Show error message in UI
var errorMsg = string.Format(App.API.GetTranslation("errorCreatingSettingPanel"),
pair.Metadata.Name, Environment.NewLine, 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 ?
Visibility.Collapsed : Visibility.Visible;
public string InitializeTime => PluginPair.Metadata.InitTime + "ms";
Expand Down
Loading