mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Plugin settings - Only enable install/uninstall prereqs when applicable
Sidebar - Added missing context menu on profiles
This commit is contained in:
1 parent
45e810c3ac
commit
3625d1ad11
7 files changed
+142
-68
No files matched your search
@@ -49,7 +49,7 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<controls:SplitButton Content="Settings" Command="{CompiledBinding OpenSettings}">
|
||||
<controls:SplitButton.Flyout>
|
||||
<MenuFlyout Placement="Bottom" IsOpen="{CompiledBinding IsSettingsPopupOpen, Mode=OneWayToSource}">
|
||||
<MenuFlyout Placement="Bottom" Opening="FlyoutBase_OnOpening">
|
||||
<MenuItem Header="Open plugin directory" Command="{CompiledBinding OpenPluginDirectory}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="FolderOpen" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -27,4 +28,9 @@ public partial class PluginView : ReactiveUserControl<PluginViewModel>
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => ViewModel?.UpdateEnabled(!ViewModel.Plugin.IsEnabled));
|
||||
}
|
||||
|
||||
private void FlyoutBase_OnOpening(object? sender, EventArgs e)
|
||||
{
|
||||
ViewModel?.CheckPrerequisites();
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,13 @@ public class PluginViewModel : ActivatableViewModelBase
|
||||
private bool _canInstallPrerequisites;
|
||||
private bool _canRemovePrerequisites;
|
||||
private bool _enabling;
|
||||
private bool _isSettingsPopupOpen;
|
||||
private Plugin _plugin;
|
||||
private Window? _window;
|
||||
|
||||
public PluginViewModel(Plugin plugin,
|
||||
ReactiveCommand<Unit, Unit>? reload,
|
||||
ICoreService coreService,
|
||||
IWindowService windowService,
|
||||
public PluginViewModel(Plugin plugin,
|
||||
ReactiveCommand<Unit, Unit>? reload,
|
||||
ICoreService coreService,
|
||||
IWindowService windowService,
|
||||
INotificationService notificationService,
|
||||
IPluginManagementService pluginManagementService)
|
||||
{
|
||||
@@ -105,16 +104,6 @@ public class PluginViewModel : ActivatableViewModelBase
|
||||
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
|
||||
public bool IsEnabled => Plugin.IsEnabled;
|
||||
|
||||
public bool IsSettingsPopupOpen
|
||||
{
|
||||
get => _isSettingsPopupOpen;
|
||||
set
|
||||
{
|
||||
if (!RaiseAndSetIfChanged(ref _isSettingsPopupOpen, value)) return;
|
||||
CheckPrerequisites();
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanInstallPrerequisites
|
||||
{
|
||||
get => _canInstallPrerequisites;
|
||||
@@ -166,7 +155,7 @@ public class PluginViewModel : ActivatableViewModelBase
|
||||
_windowService.ShowExceptionDialog("Welp, we couldn't open the device's plugin folder for you", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task ExecuteInstallPrerequisites()
|
||||
{
|
||||
List<IPrerequisitesSubject> subjects = new() {Plugin.Info};
|
||||
@@ -309,12 +298,17 @@ public class PluginViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
|
||||
private void CheckPrerequisites()
|
||||
public void CheckPrerequisites()
|
||||
{
|
||||
CanInstallPrerequisites = Plugin.Info.PlatformPrerequisites.Any() ||
|
||||
Plugin.Features.Where(f => f.AlwaysEnabled).Any(f => f.PlatformPrerequisites.Any());
|
||||
CanRemovePrerequisites = Plugin.Info.PlatformPrerequisites.Any(p => p.UninstallActions.Any()) ||
|
||||
Plugin.Features.Where(f => f.AlwaysEnabled).Any(f => f.PlatformPrerequisites.Any(p => p.UninstallActions.Any()));
|
||||
CanInstallPrerequisites = false;
|
||||
CanRemovePrerequisites = false;
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
CanInstallPrerequisites = !Plugin.Info.ArePrerequisitesMet() || Plugin.Features.Where(f => f.AlwaysEnabled).Any(f => !f.ArePrerequisitesMet());
|
||||
CanRemovePrerequisites = Plugin.Info.PlatformPrerequisites.Any(p => p.IsMet() && p.UninstallActions.Any()) ||
|
||||
Plugin.Features.Where(f => f.AlwaysEnabled).Any(f => f.PlatformPrerequisites.Any(p => p.IsMet() && p.UninstallActions.Any()));
|
||||
});
|
||||
}
|
||||
|
||||
private void OnPluginToggled(object? sender, EventArgs e)
|
||||
|
||||
Reference in new issue
Block a user