Browse Source

Added Favorite button to model browser cards, moved the Open in CivitAI link to the three-dots menu & fixed Japanese translation display issue

pull/165/head
JT 1 year ago
parent
commit
7b06ff6813
  1. 3
      CHANGELOG.md
  2. 21
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs
  3. 13
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs
  4. 61
      StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml
  5. 4
      StabilityMatrix.Avalonia/Views/LaunchPageView.axaml
  6. 6
      StabilityMatrix.Core/Models/Api/CivitSortMode.cs
  7. 2
      StabilityMatrix.Core/Models/Settings/Settings.cs

3
CHANGELOG.md

@ -8,12 +8,15 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
## v2.5.0
### Added
- Added option to change the Shared Folder method for packages using the three-dots menu on the Packages page
- Added the ability to Favorite models in the Model Browser
- Added "Favorites" sort option to the Model Browser
### Changed
- Model Browser page size is now 20 instead of 14
### Fixed
- Fixed [#141](https://github.com/LykosAI/StabilityMatrix/issues/141) - Search not working when sorting by Installed on Model Browser
- Fixed SD.Next not showing "Open Web UI" button when finished loading
- Fixed model index startup errors when `./Models` contains unknown custom folder names
- Fixed ストップ button being cut off in Japanese translation
## v2.4.6
### Added

21
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs

@ -44,10 +44,12 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
set
{
civitModel = value;
IsFavorite = settingsManager.Settings.FavoriteModels.Contains(value.Id);
UpdateImage();
CheckIfInstalled();
}
}
private CivitModel civitModel;
public override bool IsTextVisible => Value > 0;
@ -62,7 +64,9 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
[ObservableProperty]
private bool showUpdateCard;
private CivitModel civitModel;
[ObservableProperty]
private bool isFavorite;
public CheckpointBrowserCardViewModel(
IDownloadService downloadService,
@ -167,6 +171,21 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
ProcessRunner.OpenUrl($"https://civitai.com/models/{CivitModel.Id}");
}
[RelayCommand]
private void ToggleFavorite()
{
if (settingsManager.Settings.FavoriteModels.Contains(CivitModel.Id))
{
settingsManager.Transaction(s => s.FavoriteModels.Remove(CivitModel.Id));
}
else
{
settingsManager.Transaction(s => s.FavoriteModels.Add(CivitModel.Id));
}
IsFavorite = settingsManager.Settings.FavoriteModels.Contains(CivitModel.Id);
}
[RelayCommand]
private async Task Import(CivitModel model)
{

13
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs

@ -441,11 +441,6 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase
.GetAllCheckpointFiles(settingsManager.ModelsDirectory)
.Where(c => c.IsConnectedModel);
if (SelectedModelType != CivitModelType.All)
{
connectedModels = connectedModels.Where(c => c.ModelType == SelectedModelType);
}
modelRequest.CommaSeparatedModelIds = string.Join(
",",
connectedModels
@ -456,6 +451,14 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase
modelRequest.Sort = null;
modelRequest.Period = null;
}
else if (SortMode == CivitSortMode.Favorites)
{
var favoriteModels = settingsManager.Settings.FavoriteModels;
modelRequest.CommaSeparatedModelIds = string.Join(",", favoriteModels);
modelRequest.Sort = null;
modelRequest.Period = null;
}
// See if query is cached
var cachedQuery = await liteDbContext.CivitModelQueryCache

61
StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml

@ -26,11 +26,36 @@
Width="330">
<StackPanel Orientation="Vertical">
<TextBlock
Foreground="{DynamicResource TextControlForeground}"
Margin="0,0,0,0"
Text="{Binding CivitModel.Name}"
VerticalAlignment="Center" />
<Grid ColumnDefinitions="*, Auto"
Margin="0,-4,0,0">
<TextBlock
Foreground="{DynamicResource TextControlForeground}"
Text="{Binding CivitModel.Name}"
VerticalAlignment="Center" />
<Button
Grid.Column="1"
HorizontalContentAlignment="Right"
HorizontalAlignment="Right"
VerticalContentAlignment="Top"
VerticalAlignment="Top"
Padding="4,2"
Margin="4,0,0,0"
Classes="transparent"
Width="24"
BorderThickness="0">
<ui:SymbolIcon FontSize="18" Symbol="MoreVertical" />
<Button.Flyout>
<MenuFlyout>
<MenuItem Header="{x:Static lang:Resources.Action_OpenOnCivitAi}"
Command="{Binding OpenModelCommand}">
<MenuItem.Icon>
<ui:SymbolIcon Symbol="Open" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</Button.Flyout>
</Button>
</Grid>
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextControlForeground}"
@ -49,16 +74,30 @@
Stretch="UniformToFill" />
<Button
Command="{Binding OpenModelCommand}"
CommandParameter="{Binding CivitModel}"
Command="{Binding ToggleFavoriteCommand}"
HorizontalAlignment="Right"
Classes="transparent-info"
Margin="0,16,8,0"
FontSize="20"
Classes="info"
IsVisible="{Binding !IsFavorite}"
VerticalAlignment="Top">
<Button.Content>
<ui:SymbolIcon Symbol="Open" />
</Button.Content>
<Grid>
<ui:SymbolIcon Symbol="StarAdd" />
</Grid>
</Button>
<Button
Command="{Binding ToggleFavoriteCommand}"
HorizontalAlignment="Right"
Margin="0,16,8,0"
FontSize="20"
Classes="success"
IsVisible="{Binding IsFavorite}"
VerticalAlignment="Top">
<Grid>
<ui:SymbolIcon Symbol="StarFilled" />
</Grid>
</Button>
<StackPanel Orientation="Horizontal">
<controls:Card
Classes="info"

4
StabilityMatrix.Avalonia/Views/LaunchPageView.axaml

@ -35,7 +35,7 @@
Grid.Row="0"
Grid.Column="0">
<Button
Width="72"
Width="84"
IsVisible="{Binding !SelectedBasePackage.ExtraLaunchCommands.Count, FallbackValue=False}"
Classes="success"
HorizontalAlignment="Left"
@ -84,7 +84,7 @@
Grid.Row="0"
Grid.Column="0">
<Button
Width="72"
Width="84"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Classes="danger"

6
StabilityMatrix.Core/Models/Api/CivitSortMode.cs

@ -8,10 +8,16 @@ public enum CivitSortMode
{
[EnumMember(Value = "Highest Rated")]
HighestRated,
[EnumMember(Value = "Most Downloaded")]
MostDownloaded,
[EnumMember(Value = "Newest")]
Newest,
[EnumMember(Value = "Installed")]
Installed,
[EnumMember(Value = "Favorites")]
Favorites,
}

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

@ -58,6 +58,8 @@ public class Settings
public bool AutoScrollLaunchConsoleToEnd { get; set; } = true;
public HashSet<int> FavoriteModels { get; set; } = new();
public void RemoveInstalledPackageAndUpdateActive(InstalledPackage package)
{
RemoveInstalledPackageAndUpdateActive(package.Id);

Loading…
Cancel
Save