Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit c755435

Browse files
committed
show Everything service not running in settings
1 parent 51a25f3 commit c755435

6 files changed

Lines changed: 46 additions & 6 deletions

File tree

Everything/EverythingAPI.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ public bool IsFastSortOption(SortOption sortOption)
102102
{
103103
var fastSortOptionEnabled = EverythingApiDllImport.Everything_IsFastSort(sortOption);
104104

105+
// If the Everything service is not running, then this call will incorrectly report
106+
// the state as false. This checks for errors thrown by the api and up to the caller to handle.
107+
CheckAndThrowExceptionOnError();
108+
105109
return fastSortOptionEnabled;
106110
}
107111

EverythingSettings.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:helper="clr-namespace:Flow.Launcher.Plugin.Everything.Helper"
7-
xmlns:vm="clr-namespace:Flow.Launcher.Plugin.Everything.ViewModels"
87
mc:Ignorable="d"
98
Loaded="View_Loaded"
109
d:DesignHeight="300" d:DesignWidth="426.4">
@@ -70,7 +69,7 @@
7069
</ComboBox>
7170

7271
<TextBlock Name ="tbFastSortWarning" Grid.Row="4" Grid.Column="2" Margin="10 5 10 0" TextAlignment="Left"
73-
Text="{DynamicResource flowlauncher_plugin_everything_nonfastsort_warning}"
72+
Text="{Binding GetSortOptionWarningMessage}"
7473
Visibility ="{Binding FastSortWarningVisibility}"
7574
Foreground="Orange" TextWrapping="Wrap" />
7675
</Grid>

EverythingSettings.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ private void onSelectionChange(object sender, SelectionChangedEventArgs e)
7979
{
8080
// on load, tbFastSortWarning control will not have been loaded yet
8181
if (tbFastSortWarning is not null)
82+
{
8283
tbFastSortWarning.Visibility = vm.FastSortWarningVisibility;
84+
tbFastSortWarning.Text = vm.GetSortOptionWarningMessage;
85+
}
8386
}
8487
}
8588
}

Languages/en.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
44

5-
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Everything Service is not running</system:String>
5+
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Warning: Everything service is not running</system:String>
66
<system:String x:Key="flowlauncher_plugin_everything_query_error">Error while querying Everything</system:String>
77
<system:String x:Key="flowlauncher_plugin_everything_copied">Copied</system:String>
88
<system:String x:Key="flowlauncher_plugin_everything_canot_start">Can’t start {0}</system:String>

Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
377377

378378
public Control CreateSettingPanel()
379379
{
380-
return new EverythingSettings(_settings, new SettingsViewModel(_api, _settings));
380+
return new EverythingSettings(_settings, new SettingsViewModel(_api, _settings, _context));
381381
}
382382
}
383383
}

ViewModels/SettingsViewModel.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,50 @@ public class SettingsViewModel
77
{
88
private readonly IEverythingApi api;
99

10+
private readonly PluginInitContext context;
11+
1012
private Settings settings;
11-
public SettingsViewModel(IEverythingApi api, Settings settings)
13+
14+
public SettingsViewModel(IEverythingApi api, Settings settings, PluginInitContext context)
1215
{
1316
this.api = api;
1417
this.settings = settings;
18+
this.context = context;
1519
}
1620

1721
public Visibility FastSortWarningVisibility
1822
{
19-
get => api.IsFastSortOption(settings.SortOption)? Visibility.Hidden : Visibility.Visible;
23+
get
24+
{
25+
try
26+
{
27+
return api.IsFastSortOption(settings.SortOption) ? Visibility.Hidden : Visibility.Visible;
28+
}
29+
catch (IPCErrorException)
30+
{
31+
// this error occurs if the Everything service is not running, in this instance show the warning and
32+
// update the message to let user know in the settings panel.
33+
return Visibility.Visible;
34+
}
35+
}
36+
}
37+
38+
public string GetSortOptionWarningMessage
39+
{
40+
get
41+
{
42+
try
43+
{
44+
// this method is used to determine if Everything service is running because as at Everything v1.4.1
45+
// the sdk does not provide a dedicated interface to determine if it is running.
46+
return api.IsFastSortOption(settings.SortOption) ? string.Empty
47+
: context.API.GetTranslation("flowlauncher_plugin_everything_nonfastsort_warning");
48+
}
49+
catch (IPCErrorException)
50+
{
51+
return context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running");
52+
}
53+
}
2054
}
2155

2256
public SortOption[] GetSortOptions

0 commit comments

Comments
 (0)