mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Settings - Added most of the plugins tab
This commit is contained in:
parent
56f5b91f11
commit
7954012e31
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
@ -49,8 +51,12 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
|
|
||||||
_pluginManagementService.PluginDisabled += PluginManagementServiceOnPluginToggled;
|
_pluginManagementService.PluginDisabled += PluginManagementServiceOnPluginToggled;
|
||||||
_pluginManagementService.PluginEnabled += PluginManagementServiceOnPluginToggled;
|
_pluginManagementService.PluginEnabled += PluginManagementServiceOnPluginToggled;
|
||||||
|
|
||||||
|
OpenSettings = ReactiveCommand.Create(ExecuteOpenSettings, this.WhenAnyValue(x => x.IsEnabled).Select(isEnabled => isEnabled && Plugin.ConfigurationDialog != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> OpenSettings { get; }
|
||||||
|
|
||||||
public ObservableCollection<PluginFeatureViewModel> PluginFeatures { get; }
|
public ObservableCollection<PluginFeatureViewModel> PluginFeatures { get; }
|
||||||
|
|
||||||
public Plugin Plugin
|
public Plugin Plugin
|
||||||
@ -66,8 +72,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
|
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
|
||||||
public bool CanOpenSettings => IsEnabled && Plugin.ConfigurationDialog != null;
|
|
||||||
|
|
||||||
public bool IsEnabled
|
public bool IsEnabled
|
||||||
{
|
{
|
||||||
get => Plugin.IsEnabled;
|
get => Plugin.IsEnabled;
|
||||||
@ -96,7 +101,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
set => this.RaiseAndSetIfChanged(ref _canRemovePrerequisites, value);
|
set => this.RaiseAndSetIfChanged(ref _canRemovePrerequisites, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenSettings()
|
private void ExecuteOpenSettings()
|
||||||
{
|
{
|
||||||
if (Plugin.ConfigurationDialog == null)
|
if (Plugin.ConfigurationDialog == null)
|
||||||
return;
|
return;
|
||||||
@ -163,7 +168,6 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
{
|
{
|
||||||
await PluginPrerequisitesUninstallDialogViewModel.Show(_windowService, subjects, forPluginRemoval ? "Skip, remove plugin" : "Cancel");
|
await PluginPrerequisitesUninstallDialogViewModel.Show(_windowService, subjects, forPluginRemoval ? "Skip, remove plugin" : "Cancel");
|
||||||
this.RaisePropertyChanged(nameof(IsEnabled));
|
this.RaisePropertyChanged(nameof(IsEnabled));
|
||||||
this.RaisePropertyChanged(nameof(CanOpenSettings));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +246,6 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
private void PluginManagementServiceOnPluginToggled(object? sender, PluginEventArgs e)
|
private void PluginManagementServiceOnPluginToggled(object? sender, PluginEventArgs e)
|
||||||
{
|
{
|
||||||
this.RaisePropertyChanged(nameof(IsEnabled));
|
this.RaisePropertyChanged(nameof(IsEnabled));
|
||||||
this.RaisePropertyChanged(nameof(CanOpenSettings));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateEnabled(bool enable)
|
private async Task UpdateEnabled(bool enable)
|
||||||
@ -306,14 +309,12 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.RaisePropertyChanged(nameof(IsEnabled));
|
this.RaisePropertyChanged(nameof(IsEnabled));
|
||||||
this.RaisePropertyChanged(nameof(CanOpenSettings));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelEnable()
|
private void CancelEnable()
|
||||||
{
|
{
|
||||||
Enabling = false;
|
Enabling = false;
|
||||||
this.RaisePropertyChanged(nameof(IsEnabled));
|
this.RaisePropertyChanged(nameof(IsEnabled));
|
||||||
this.RaisePropertyChanged(nameof(CanOpenSettings));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckPrerequisites()
|
private void CheckPrerequisites()
|
||||||
|
|||||||
@ -2,7 +2,116 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Avalonia.Screens.Plugins.Views.PluginSettingsView">
|
x:Class="Artemis.UI.Avalonia.Screens.Plugins.Views.PluginSettingsView">
|
||||||
Welcome to Avalonia!
|
<Border Classes="card" Width="900" Padding="15" Margin="0 5">
|
||||||
</UserControl>
|
<Grid RowDefinitions="*,Auto" ColumnDefinitions="4*,5*">
|
||||||
|
<Grid Grid.Row="0" RowDefinitions="Auto,Auto,*" ColumnDefinitions="80,*">
|
||||||
|
<avalonia:MaterialIcon Kind="{Binding Plugin.Info.ResolvedIcon}"
|
||||||
|
Width="48"
|
||||||
|
Height="48"
|
||||||
|
Margin="0 5 0 0"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="3"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="1" Grid.Row="0" Classes="h5 no-margin" Text="{Binding Plugin.Info.Name}" />
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Classes="subtitle"
|
||||||
|
Text="{Binding Plugin.Info.Author}"
|
||||||
|
IsVisible="{Binding Plugin.Info.Author, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
Grid.Row="2"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="0 5"
|
||||||
|
Text="{Binding Plugin.Info.Description}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" Grid.Column="0" ColumnDefinitions="*,Auto">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<controls:SplitButton Content="Settings" Command="{Binding OpenSettings}">
|
||||||
|
<controls:SplitButton.Flyout>
|
||||||
|
<MenuFlyout Placement="Bottom">
|
||||||
|
<MenuItem Header="Open plugin directory" Command="{Binding OpenPluginDirectory}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="FolderOpen" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Reload plugin" Command="{Binding Reload}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="Reload" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Install prerequisites" Command="{Binding InstallPrerequisites}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="CheckAll" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Remove prerequisites" Command="{Binding RemovePrerequisites}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="Delete" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Clear plugin settings" Command="{Binding RemoveSettings}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="DatabaseRemove" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Remove plugin" Command="{Binding Remove}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<avalonia:MaterialIcon Kind="DeleteForever" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
</MenuFlyout>
|
||||||
|
</controls:SplitButton.Flyout>
|
||||||
|
</controls:SplitButton>
|
||||||
|
|
||||||
|
<controls:HyperlinkButton Classes="icon-button"
|
||||||
|
Margin="5 0"
|
||||||
|
IsVisible="{Binding Plugin.Info.Website, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
NavigateUri="{Binding Plugin.Info.Website}">
|
||||||
|
<avalonia:MaterialIcon Kind="Web" />
|
||||||
|
</controls:HyperlinkButton>
|
||||||
|
<controls:HyperlinkButton Classes="icon-button"
|
||||||
|
Margin="5 0"
|
||||||
|
IsVisible="{Binding Plugin.Info.Repository, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
NavigateUri="{Binding Plugin.Info.Repository}">
|
||||||
|
<avalonia:MaterialIcon Kind="Git" />
|
||||||
|
</controls:HyperlinkButton>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<CheckBox Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
IsVisible="{Binding !Enabling}"
|
||||||
|
IsChecked="{Binding IsEnabled}">
|
||||||
|
<StackPanel x:Name="EnableText" Orientation="Horizontal">
|
||||||
|
<TextBlock>Plugin enabled</TextBlock>
|
||||||
|
<avalonia:MaterialIcon Kind="ShieldHalfFull"
|
||||||
|
Margin="5 0 0 0"
|
||||||
|
ToolTip.Tip="Plugin requires admin rights"
|
||||||
|
IsVisible="{Binding Plugin.Info.RequiresAdmin}" />
|
||||||
|
</StackPanel>
|
||||||
|
</CheckBox>
|
||||||
|
|
||||||
|
<ProgressBar Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
IsVisible="{Binding Enabling}"
|
||||||
|
IsIndeterminate="True" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Border Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" BorderBrush="{StaticResource ButtonBorderBrush}" BorderThickness="1 0 0 0" Margin="10 0 0 0" Padding="10 0 0 0">
|
||||||
|
<Grid RowDefinitions="Auto,*">
|
||||||
|
<TextBlock Classes="h5">Plugin features</TextBlock>
|
||||||
|
<ListBox Grid.Row="1" MaxHeight="135" Items="{Binding PluginFeatures}" />
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</UserControl>
|
||||||
@ -39,6 +39,9 @@
|
|||||||
<Setter Property="FontSize" Value="14" />
|
<Setter Property="FontSize" Value="14" />
|
||||||
<Setter Property="Margin" Value="0 0 0 2" />
|
<Setter Property="Margin" Value="0 0 0 2" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style Selector="TextBlock.no-margin">
|
||||||
|
<Setter Property="Margin" Value="0" />
|
||||||
|
</Style>
|
||||||
<Style Selector="TextBlock.subtitle">
|
<Style Selector="TextBlock.subtitle">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorTertiaryBrush}" />
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user