Browse Source

keepFolderLinksOnShutdown -> RemoveFolderLinksOnShutdown & also fix app version

pull/55/head
JT 1 year ago
parent
commit
8e644e4c1b
  1. 4
      StabilityMatrix.Avalonia/App.axaml.cs
  2. 22
      StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs
  3. 8
      StabilityMatrix.Avalonia/Views/SettingsPage.axaml
  4. 2
      StabilityMatrix.Core/Models/Settings/Settings.cs
  5. 4
      StabilityMatrix/App.xaml.cs
  6. 6
      StabilityMatrix/ViewModels/SettingsViewModel.cs

4
StabilityMatrix.Avalonia/App.axaml.cs

@ -358,11 +358,11 @@ public sealed class App : Application
// Services.GetRequiredService<LaunchViewModel>().OnShutdown(); // Services.GetRequiredService<LaunchViewModel>().OnShutdown();
var settingsManager = Services.GetRequiredService<ISettingsManager>(); var settingsManager = Services.GetRequiredService<ISettingsManager>();
// Unless KeepFolderLinksOnShutdown is set, delete all package junctions // If RemoveFolderLinksOnShutdown is set, delete all package junctions
if (settingsManager is if (settingsManager is
{ {
IsLibraryDirSet: true, IsLibraryDirSet: true,
Settings.KeepFolderLinksOnShutdown: false Settings.RemoveFolderLinksOnShutdown: true
}) })
{ {
var sharedFolders = Services.GetRequiredService<ISharedFolders>(); var sharedFolders = Services.GetRequiredService<ISharedFolders>();

22
StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs

@ -34,10 +34,18 @@ public partial class SettingsViewModel : PageViewModelBase
public override string Title => "Settings"; public override string Title => "Settings";
public override IconSource IconSource => new SymbolIconSource {Symbol = Symbol.Settings, IsFilled = true}; public override IconSource IconSource => new SymbolIconSource {Symbol = Symbol.Settings, IsFilled = true};
public string AppVersion => GetAppVersion();
// Theme panel // Theme panel
[ObservableProperty] private string? selectedTheme; [ObservableProperty] private string? selectedTheme;
// Debug info
[ObservableProperty] private string? debugPaths;
[ObservableProperty] private string? debugCompatInfo;
[ObservableProperty] private string? debugGpuInfo;
[ObservableProperty] private bool removeSymlinksOnShutdown;
public ObservableCollection<string> AvailableThemes { get; } = new() public ObservableCollection<string> AvailableThemes { get; } = new()
{ {
"Light", "Light",
@ -57,6 +65,7 @@ public partial class SettingsViewModel : PageViewModelBase
this.pyRunner = pyRunner; this.pyRunner = pyRunner;
SelectedTheme = AvailableThemes[1]; SelectedTheme = AvailableThemes[1];
RemoveSymlinksOnShutdown = settingsManager.Settings.RemoveFolderLinksOnShutdown;
} }
partial void OnSelectedThemeChanged(string? value) partial void OnSelectedThemeChanged(string? value)
@ -72,10 +81,6 @@ public partial class SettingsViewModel : PageViewModelBase
}; };
} }
// Debug info
[ObservableProperty] private string? debugPaths;
[ObservableProperty] private string? debugCompatInfo;
[ObservableProperty] private string? debugGpuInfo;
public void LoadDebugInfo() public void LoadDebugInfo()
{ {
@ -183,4 +188,13 @@ public partial class SettingsViewModel : PageViewModelBase
dialog.PrimaryButtonText = "Ok"; dialog.PrimaryButtonText = "Ok";
await dialog.ShowAsync(); await dialog.ShowAsync();
} }
private static string GetAppVersion()
{
var assembly = Assembly.GetExecutingAssembly();
var version = assembly.GetName().Version;
return version == null
? "(Unknown)"
: $"Version {version.Major}.{version.Minor}.{version.Build}";
}
} }

8
StabilityMatrix.Avalonia/Views/SettingsPage.axaml

