From bad923dc9f1a45220e368db80a186cbd116fa8e3 Mon Sep 17 00:00:00 2001 From: DenAbr <1344505+denabr@users.noreply.github.com> Date: Tue, 6 May 2025 00:16:31 +0300 Subject: [PATCH 1/2] Show 'About this version' for CivitAI models --- .../Languages/Resources.Designer.cs | 9 +++++++++ .../Languages/Resources.resx | 3 +++ .../ViewModels/Dialogs/ModelVersionViewModel.cs | 5 +++++ .../Views/Dialogs/SelectModelVersionDialog.axaml | 16 ++++++++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/StabilityMatrix.Avalonia/Languages/Resources.Designer.cs b/StabilityMatrix.Avalonia/Languages/Resources.Designer.cs index 3afe98f42..276e47d7f 100644 --- a/StabilityMatrix.Avalonia/Languages/Resources.Designer.cs +++ b/StabilityMatrix.Avalonia/Languages/Resources.Designer.cs @@ -2153,6 +2153,15 @@ public static string Label_ModelDescription { } } + /// + /// Looks up a localized string similar to Model Version Description. + /// + public static string Label_ModelVersionDescription { + get { + return ResourceManager.GetString("Label_ModelVersionDescription", resourceCulture); + } + } + /// /// Looks up a localized string similar to Search models, #tags, or @users. /// diff --git a/StabilityMatrix.Avalonia/Languages/Resources.resx b/StabilityMatrix.Avalonia/Languages/Resources.resx index efe3537fe..cd3aa9953 100644 --- a/StabilityMatrix.Avalonia/Languages/Resources.resx +++ b/StabilityMatrix.Avalonia/Languages/Resources.resx @@ -303,6 +303,9 @@ Model Description + + About this version + A new version of Stability Matrix is available! diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs index 99261ecfc..dcd907f1f 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs @@ -10,6 +10,8 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; public partial class ModelVersionViewModel : ObservableObject { private readonly IModelIndexService modelIndexService; + + public string VersionDescription { get; set; } [ObservableProperty] private CivitModelVersion modelVersion; @@ -37,6 +39,9 @@ public ModelVersionViewModel(IModelIndexService modelIndexService, CivitModelVer ModelVersion.Files?.Select(file => new CivitFileViewModel(modelIndexService, file)) ?? new List() ); + + VersionDescription = + $"""{modelVersion.Description}"""; } public void RefreshInstallStatus() diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml index 7bc8092e6..ec913266f 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml @@ -24,7 +24,7 @@ MinHeight="450" Margin="8" ColumnDefinitions="*,Auto,*" - RowDefinitions="Auto, Auto, *, Auto"> + RowDefinitions="Auto, Auto, *, Auto, Auto"> @@ -287,10 +287,22 @@ - + + + + + + From d6d8da145b4723d86bc878e16b67263ef31a4414 Mon Sep 17 00:00:00 2001 From: DenAbr <1344505+denabr@users.noreply.github.com> Date: Sun, 20 Jul 2025 22:59:33 +0300 Subject: [PATCH 2/2] Hide expander if version description is blank --- .../Dialogs/ModelVersionViewModel.cs | 21 ++++++++++--------- .../Dialogs/SelectModelVersionDialog.axaml | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs index dcd907f1f..b934aae71 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/ModelVersionViewModel.cs @@ -10,9 +10,11 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; public partial class ModelVersionViewModel : ObservableObject { private readonly IModelIndexService modelIndexService; - + public string VersionDescription { get; set; } + public bool HasVersionDescription { get; set; } + [ObservableProperty] private CivitModelVersion modelVersion; @@ -29,17 +31,17 @@ public ModelVersionViewModel(IModelIndexService modelIndexService, CivitModelVer ModelVersion = modelVersion; IsInstalled = - ModelVersion.Files?.Any( - file => - file is { Type: CivitFileType.Model, Hashes.BLAKE3: not null } - && modelIndexService.ModelIndexBlake3Hashes.Contains(file.Hashes.BLAKE3) + ModelVersion.Files?.Any(file => + file is { Type: CivitFileType.Model, Hashes.BLAKE3: not null } + && modelIndexService.ModelIndexBlake3Hashes.Contains(file.Hashes.BLAKE3) ) ?? false; CivitFileViewModels = new ObservableCollection( ModelVersion.Files?.Select(file => new CivitFileViewModel(modelIndexService, file)) ?? new List() ); - + + HasVersionDescription = !string.IsNullOrWhiteSpace(modelVersion.Description); VersionDescription = $"""{modelVersion.Description}"""; } @@ -47,10 +49,9 @@ public ModelVersionViewModel(IModelIndexService modelIndexService, CivitModelVer public void RefreshInstallStatus() { IsInstalled = - ModelVersion.Files?.Any( - file => - file is { Type: CivitFileType.Model, Hashes.BLAKE3: not null } - && modelIndexService.ModelIndexBlake3Hashes.Contains(file.Hashes.BLAKE3) + ModelVersion.Files?.Any(file => + file is { Type: CivitFileType.Model, Hashes.BLAKE3: not null } + && modelIndexService.ModelIndexBlake3Hashes.Contains(file.Hashes.BLAKE3) ) ?? false; } } diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml index ec913266f..d7f43442d 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml @@ -293,7 +293,8 @@ Grid.ColumnSpan="3" Margin="8,8" ExpandDirection="Down" - Header="{x:Static lang:Resources.Label_ModelVersionDescription}"> + Header="{x:Static lang:Resources.Label_ModelVersionDescription}" + IsVisible="{Binding SelectedVersionViewModel.HasVersionDescription}">