Browse Source

Add savable import as connected toggle

pull/14/head
Ionite 1 year ago
parent
commit
bdc02cae3d
No known key found for this signature in database
  1. 12
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 1
      StabilityMatrix/Helper/ISettingsManager.cs
  3. 5
      StabilityMatrix/Helper/SettingsManager.cs
  4. 7
      StabilityMatrix/Models/Settings/Settings.cs
  5. 15
      StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs

12
StabilityMatrix/CheckpointManagerPage.xaml

@ -416,12 +416,22 @@
</Page.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Top settings bar -->
<ui:ToggleSwitch
Content="Import as Connected"
Grid.Column="0"
Margin="24,8" />
<StackPanel
Grid.Column="1"
Grid.Row="0"
HorizontalAlignment="Right"
Margin="16,0"
Orientation="Horizontal">
@ -449,6 +459,8 @@
<!-- Main view with model cards -->
<ui:DynamicScrollViewer
CanContentScroll="True"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">

1
StabilityMatrix/Helper/ISettingsManager.cs

@ -70,4 +70,5 @@ public interface ISettingsManager
void SetSearchOptions(ModelSearchOptions options);
Guid GetOldActivePackageId();
void SetActiveInstalledPackage(Guid guid);
void SetIsImportAsConnected(bool value);
}

5
StabilityMatrix/Helper/SettingsManager.cs

@ -223,6 +223,11 @@ public class SettingsManager : ISettingsManager
Settings.IsNavExpanded = navExpanded;
SaveSettings();
}
public void SetIsImportAsConnected(bool value)
{
Settings.IsImportAsConnected = value;
}
public void AddPathExtension(string pathExtension)
{

7
StabilityMatrix/Models/Settings/Settings.cs

@ -15,13 +15,16 @@ public class Settings
Wpf.Ui.Controls.Window.WindowBackdropType.Mica;
public List<InstalledPackage> InstalledPackages { get; set; } = new();
public Guid? ActiveInstalledPackage { get; set; }
public bool IsNavExpanded { get; set; }
public bool HasSeenWelcomeNotification { get; set; }
public List<string>? PathExtensions { get; set; }
public string? WebApiHost { get; set; }
public string? WebApiPort { get; set; }
// UI states
public bool ModelBrowserNsfwEnabled { get; set; }
public bool IsNavExpanded { get; set; }
public bool IsImportAsConnected { get; set; }
public SharedFolderType? SharedFolderVisibleCategories { get; set; } =
SharedFolderType.StableDiffusion |
SharedFolderType.Lora |

15
StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs

@ -16,6 +16,18 @@ public partial class CheckpointManagerViewModel : ObservableObject
private readonly ISharedFolders sharedFolders;
private readonly ISettingsManager settingsManager;
private readonly IDialogFactory dialogFactory;
// Toggle button for auto hashing new drag-and-dropped files for connected upgrade
[ObservableProperty] private bool isImportAsConnected;
partial void OnIsImportAsConnectedChanged(bool value)
{
if (value != settingsManager.Settings.IsImportAsConnected)
{
settingsManager.SetIsImportAsConnected(value);
}
}
public ObservableCollection<CheckpointFolder> CheckpointFolders { get; set; } = new();
public CheckpointManagerViewModel(ISharedFolders sharedFolders, ISettingsManager settingsManager, IDialogFactory dialogFactory)
@ -27,6 +39,9 @@ public partial class CheckpointManagerViewModel : ObservableObject
public async Task OnLoaded()
{
// Set UI states
IsImportAsConnected = settingsManager.Settings.IsImportAsConnected;
var modelsDirectory = settingsManager.ModelsDirectory;
// Get all folders within the shared folder root
if (string.IsNullOrWhiteSpace(modelsDirectory))

Loading…
Cancel
Save