1
0
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:
Robert 2021-06-04 21:26:00 +02:00
parent 4c3e9b2784
commit e9eebc4f36
5 changed files with 29 additions and 14 deletions

View File

@ -173,6 +173,7 @@ namespace Artemis.Core
Name = Entity.Name; Name = Entity.Name;
IsSuspended = Entity.IsSuspended; IsSuspended = Entity.IsSuspended;
ActivationBehaviour = (ActivationBehaviour) Entity.ActivationBehaviour; ActivationBehaviour = (ActivationBehaviour) Entity.ActivationBehaviour;
Order = Entity.Order;
Icon.Load(); Icon.Load();
@ -188,6 +189,7 @@ namespace Artemis.Core
Entity.IsSuspended = IsSuspended; Entity.IsSuspended = IsSuspended;
Entity.ActivationBehaviour = (int) ActivationBehaviour; Entity.ActivationBehaviour = (int) ActivationBehaviour;
Entity.ProfileCategoryId = Category.Entity.Id; Entity.ProfileCategoryId = Category.Entity.Id;
Entity.Order = Order;
Icon.Save(); Icon.Save();

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using Artemis.Core.Modules; using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
@ -487,19 +488,26 @@ namespace Artemis.Core.Services
ProfileConfiguration profileConfiguration; ProfileConfiguration profileConfiguration;
if (exportModel.ProfileConfigurationEntity != null) 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 // A new GUID will be given on save
exportModel.ProfileConfigurationEntity.FileIconId = Guid.Empty; profileConfigurationEntity.FileIconId = Guid.Empty;
profileConfiguration = new ProfileConfiguration(category, exportModel.ProfileConfigurationEntity); profileConfiguration = new ProfileConfiguration(category, profileConfigurationEntity);
if (nameAffix != null) if (nameAffix != null)
profileConfiguration.Name = $"{profileConfiguration.Name} - {nameAffix}"; profileConfiguration.Name = $"{profileConfiguration.Name} - {nameAffix}";
} }
else else
{ {
profileConfiguration = new ProfileConfiguration(category, exportModel.ProfileEntity!.Name, "Import"); profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
} }
if (exportModel.ProfileImage != null) 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; profileConfiguration.Entity.ProfileId = profileEntity.Id;
category.AddProfileConfiguration(profileConfiguration, 0); category.AddProfileConfiguration(profileConfiguration, 0);

View File

@ -9,6 +9,7 @@ namespace Artemis.Storage.Entities.Profile
public string MaterialIcon { get; set; } public string MaterialIcon { get; set; }
public Guid FileIconId { get; set; } public Guid FileIconId { get; set; }
public int IconType { get; set; } public int IconType { get; set; }
public int Order { get; set; }
public bool IsSuspended { get; set; } public bool IsSuspended { get; set; }
public int ActivationBehaviour { get; set; } public int ActivationBehaviour { get; set; }

View File

@ -1,4 +1,5 @@
using Artemis.Core.Modules; using Artemis.Core.Modules;
using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.Sidebar.Dialogs.ProfileEdit namespace Artemis.UI.Screens.Sidebar.Dialogs.ProfileEdit
@ -8,8 +9,12 @@ namespace Artemis.UI.Screens.Sidebar.Dialogs.ProfileEdit
public ProfileModuleViewModel(Module module) public ProfileModuleViewModel(Module module)
{ {
Module = module; Module = module;
Icon = module.DisplayIcon;
Name = module.DisplayName; 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; Description = module.Info.Description;
} }

View File

@ -29,7 +29,6 @@ namespace Artemis.UI.Screens.Sidebar
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IProfileService _profileService; private readonly IProfileService _profileService;
private SidebarProfileConfigurationViewModel _selectedProfileConfiguration; private SidebarProfileConfigurationViewModel _selectedProfileConfiguration;
private bool _showItems;
private readonly DefaultDropHandler _defaultDropHandler; private readonly DefaultDropHandler _defaultDropHandler;
private bool _addingProfile; private bool _addingProfile;
@ -43,7 +42,6 @@ namespace Artemis.UI.Screens.Sidebar
_dialogService = dialogService; _dialogService = dialogService;
_vmFactory = vmFactory; _vmFactory = vmFactory;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_showItems = !profileCategory.IsCollapsed;
_defaultDropHandler = new DefaultDropHandler(); _defaultDropHandler = new DefaultDropHandler();
ProfileCategory = profileCategory; ProfileCategory = profileCategory;
@ -53,15 +51,15 @@ namespace Artemis.UI.Screens.Sidebar
public bool ShowItems public bool ShowItems
{ {
get => _showItems; get => !ProfileCategory.IsCollapsed;
set set
{ {
if (!SetAndNotify(ref _showItems, value)) return; ProfileCategory.IsCollapsed = !value;
if (ProfileCategory.IsCollapsed)
if (value)
CreateProfileViewModels();
else
Items.Clear(); Items.Clear();
else
CreateProfileViewModels();
_profileService.SaveProfileCategory(ProfileCategory);
} }
} }
@ -218,7 +216,8 @@ namespace Artemis.UI.Screens.Sidebar
/// <inheritdoc /> /// <inheritdoc />
protected override void OnActivate() protected override void OnActivate()
{ {
CreateProfileViewModels(); if (ShowItems)
CreateProfileViewModels();
base.OnActivate(); base.OnActivate();
} }