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. 6
      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();
var settingsManager = Services.GetRequiredService<ISettingsManager>();
// Unless KeepFolderLinksOnShutdown is set, delete all package junctions
// If RemoveFolderLinksOnShutdown is set, delete all package junctions
if (settingsManager is
{
IsLibraryDirSet: true,
Settings.KeepFolderLinksOnShutdown: false
Settings.RemoveFolderLinksOnShutdown: true
})
{
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 IconSource IconSource => new SymbolIconSource {Symbol = Symbol.Settings, IsFilled = true};
public string AppVersion => GetAppVersion();
// Theme panel
[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()
{
"Light",
@ -57,6 +65,7 @@ public partial class SettingsViewModel : PageViewModelBase
this.pyRunner = pyRunner;
SelectedTheme = AvailableThemes[1];
RemoveSymlinksOnShutdown = settingsManager.Settings.RemoveFolderLinksOnShutdown;
}
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()
{
@ -183,4 +188,13 @@ public partial class SettingsViewModel : PageViewModelBase
dialog.PrimaryButtonText = "Ok";
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}";
}
}

6
StabilityMatrix.Avalonia/Views/SettingsPage.axaml

@ -39,8 +39,8 @@
<StackPanel Grid.Row="1">
<ui:SettingsExpander
IconSource="Folder"
Header="Keep 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."
Header="Remove shared checkpoints directory symbolic links on shutdown"
Description="Select this option if you're having problems moving Stability Matrix to another drive."
Margin="8">
<ui:SettingsExpander.Footer>
<CheckBox Margin="8" />
@ -165,7 +165,7 @@
<Button
Background="Transparent"
BorderThickness="0"
Content="Version 0.0.0"
Content="{Binding AppVersion}"
Margin="8,0,8,8"
Padding="2,0,2,0"/>
</Grid>

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

@ -26,7 +26,7 @@ public class Settings
public ModelSearchOptions? ModelSearchOptions { get; set; }
public bool KeepFolderLinksOnShutdown { get; set; }
public bool RemoveFolderLinksOnShutdown { get; set; }
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
if (!(settingsManager?.TryFindLibrary() ?? false)) return;
// Unless KeepFolderLinksOnShutdown is set, delete all package junctions
if (!settingsManager.Settings.KeepFolderLinksOnShutdown)
// If RemoveFolderLinksOnShutdown is set, delete all package junctions
if (settingsManager.Settings.RemoveFolderLinksOnShutdown)
{
var sharedFolders = serviceProvider?.GetRequiredService<ISharedFolders>();
sharedFolders?.RemoveLinksForAllPackages();

6
StabilityMatrix/ViewModels/SettingsViewModel.cs

@ -91,9 +91,9 @@ public partial class SettingsViewModel : ObservableObject
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.prerequisiteHelper = prerequisiteHelper;
SelectedTheme = settingsManager.Settings.Theme ?? "Dark";
KeepFolderLinksOnShutdown = settingsManager.Settings.KeepFolderLinksOnShutdown;
KeepFolderLinksOnShutdown = settingsManager.Settings.RemoveFolderLinksOnShutdown;
}
[ObservableProperty]

Loading…
Cancel
Save