mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Plugins - Fixed GetFeature<T> always returning null
Plugins - Added AlwaysEnabled property to [PluginFeature] attribute
This commit is contained in:
1 parent
0a7c724de0
commit
5545bdb783
7 files changed
+72
-19
No files matched your search
@@ -50,13 +50,17 @@
|
||||
VerticalAlignment="Center"
|
||||
Margin="8"
|
||||
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay, FallbackValue=Collapsed}"
|
||||
Orientation="Horizontal">
|
||||
Orientation="Horizontal"
|
||||
ToolTip="This feature cannot be disabled without disabling the whole plugin"
|
||||
ToolTipService.IsEnabled="{Binding FeatureInfo.AlwaysEnabled}">
|
||||
<materialDesign:PackIcon Kind="ShieldHalfFull"
|
||||
ToolTip="Plugin requires admin rights"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 5 0"
|
||||
Visibility="{Binding ShowShield, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding IsEnabled}" IsEnabled="{Binding FeatureInfo.Plugin.IsEnabled}">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
IsChecked="{Binding IsEnabled}"
|
||||
IsEnabled="{Binding CanToggleEnabled}">
|
||||
Feature enabled
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private bool _enabling;
|
||||
private readonly IMessageService _messageService;
|
||||
private bool _canToggleEnabled;
|
||||
|
||||
public PluginFeatureViewModel(PluginFeatureInfo pluginFeatureInfo,
|
||||
bool showShield,
|
||||
@@ -50,6 +51,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
set => Task.Run(() => UpdateEnabled(value));
|
||||
}
|
||||
|
||||
public bool CanToggleEnabled => FeatureInfo.Plugin.IsEnabled && !FeatureInfo.AlwaysEnabled;
|
||||
|
||||
public void ShowLogsFolder()
|
||||
{
|
||||
try
|
||||
@@ -76,6 +79,9 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
_pluginManagementService.PluginFeatureEnabled += OnFeatureEnableStopped;
|
||||
_pluginManagementService.PluginFeatureEnableFailed += OnFeatureEnableStopped;
|
||||
|
||||
FeatureInfo.Plugin.Enabled += PluginOnToggled;
|
||||
FeatureInfo.Plugin.Disabled += PluginOnToggled;
|
||||
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
@@ -85,6 +91,9 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
_pluginManagementService.PluginFeatureEnabled -= OnFeatureEnableStopped;
|
||||
_pluginManagementService.PluginFeatureEnableFailed -= OnFeatureEnableStopped;
|
||||
|
||||
FeatureInfo.Plugin.Enabled -= PluginOnToggled;
|
||||
FeatureInfo.Plugin.Disabled -= PluginOnToggled;
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
@@ -147,6 +156,11 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
NotifyOfPropertyChange(nameof(LoadException));
|
||||
}
|
||||
|
||||
private void PluginOnToggled(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(CanToggleEnabled));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user