@ -39,8 +39,8 @@
<StackPanel Grid.Row="1"> <StackPanel Grid.Row="1">
<ui:SettingsExpander <ui:SettingsExpander
IconSource="Folder" IconSource="Folder"
Header="Keep shared checkpoints directory symbolic links on shutdown" Header="Remove shared checkpoints directory symbolic links on shutdown"
Description="Normally removed on shutdown to allow the data folder to be moved without potential file explorer issues." Description="Select this option if you're having problems moving Stability Matrix to another drive."
Margin="8"> Margin="8">
<ui:SettingsExpander.Footer> <ui:SettingsExpander.Footer>
<CheckBox Margin="8" /> <CheckBox Margin="8" />
@ -165,9 +165,9 @@
<Button <Button
Background="Transparent" Background="Transparent"
BorderThickness="0" BorderThickness="0"
Content="Version 0.0.0" Content="{Binding AppVersion}"
Margin="8,0,8,8" Margin="8,0,8,8"
Padding="2,0,2,0" /> Padding="2,0,2,0"/>
</Grid> </Grid>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">

2
StabilityMatrix.Core/Models/Settings/Settings.cs

@ -26,7 +26,7 @@ public class Settings
public ModelSearchOptions? ModelSearchOptions { get; set; } public ModelSearchOptions? ModelSearchOptions { get; set; }
public bool KeepFolderLinksOnShutdown { get; set; } public bool RemoveFolderLinksOnShutdown { get; set; }
public HashSet<string>? InstalledModelHashes { get; set; } = new(); public HashSet<string>? InstalledModelHashes { get; set; } = new();

4
StabilityMatrix/App.xaml.cs

@ -377,8 +377,8 @@ namespace StabilityMatrix
// Skip remaining steps if no library is set // Skip remaining steps if no library is set
if (!(settingsManager?.TryFindLibrary() ?? false)) return; if (!(settingsManager?.TryFindLibrary() ?? false)) return;
// Unless KeepFolderLinksOnShutdown is set, delete all package junctions // If RemoveFolderLinksOnShutdown is set, delete all package junctions
if (!settingsManager.Settings.KeepFolderLinksOnShutdown) if (settingsManager.Settings.RemoveFolderLinksOnShutdown)
{ {
var sharedFolders = serviceProvider?.GetRequiredService<ISharedFolders>(); var sharedFolders = serviceProvider?.GetRequiredService<ISharedFolders>();
sharedFolders?.RemoveLinksForAllPackages(); sharedFolders?.RemoveLinksForAllPackages();

6
StabilityMatrix/ViewModels/SettingsViewModel.cs

@ -91,9 +91,9 @@ public partial class SettingsViewModel : ObservableObject
partial void OnKeepFolderLinksOnShutdownChanged(bool value) partial void OnKeepFolderLinksOnShutdownChanged(bool value)
{ {
if (value != settingsManager.Settings.KeepFolderLinksOnShutdown) if (value != settingsManager.Settings.RemoveFolderLinksOnShutdown)
{ {
settingsManager.Transaction(s => s.KeepFolderLinksOnShutdown = value); settingsManager.Transaction(s => s.RemoveFolderLinksOnShutdown = value);
} }
} }
@ -127,7 +127,7 @@ public partial class SettingsViewModel : ObservableObject
this.liteDbContext = liteDbContext; this.liteDbContext = liteDbContext;
this.prerequisiteHelper = prerequisiteHelper; this.prerequisiteHelper = prerequisiteHelper;
SelectedTheme = settingsManager.Settings.Theme ?? "Dark"; SelectedTheme = settingsManager.Settings.Theme ?? "Dark";
KeepFolderLinksOnShutdown = settingsManager.Settings.KeepFolderLinksOnShutdown; KeepFolderLinksOnShutdown = settingsManager.Settings.RemoveFolderLinksOnShutdown;
} }
[ObservableProperty] [ObservableProperty]

Loading…
Cancel
Save