mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile properties - Fix custom module icons missing
Profiles - Fix duplicating a profile causing weird behaviour Sidebar - Remember category collapse state
This commit is contained in:
parent
4c3e9b2784
commit
e9eebc4f36
@ -173,6 +173,7 @@ namespace Artemis.Core
|
||||
Name = Entity.Name;
|
||||
IsSuspended = Entity.IsSuspended;
|
||||
ActivationBehaviour = (ActivationBehaviour) Entity.ActivationBehaviour;
|
||||
Order = Entity.Order;
|
||||
|
||||
Icon.Load();
|
||||
|
||||
@ -188,6 +189,7 @@ namespace Artemis.Core
|
||||
Entity.IsSuspended = IsSuspended;
|
||||
Entity.ActivationBehaviour = (int) ActivationBehaviour;
|
||||
Entity.ProfileCategoryId = Category.Entity.Id;
|
||||
Entity.Order = Order;
|
||||
|
||||
Icon.Save();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
@ -487,19 +488,26 @@ namespace Artemis.Core.Services
|
||||
ProfileConfiguration profileConfiguration;
|
||||
if (exportModel.ProfileConfigurationEntity != null)
|
||||
{
|
||||
ProfileConfigurationEntity profileConfigurationEntity = JsonConvert.DeserializeObject<ProfileConfigurationEntity>(
|
||||
JsonConvert.SerializeObject(exportModel.ProfileConfigurationEntity, IProfileService.ExportSettings), IProfileService.ExportSettings
|
||||
)!;
|
||||
// A new GUID will be given on save
|
||||
exportModel.ProfileConfigurationEntity.FileIconId = Guid.Empty;
|
||||
profileConfiguration = new ProfileConfiguration(category, exportModel.ProfileConfigurationEntity);
|
||||
profileConfigurationEntity.FileIconId = Guid.Empty;
|
||||
profileConfiguration = new ProfileConfiguration(category, profileConfigurationEntity);
|
||||
if (nameAffix != null)
|
||||
profileConfiguration.Name = $"{profileConfiguration.Name} - {nameAffix}";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileConfiguration = new ProfileConfiguration(category, exportModel.ProfileEntity!.Name, "Import");
|
||||
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
|
||||
}
|
||||
|
||||
if (exportModel.ProfileImage != null)
|
||||
profileConfiguration.Icon.FileIcon = exportModel.ProfileImage;
|
||||
{
|
||||
profileConfiguration.Icon.FileIcon = new MemoryStream();
|
||||
exportModel.ProfileImage.Position = 0;
|
||||
exportModel.ProfileImage.CopyTo(profileConfiguration.Icon.FileIcon);
|
||||
}
|
||||
|
||||
profileConfiguration.Entity.ProfileId = profileEntity.Id;
|
||||
category.AddProfileConfiguration(profileConfiguration, 0);
|
||||
|
||||
@ -9,6 +9,7 @@ namespace Artemis.Storage.Entities.Profile
|
||||
public string MaterialIcon { get; set; }
|
||||
public Guid FileIconId { get; set; }
|
||||
public int IconType { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public bool IsSuspended { get; set; }
|
||||
public int ActivationBehaviour { get; set; }
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Modules;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar.Dialogs.ProfileEdit
|
||||
@ -8,8 +9,12 @@ namespace Artemis.UI.Screens.Sidebar.Dialogs.ProfileEdit
|
||||
public ProfileModuleViewModel(Module module)
|
||||
{
|
||||
Module = module;
|
||||
Icon = module.DisplayIcon;
|
||||
Name = module.DisplayName;
|
||||
if (module.DisplayIcon != null)
|
||||
Icon = module.DisplayIcon.EndsWith(".svg") ? module.Plugin.ResolveRelativePath(module.DisplayIcon) : module.DisplayIcon;
|
||||
else
|
||||
Icon = PackIconKind.QuestionMark.ToString();
|
||||
|
||||
Description = module.Info.Description;
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly IProfileService _profileService;
|
||||
private SidebarProfileConfigurationViewModel _selectedProfileConfiguration;
|
||||
private bool _showItems;
|
||||
private readonly DefaultDropHandler _defaultDropHandler;
|
||||
private bool _addingProfile;
|
||||
|
||||
@ -43,7 +42,6 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
_dialogService = dialogService;
|
||||
_vmFactory = vmFactory;
|
||||
_eventAggregator = eventAggregator;
|
||||
_showItems = !profileCategory.IsCollapsed;
|
||||
_defaultDropHandler = new DefaultDropHandler();
|
||||
|
||||
ProfileCategory = profileCategory;
|
||||
@ -53,15 +51,15 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
|
||||
public bool ShowItems
|
||||
{
|
||||
get => _showItems;
|
||||
get => !ProfileCategory.IsCollapsed;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _showItems, value)) return;
|
||||
|
||||
if (value)
|
||||
CreateProfileViewModels();
|
||||
else
|
||||
ProfileCategory.IsCollapsed = !value;
|
||||
if (ProfileCategory.IsCollapsed)
|
||||
Items.Clear();
|
||||
else
|
||||
CreateProfileViewModels();
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +216,8 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
/// <inheritdoc />
|
||||
protected override void OnActivate()
|
||||
{
|
||||
CreateProfileViewModels();
|
||||
if (ShowItems)
|
||||
CreateProfileViewModels();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user