mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add ShowErrorMessage setting
This commit is contained in:
parent
cea1402dde
commit
1906d68541
4 changed files with 21 additions and 1 deletions
|
|
@ -15,4 +15,5 @@
|
|||
<system:String x:Key="flowlauncher_plugin_calculator_decimal_separator_dot">Dot (.)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_max_decimal_places">Max. decimal places</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_failed_to_copy">Copy failed, please try later</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_show_error_message">Show error message when calculation fails</system:String>
|
||||
</ResourceDictionary>
|
||||
|
|
@ -79,6 +79,7 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
|
||||
if (result == null || string.IsNullOrEmpty(result.ToString()))
|
||||
{
|
||||
if (!_settings.ShowErrorMessage) return EmptyResults;
|
||||
return new List<Result>
|
||||
{
|
||||
new Result
|
||||
|
|
@ -90,10 +91,14 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
}
|
||||
|
||||
if (result.ToString() == "NaN")
|
||||
{
|
||||
result = Localize.flowlauncher_plugin_calculator_not_a_number();
|
||||
}
|
||||
|
||||
if (result is Function)
|
||||
{
|
||||
result = Localize.flowlauncher_plugin_calculator_expression_not_complete();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(result.ToString()))
|
||||
{
|
||||
|
|
@ -129,6 +134,7 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
catch (Exception)
|
||||
{
|
||||
// Mages engine can throw various exceptions, for simplicity we catch them all and show a generic message.
|
||||
if (!_settings.ShowErrorMessage) return EmptyResults;
|
||||
return new List<Result>
|
||||
{
|
||||
new Result
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
public class Settings
|
||||
{
|
||||
public DecimalSeparator DecimalSeparator { get; set; } = DecimalSeparator.UseSystemLocale;
|
||||
public int MaxDecimalPlaces { get; set; } = 10;
|
||||
|
||||
public int MaxDecimalPlaces { get; set; } = 10;
|
||||
|
||||
public bool ShowErrorMessage { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
|
@ -58,5 +59,14 @@
|
|||
ItemsSource="{Binding MaxDecimalPlacesRange}"
|
||||
SelectedItem="{Binding Settings.MaxDecimalPlaces}" />
|
||||
|
||||
<CheckBox
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Content="{DynamicResource flowlauncher_plugin_calculator_show_error_message}"
|
||||
IsChecked="{Binding Settings.ShowErrorMessage, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
|||
Loading…
Reference in a new issue