mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Plugins - Implemented enabling/disabling (doesnt work for devices)
Plugins - Disable plugins that caused a crash Tray icon - Added menu items for quick access
This commit is contained in:
1 parent
fbc9d20db7
commit
73245a3d4b
29 files changed
+442
-164
No files matched your search
@@ -186,10 +186,9 @@ namespace Artemis.UI.Screens.Settings
|
||||
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
||||
DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device));
|
||||
|
||||
// TODO: GetPluginsOfType isn't ideal here as it doesn't include disabled plugins
|
||||
Plugins.Clear();
|
||||
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
|
||||
Plugins.Add(new PluginSettingsViewModel(plugin, _windowManager, _dialogService));
|
||||
foreach (var pluginInfo in _pluginService.GetAllPluginInfo())
|
||||
Plugins.Add(new PluginSettingsViewModel(pluginInfo.Instance, _windowManager, _dialogService, _pluginService));
|
||||
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
@@ -10,21 +11,27 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly Plugin _plugin;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService)
|
||||
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_windowManager = windowManager;
|
||||
_dialogService = dialogService;
|
||||
IsEnabled = true;
|
||||
_pluginService = pluginService;
|
||||
}
|
||||
|
||||
public string Type => _plugin.GetType().BaseType?.Name ?? _plugin.GetType().Name;
|
||||
public string Name => _plugin.PluginInfo.Name;
|
||||
public string Description => _plugin.PluginInfo.Description;
|
||||
public Version Version => _plugin.PluginInfo.Version;
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _plugin.PluginInfo.Enabled;
|
||||
set => Task.Run(() => UpdateEnabled(value));
|
||||
}
|
||||
|
||||
public bool CanOpenSettings => IsEnabled && _plugin.HasConfigurationViewModel;
|
||||
|
||||
@@ -42,5 +49,16 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnabled(in bool enable)
|
||||
{
|
||||
if (_plugin.PluginInfo.Enabled == enable)
|
||||
return;
|
||||
|
||||
if (enable)
|
||||
_pluginService.EnablePlugin(_plugin);
|
||||
else
|
||||
_pluginService.DisablePlugin(_plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user